-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ansible_local provisioner can't detect ansible 2.0 install due to changed exit codes #6793
Comments
Addresses issue: hashicorp#6793 Now ansible_local provisioner can detect ansible 2.0 install. Changed to the conditional check to look for the commands rather than execute them.
@nigelgbanks Thanks for reporting this integration issue (which is still present in Ansible 2.0.0.rc3) This problem is actually caused by a bug in Ansible 2.0 (beta): ansible/ansible#12004. Most probably this issue won't be resolved for the Ansible 2.0.0, so we might have to adopt a safer (more resilient) way to sanity-check the Ansible installation... |
Less "critical" issue, because ansible/ansible#12020 has been merged right now :) @nigelgbanks please give a try with latest state of |
Will do! On Wednesday, January 6, 2016, Gilles Cornu [email protected]
Nigel Banks |
ansible/ansible#12020 has been reverted due to annoying side effect: ansible/ansible#13743 Problem not solved yet. @NigelBanks hold on with tests ;) |
Since Ansible 2.0.x has landed with this behavior (code 5 returned), vagrant should be adapted. The fix proposed by @mintwax ( |
Sorry, I just opened and self-closed the third clone for this issue. I came here just to say "me too!", and to point out that this issue is the same for both |
@fquffio no worries :) |
Another 'me too', but the |
Another 'me too'. I've been scratching my head all day around an unchanged Vagrantfile and playbook which suddenly stopped working. Glad you folks found the issue! |
So this is hacky and inelegant, and I'll be improving it, but for now it got me out of a tight spot: In my config.vm.provision "shell", inline: "sudo apt-get install -y python-pip python-dev && sudo pip install ansible==1.9.2 && sudo cp /usr/local/bin/ansible /usr/bin/ansible" Hope it's of use to someone. Cheers! |
Thanks for all the comments above! @geerlingguy you're right, this only affects I picked the #6869 fix into my #6800 "ansible bug fixes" general PR (I'll do some more stuff in this branch for 1.8.2). |
@geerlingguy Sorry I don't have any information about the release due date. I can only recommend you to take contact with Hashicorp support. I know that many Ansible/Vagrant users are now awaiting for Vagrant 1.8.2, but I just like to stress that this situation is originally caused by an unexpected breaking change in Ansible 2.0.0.0. Fixing ansible/ansible#12004 should also receive enough attention in my opinion. |
Milestone |
Note that the `ansible==1.9.4` here is due to work around hashicorp/vagrant#6793 for now. That will likely be un-necessary after vagrant 1.8.2 is released.
I can confirm that the issue exists for vagrant version 1.8.1 running on an OSX host machine. I wish you luck in fixing this issue soon. I tried to use @MasonM's workaround and it generated the following output, and does not work :(
I made sure to add the snippet before any other provisoners, as mentioned. |
Can you please summarize: for which combinations of vagrant/ansible versions this is reproducible and what is the official workaround for this? I will try downgranding ansible via ansible.version =, but not sure whether this will succeed. |
Ok. I read the thread a bit more carefully.
put before ansible provision |
For
So, I just commented the whole block instead.
UPDATE: Recreated the VM & this time there was no "unexpected indent" error. |
@ilyapoz Thanks! This helped us. We streamlined it a little more with simple bash in case it helps anyone else:
|
That doesn't work for me for whatever reason, I had to use this syntax for heredoc:
|
@likwid Thanks this worked for me. I'm on OSX El Capitan. |
@janzenz (and for those wondering, such as I was): The difference between the "simple bash" scripts provided by @skalfyfan and the updated one from @likwid + the reason why only the one from @likwid would work for you is that @skalfyfan used the Ruby Heredoc syntax that MUST be ended at the beginning of a newline ( The most likely scenario that I can imagine here would be that this would present itself if these are nested (i.e. indented) at all in your Vagrantfile, so if you're closing the non-hyphen FWIW, I immediately put the content of that Heredoc into a standalone Bash script and provided it as a file to the Shell provisioner rather than doing it |
This is a note for people who come here through a web search. I want to use Ubuntu 16.04 as both host and guest with the official-repository-provided Vagrant v1.8.1 and Ansible v2.0.0.2, which means I get the problem described in this issue if I use the Ansible Local provisioner. The following snippet using the Shell provisioner approximates the Ansible Local provisioner: $inline_script = <<-INLINE_SCRIPT
sudo apt-get install -y ansible
cd /vagrant
ANSIBLE_FORCE_COLOR=true ansible-playbook --inventory="localhost," playbook.yml
INLINE_SCRIPT
config.vm.provision "shell", inline: $inline_script, privileged: false, keep_color: true You can find something like this used in one of my projects here. |
Your snippet wasn't working for me @jeremyn, because the guest couldn't ssh to itself. I modified it to work without ssh, with $inline_script = <<-INLINE_SCRIPT
sudo apt-get install -y ansible
cd /vagrant
ANSIBLE_FORCE_COLOR=true ansible-playbook -i="localhost," -c local playbook.yml
INLINE_SCRIPT
config.vm.provision "shell", inline: $inline_script, privileged: false, keep_color: true |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
ansible_local provisioner can't detect ansible 2.0 install due to changed exit codes.
Code Responsible:
https://github.com/mitchellh/vagrant/blob/25ff027b08582978981ed28754a3fed21953a90e/plugins/provisioners/ansible/provisioner/guest.rb#L35-L65
Example Ansible 1.9.4
Example Ansible 2.0.0
The text was updated successfully, but these errors were encountered: