Using Ansible to deploy a Ubuntu XENIAL machine you will have the problem that Ubuntu has no Python 2.7 installed by default. Ansible is not running with Python 3 and need 2.7.
Using Vagrant this can be very annoying to install Pyython 2.7 manually all the time.
The idea to handle this problem is to use the Ansible raw-Module to install Python 2.7.
--- - hosts: all gather_facts: no become: Yes tasks: - name: Check for Python 2.7 raw: which python2.7 > /dev/null ; echo -n $? register: py27_exist - name: Install Python 2.7 raw: apt-get install python2.7 --yes when: py27_exist.stdout == "1" - name: Check for default python raw: which python > /dev/null ; echo -n $? register: py_exist - name: Set Python 2.7 as default raw: update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10
The Ansible playbook above checks that python 2.7 is installed or need to install. If need to install, ansible will use the raw command. The last two points, ansible checks that python command exists. If not, set python 2.7 as default python runtime.
Now you can include the bootstrap.yml to your ubuntu playbook:
--- - include: bootstrap.yml - hosts: all become: yes tasks: - name: ... ...