Last active
August 29, 2015 13:59
-
-
Save rdhyee/10935909 to your computer and use it in GitHub Desktop.
a template Vagrantfile that adds ansible provisioning, along with accompanying ansible playbook. To run the ansible playbook: ansible-playbook -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory --private-key=~/.vagrant.d/insecure_private_key -u vagrant hello.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ansible-playbook -vvvv -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory --private-key=.vagrant/machines/hello_django/virtualbox/private_key -u vagrant $1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Hello Ansible | |
hosts: box001 | |
sudo: no | |
tasks: | |
- name: Hello server | |
shell: date > now.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "ubuntu/trusty64" | |
# you can replace box001 with another name | |
config.vm.define 'box001' do |node| | |
node.vm.provision 'ansible' do |ansible| | |
# http://bertvv.github.io/vagrant-presentation/#/vagrant-configuration | |
# "define directive is important to make automatic inventory work" | |
# I wish I could comment out the following line to allow for | |
# .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory | |
# to be calculated w/o running any ansible playbook -- but no luck | |
ansible.playbook = 'hello.yml' | |
end | |
end | |
# config.vm.network "forwarded_port", guest: 80, host: 8080 | |
# config.vm.network "private_network", ip: "192.168.33.10" | |
# config.vm.synced_folder "data", "vagrant_data" | |
# virtualbox | |
# config.vm.provider "virtualbox" do |vb| | |
# # Don't boot with headless mode | |
# vb.gui = true | |
# | |
# # Use VBoxManage to customize the VM. For example to change memory: | |
# vb.customize ["modifyvm", :id, "--memory", "1024"] | |
# end | |
# | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run the ansible playbook: