Inspired mostly from this post by Lars Kellogg-Stedman.
Fedora 23 is using python 3 as the default python version that gets installed (see changes), but Ansible still requires python 2. For that reason Ansible errors out when you try to run it because it assumes python 2 by default:
GATHERING FACTS *
failed: [f23] => {"failed": true, "parsed": false}
/bin/sh: /usr/bin/python: No such file or directory
Fortunately there are a few steps you can add to your playbooks in order to fully workaround this problem. You can either choose to apply then in a single play or in mulitple plays as shown below.
In the case of a single play, which is something I use often when applying configuration to vagrant boxes you can workaround this problem by taking the following steps:
The gathering of facts that happens by default on ansible execution will try to use python 2. We must disable this or it will fail before executing the raw ssh commands to install python 2. Fortunately we can still use facts in our single play, though, by explicitly calling the setup module after python2 is installed.
So with these minor changes applied a simple all in one play might look like:
- hosts: f23
remote_user: fedora
gather_facts: false
become_user: root
become: yes
tasks:
- name: install python and deps for ansible modules
raw: dnf install -y python2 python2-dnf libselinux-python
- name: gather facts
setup:
- name: use facts
lineinfile: dest=/etc/some-cfg-file line="myip={{ ansible_eth0.ipv4.address }}" create=true
And the output of running the play should be successful:
PLAY [f23] ****************************************************************
TASK: [install python and deps for ansible modules] ***************************
ok: [f23]
TASK: [gather facts] **********************************************************
ok: [f23]
TASK: [use facts] *************************************************************
changed: [f23]
PLAY RECAP ********************************************************************
f23 : ok=3 changed=1 unreachable=0 failed=0
If you use multiple plays in your playbooks then you can simply have one of them do the python 2 install in raw mode while the others can remain unchanged; you don't have to explicitly gather facts because python 2 is now installed. So for the first play you would have something like:
- hosts: f23
remote_user: fedora
gather_facts: false
become_user: root
become: yes
tasks:
- name: install python and deps for ansible modules
raw: dnf install -y python2 python2-dnf libselinux-python
And, re-using the code from the sample above the second play would look like:
- hosts: f23
remote_user: fedora
become_user: root
become: yes
tasks:
- name: use facts
lineinfile: dest=/etc/some-cfg-file line="myip={{ ansible_eth0.ipv4.address }}" create=true
So using these small changes you should be back up and running until Ansible adds first class support for python 3.
Enjoy!
Dusty