--- ################################################################################ # Install Ansible's dependencies: python and lsb_release, required respectively # to run Ansible modules and gather Ansible facts. # # See also: # - http://docs.ansible.com/ansible/intro_installation.html#managed-node-requirements # - http://docs.ansible.com/ansible/setup_module.html ################################################################################ - name: check if python is installed (as required by ansible modules) raw: test -e /usr/bin/python register: is_python_installed failed_when: is_python_installed.rc not in [0, 1] changed_when: false # never mutates state. - name: install python if missing (as required by ansible modules) when: is_python_installed|failed # skip otherwise raw: (test -e /usr/bin/apt-get && apt-get update && apt-get install -y python-minimal) || (test -e /usr/bin/yum && yum update && yum install -y python) changed_when: is_python_installed.rc == 1 - name: check if lsb_release is installed (as required for ansible facts) raw: test -e /usr/bin/lsb_release register: is_lsb_release_installed failed_when: is_lsb_release_installed.rc not in [0, 1] changed_when: false # never mutates state. - name: install lsb_release if missing (as required for ansible facts) when: is_lsb_release_installed|failed # skip otherwise raw: (test -e /usr/bin/apt-get && apt-get install -y lsb_release) || (test -e /usr/bin/yum && yum install -y redhat-lsb-core) changed_when: is_lsb_release_installed.rc == 1 - setup: # gather 'facts', i.e. compensates for 'gather_facts: false' in calling playbook.