Created
March 20, 2014 04:14
-
-
Save phantomwhale/9657134 to your computer and use it in GitHub Desktop.
Passing command line arguments into Vagrant to configure Ansible Provisioning
This file contains 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
# with a space, this doesn't work... | |
$ ANSIBLE_ARGS='-t elasticsearch' vagrant provision | |
==> default: Running provisioner: ansible... | |
ERROR: tag(s) not found in playbook: elasticsearch. possible values: apache,common,elasticsearch,java,passenger,postgresql,ruby | |
Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again. | |
# without the space, it now works... | |
$ ANSIBLE_ARGS='-telasticsearch' vagrant provision | |
==> default: Running provisioner: ansible... | |
PLAY [web] ******************************************************************** | |
... |
This file contains 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
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "precise64" | |
config.vm.box_url = "http://files.vagrantup.com/precise64.box" | |
config.vm.provision "ansible" do |ansible| | |
ansible.playbook = "config/ansible/site.yml" | |
ansible.extra_vars = { | |
"ansible_ssh_user" => "vagrant", | |
} | |
ansible.raw_arguments = ENV['ANSIBLE_ARGS'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have to provision a VM on Windows using
ansible_local
. Pity me. And, I am PS impaired also so for those of my lot, this might help:The same entry in the Vagrant file shared by @geerlingguy applies. The application of the
ANSIBLE_ARGS
on a Windows PS (compared to the Linux line shared) is that ANSIBLE_ARGS is permanent for the terminal session.To get that same behavior to not have an env var linger, you would have to unset it after the
vagrant
command: