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.

2

1 Answer 1

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.

3
  • 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, 2015 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. Aug 4, 2015 at 17:00
  • I've posted an answer to your question, maybe continue discussion there? serverfault.com/questions/710709/… Aug 4, 2015 at 17:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .