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.


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?

  • 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 Feb 21 '18 at 18:57

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


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

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.