<p>What about using a CI tool? Create a parallel job and the jobs will run parallel. For example, one could use Jenkins:</p>

<p><a href="https://jenkins.io/blog/2017/09/25/declarative-1/" rel="nofollow noreferrer">https://jenkins.io/blog/2017/09/25/declarative-1/</a></p>

<blockquote>
<pre><code>stage('run-parallel-branches') {
  steps {
    parallel(
      a: {
        echo "This is branch a"
      },
      b: {
        echo "This is branch b"
      }
    )
  }
}
</code></pre>
</blockquote>

<p>but there are other CI tools that could do the same.</p>

CC BY-SA 3.0
2018-02-21T18:47:04.897Z
2018-02-21T18:47:04.897Z
030
<p><strong>Issue</strong></p>

<p>I have an Ansible role which covers Windows, macOS and Ubuntu OS. I also have a Packer template file for each OS (due to small nuances and changes in the template file to handle provisioning) which handles standing up and provisioning the VM with Ansible onto VSphere.</p>

<p>So to build all three VMs, it goes something like:</p>

<pre><code>  Windows build                Mac build                 Ubuntu build
---------------------     ---------------------      --------------------
| Packer -&gt; Ansible | --&gt; | Packer -&gt; Ansible | ---&gt; |Packer -&gt; Ansible |
---------------------     ---------------------      --------------------
</code></pre>

<p>Which isn't very efficient and can take a while.</p>

<p><strong>Solution</strong></p>

<p>I'm thinking of parallelising this somehow, by potentially having Packer standup all three VMs, but not provision it - only get the IP address of the VMs, which then (with some manipulation), put the IP addresses into an Ansible inventory file, and the ansible playbook is then run against that. </p>

<p>Something like:</p>

<pre><code>          --------------
Packer -&gt; | Windows VM | &lt;----
   |      --------------     |
   |      --------------     |
   -----&gt; |  macOS VM  | &lt;----
   |      --------------     |
   |      --------------     |
   -----&gt; | Ubuntu VM  | &lt;----
          --------------     |
                             |
                          Ansible parallel provisioning
</code></pre>

<p>Is this an optimal way of using Packer and Ansible together? or is there a better way of parallelising these builds?</p>

CC BY-SA 3.0
2018-02-21T18:57:00.877Z
I'm voting to close this question as off-topic because it should describe a problem and try to fix it with a certain tool instead of starting with a tool and then solve the problem, e.g. use a saw to put a nail into the wall (X->Y vs. Y->X)
030
<continuous-integration><ansible><packer>
Parallelising Packer with Ansible
Rekovni
# Parallelising Packer with Ansible

(Asked by: username_0 on 2018-02-21)

Issue
I have an Ansible role which covers Windows, macOS and Ubuntu OS. I also have a Packer template file for each OS (due to small nuances and changes in the template file to handle provisioning) which handles standing up and provisioning the VM with Ansible onto VSphere.
So to build all three VMs, it goes something like:
  Windows build                Mac build                 Ubuntu build
---------------------     ---------------------      --------------------
| Packer -> Ansible | --> | Packer -> Ansible | ---> |Packer -> Ansible |
---------------------     ---------------------      --------------------

Which isn't very efficient and can take a while.
Solution
I'm thinking of parallelising this somehow, by potentially having Packer standup all three VMs, but not provision it - only get the IP address of the VMs, which then (with some manipulation), put the IP addresses into an Ansible inventory file, and the ansible playbook is then run against that. 
Something like:
          --------------
Packer -> | Windows VM | <----
   |      --------------     |
   |      --------------     |
   -----> |  macOS VM  | <----
   |      --------------     |
   |      --------------     |
   -----> | Ubuntu VM  | <----
          --------------     |
                             |
                          Ansible parallel provisioning

Is this an optimal way of using Packer and Ansible together? or is there a better way of parallelising these builds?

**Tags:** continuous-integration, ansible, packer

> **Comments:**
> **username_1**: I'm voting to close this question as off-topic because it should describe a problem and try to fix it with a certain tool instead of starting with a tool and then solve the problem, e.g. use a saw to put a nail into the wall (X->Y vs. Y->X)  

---

## 1 answers

### Answer by username_1 on 2018-02-21. Score: 1

What about using a CI tool? Create a parallel job and the jobs will run parallel. For example, one could use Jenkins:
https://jenkins.io/blog/2017/09/25/declarative-1/

stage('run-parallel-branches') {
  steps {
    parallel(
      a: {
        echo "This is branch a"
      },
      b: {
        echo "This is branch b"
      }
    )
  }
}


but there are other CI tools that could do the same.


---

