I am new to Ansible and I bit confused if I can better use Vagrant to create VM instances (on EC2 and local virtual boxes) and use Ansible only for provisioning or if I can/should use Ansible to create EC2 instances and local virtual boxes.


Vagrant is a Virtual Machine Manager - I would use that for creating and managing your VM's. Ansible is intended for Configuration Management of machines - virtual or otherwise.

You could use Ansible to create VM's, then provision them, I suppose - Ansible has a shell module that you can use for anything - or use something like this. But Vagrant is a special purpose tool which does a huge amount of the VM housekeeping work for you - you would essentially end up manually recreating some of this tool in your Ansible playbooks.

I would strongly suggest using the best tool for each job. in this case that would mean using Vagrant to manage your VM's (VirtualBox, EC2, VMWare, whatever) - and then have Vagrant kick-off Ansible to configure them.

  • 1
    How is Vagrant a better tool for managing EC2 VMs than Ansible, whose AWS modules are capable of creating and managing AWS resources from a dynamic inventory? Using Ansible, any (authorised) team member can simply download the playbook onto their machine and immediately manage then-current AWS resources; but unless I've misunderstood nothing like this is possible using Vagrant (which stores VM state information locally, in a form that is not so easy to share amongst a team)? Indeed, I've posted this as a separate question: grateful for your thoughts! – eggyal Aug 4 '15 at 16:40
  • 1
    You're mostly correct I think - if you ONLY want to manage EC2 instances - although vagrant can easily use Ansible's dynamic inventory system: docs.vagrantup.com/v2/provisioning/ansible.html The real advantage of Vagrant is being able to use the same/similar Vagrantfiles for multiple environments - with the same ansible scripts. So Virtualbox VM's for dev and EC2 for stage/prod with the same Ansible provisioning scripts and either the same vagrantfile, or two very similar ones. – Duncan Lock Aug 4 '15 at 17:00
  • I've posted an answer to your question, maybe continue discussion there? serverfault.com/questions/710709/… – Duncan Lock Aug 4 '15 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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