At first I want to say that I'm not an experienced user of ansible, but I'm sure that there are many people like me therefore I will try to describe it in a way that even I would understand it ;)
Situation
I have Fedora 23 on the host machine with installed Vagrant, ansible, python3, python2 etc. I have Vagrantfile with fedora/23-cloud-base as config.vm.box and provision by ansible.
When I started vagrant provision comand I got this error:
$ vagrant provision
==> default: Running provisioner: ansible... default: Running ansible-playbook... PLAY [vagrant] **************************************************************** GATHERING FACTS *************************************************************** failed: [192.168.25.25] => {"failed": true, "parsed": false} BECOME-SUCCESS-afwahqttsdeueajwfcuqsvaulkoxjixf /bin/sh: /usr/bin/python: No such file or directory OpenSSH_7.1p1, OpenSSL 1.0.2e-fips 3 Dec 2015 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 56: Applying options for * debug1: auto-mux: Trying existing master debug1: mux_client_request_session: master session id: 2 Shared connection to 192.168.25.25 closed. TASK: [apache | Install Apache] *********************************************** FATAL: no hosts matched or all hosts have already failed -- aborting
PLAY RECAP ******************************************************************** to retry, use: --limit @/home/tomor/playbook.retry 192.168.25.25 : ok=0 changed=0 unreachable=0 failed=1
Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.
When I enabled debugging by ansible.verbose="vvv" I saw more output but it didn't help me.
Reason of the fail
The problem is in the fact that
- ansible needs python 2.x on the remote system and Fedora23 has only python3 installed by default
- python3 does not create /usr/bin/python - because it's not compatible with python2
failed: [192.168.25.25] => {"failed": true, "parsed": false} BECOME-SUCCESS-afwahqttsdeueajwfcuqsvaulkoxjixf /bin/sh: /usr/bin/python: No such file or directory
Python is needed for gathering of the facts (setup module).
Solution
To solve this situation you just have to install python 2 on the remote machine.
As I wanted to do the whole installation of the Vagrant box by ansible I solved it by:
- disable Gathering Facts
- add installation of python2
- start gathering facts manually (by setup module)
It means adapting basic playbook like this:
--- - hosts: vagrant sudo: true gather_facts: false # Fedora23 doesn't have python2 installed by default roles: - ansible_prepare # install python2, gather facts manually after python is prepared - my_another_role
And creation of ansible_prepare role task:
- name: Install python2 on the remote machine raw: dnf install -y python2 python2-dnf libselinux-python - name: Gather facts setup:
Yes, there is just setup: which does gathering of the facts ;)
See the setup module docs for more details.
That's it.
No comments:
Post a Comment