4

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.

JE42
  • 221
  • 1
  • 2
  • 5

1 Answers1

4

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.

Duncan Lock
  • 1,812
  • 1
  • 17
  • 18
  • 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](http://serverfault.com/q/710709): grateful for your thoughts! – eggyal Aug 04 '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: http://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 04 '15 at 17:00
  • I've posted an answer to your question, maybe continue discussion there? http://serverfault.com/questions/710709/what-benefit-is-there-to-using-vagrant-for-aws-resource-management-when-using-an/710830#710830 – Duncan Lock Aug 04 '15 at 17:09