Ansible playbook errors solved!

If you use our venerated :slight_smile: Ansible playbook to deploy Plone and run into this error:

fatal: [xenial]: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n", "msg": "MODULE FAILURE", "rc": 0}

It is because Python 2.7 is not installed. See https://github.com/plone/ansible-playbook/issues/82

To test,

which python2.7

and if that comes back with nothing,

sudo apt-get install -y python 

An earlier error I ran into was

fatal: [xenial]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to remote host \"127.0.0.1\". Make sure this host can be reached over ssh", "unreachable": true}

and that seemed to be caused by the fact that I had an earlier vagrant that had a different SSH fingerprint. I deleted the old fingerprint from my .ssh/known_hosts file. Even so that did not quite work, so I modified the vbox_host.cfg so it would specify the SSH password instead of using SSH keys.

#BEFORE
#xenial ansible_ssh_port=2222 ansible_ssh_host=127.0.0.1 ansible_ssh_user=ubuntu ansible_ssh_private_key_file=/Users/kim/src/aiteam.playbooks/.vagrant/machines/xenial/virtualbox/private_key ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
#AFTER
xenial ansible_ssh_port=2222 ansible_ssh_host=127.0.0.1 ansible_ssh_user=ubuntu ansible_ssh_pass=password ansible_ssh_extra_args='-o StrictHostKeyChecking=no'

http://docs.ansible.com/ansible/latest/intro_installation.html#managed-node-requirements

Thanks - are you referring specifically to the command

ansible myhost --sudo -m raw -a "yum install -y python2 python-simplejson"

I did try ANSIBLE_SCP_IF_SSH=y and setting scp_if_ssh = True in ansible.cfg

I was thinking to something like (oh can't this darn forum software provide a preview I don't even know how to avoid this hateful html formatting...)
WELL... browsing the discourse meta forum finally made me to understand that all that is needed is to insert 4 spaces before each line to avoid this marvelous formatting. I love discourse, absolutely. This is the period for love of course. Don't ask me tomorrow.

--- playbook.yml.ori	2017-12-25 19:33:46.350428287 +0100
+++ playbook.yml	2017-12-25 20:57:02.412595449 +0100
@@ -3,10 +3,15 @@
 - hosts: all
   become: yes
   become_method: sudo
-  gather_facts: yes
-
+  gather_facts: False

   pre_tasks:
+    - name: Install python 2 if needed with debian
+      raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
+      register: output
+      changed_when: False
+
+    - setup: # aka gather_facts
 
     - name: Fail if Ansible is ancient
       fail: msg="We need Ansible >= 2.0. Please update your kit. 'pip install -U Ansible'"
1 Like