title: Calling an Ansible Module from another Ansible Module?
body: <h1>Question</h1>
  
  <p>Is it possible to call an Ansible module from another Ansible module programmatically?</p>
  
  <h1>Context</h1>
  
  <p>I have been working with Cisco UCS via Python (ucsmsdk) and Ansible to create a means of automating service profile templates (SPTs from now on). I have created <a href="https://github.com/de-crob/ucsm_apis" rel="noreferrer">apis</a> and <a href="https://github.com/de-crob/ucsm-ansible" rel="noreferrer">modules</a> conforming to the standards set in the respective Git repos.</p>
  
  <p>While I am able to create these SPTs with an Ansible playbook, it requires a lot of reused properties to create each individual item and follow their long chains of parent/child relationships. I would like to remove all this reuse and simplify the creation of the items by feeding all the parameters I need to do this in one go with their structure in tact. </p>
  
  <p>The example below shows the current system to what I would like.  </p>
  
  <h3>Current</h3>
  
  <pre><code>tasks:
  - name: create ls server
    ls_server_module:
      name: ex
      other_args:
      creds: 
  - name: create VNIC Ether
    vnic_ether_module:
      name: ex_child
      parent: ex
      other_args: 
      creds: 
  - name: create VNIC Ether If (VLAN)
    vnic_ether_if_module:
      name: ex_child_child
      parent: ex_child
      creds: 
  - name: create VNIC Ether
    vnic_ether_module:
      name: ex_child_2
      parent: ex
      other_args: 
      creds: 
  </code></pre>
  
  <h3>Desired</h3>
  
  <pre><code>tasks:
  - name: create template
    spt_module:
      name: ex
      other_args:
      creds: 
      LAN:
        VNIC:
        - name: ex_child
          other_args:
          vlans:
          - ex_child_child
        - name: ex_child_2
          other_args:
  </code></pre>
  
  <p>Currently, my only barrier is inducing some code reuse by calling these modules that create the object in a dynamic and programmatic way.</p>