Fix python prereq install task

It's not possible to check ansible_pkg_mgr yet because we haven't
gathered facts. This patch adjusts the task to run on all distros
but it only has an effect on Ubuntu systems without python installed.

Change-Id: I8859b740a4d190fb1548af7ed7df92c248e2c5a3
This commit is contained in:
Major Hayden 2017-08-11 09:48:44 -05:00
parent 55e084b145
commit 56a388eb38
No known key found for this signature in database
GPG Key ID: 737051E0C1011FB1

View File

@ -13,6 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# NOTE(mhayden): CentOS always has python (because of yum), but it's possible
# that Ubuntu nodes may not have python by default. Ansible doesn't work very
# well if Python isn't installed.
#
# Also, we can't use a 'when' to check for the ansible_pkg_mgr here because
# we haven't gathered facts yet.
- name: Install Ansible prerequisites
hosts: "{{ openstack_host_group|default('hosts') }}"
gather_facts: false
@ -20,9 +26,13 @@
pre_tasks:
- name: Ensure python is installed
register: result
raw: apt-get -y install python
when:
- ansible_pkg_mgr == 'apt'
raw: |
if which apt-get >/dev/null && ! which python >/dev/null ; then
apt-get -y install python
exit 2
else
exit 0
fi
changed_when: "result.rc == 2"
failed_when: "{{ result.rc not in [0, 2] }}"