Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cescoferraro/156e1adb6f0f5ceadc41 to your computer and use it in GitHub Desktop.
Save cescoferraro/156e1adb6f0f5ceadc41 to your computer and use it in GitHub Desktop.
nearly empty playbook to trigger vagrant to create a valid Ansible inventory and keys
* create a folder, here we call it /tmp/ansible-vagrant
* paste this two files inside
run:
$ vagrant up && vagrant provisioning
* this will create those both files that you will need to run ansible againt the box
/tmp/ansible-vagrant.vagrant/machines/default/virtualbox/private_key
/tmp/ansible-vagrant.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
ansible-playbook --private-key=.vagrant/machines/default/virtualbox/private_key \
-u vagrant \
-i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory \
path/to/the/playbook.yml
---
- hosts: all
tasks:
- debug: msg="Please work Vagrant!"
# This guide is optimized for Vagrant 1.7 and above.
# Although versions 1.6.x should behave very similarly, it is recommended
# to upgrade instead of disabling the requirement below.
Vagrant.require_version ">= 1.7.0"
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
# Disable the new default behavior introduced in Vagrant 1.7, to
# ensure that all Vagrant machines will use the same SSH key pair.
# See https://github.com/mitchellh/vagrant/issues/5005
config.ssh.insert_key = false
config.vm.provision "ansible" do |ansible|
ansible.verbose = "v"
ansible.playbook = "playbook.yml"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment