Skip to content

Create Vagrant machines with Ansible to run Ansible against as typical remote instances

License

Notifications You must be signed in to change notification settings

davidegreenwald/vagrant-ansible-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Ansible Vagrant Set-Up

What this does

Uses Ansible to create configured Vagrant folders/files with local-only SSH keys for Ansible to then provision for local development, as if they were standard remote machines.

See an example

Check out the example-output branch to see a finished playbook build.

Prerequisites

Ansible 2.8+

Vagrant

Instructions

  • Update Vagrant configurations with your variables in your_project/ansible/roles/vagrant-setup/defaults/main.yml

  • update the vagrant-setup role tasks in your_project/ansible/roles/tasks/main.yml with the new variable items

  • cd into the ansible directory

  • run ansible-playbook setup-playbook.yml

This will create the Vagrant folder(s), keys, and add the new inventory to Ansible.

Go back to the parent directory and into a Vagrant folder. Start Vagrant:

cd ../vagrant
vagrant up

vagrant up will run a short shell script to add the SSH key to the vagrant user.

You can now run Ansible against the Vagrant boxes. Add any roles or tasks to vagrant-playbook.yml.

You can also SSH directly into the running Vagrant box as a typical remote server with the created private key in the Ansible folder as vagrant@<ip> instead of running vagrant ssh.

Example:

ssh -i ansible/vagrant_ssh/vagrant_rsa [email protected]

Warning

Don't save SSH keys in version control ever. Generate these keys strictly for local ease of use.

About

Create Vagrant machines with Ansible to run Ansible against as typical remote instances

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages