From 06772e407104d9b6e9dc39716fa42eda84e78bad Mon Sep 17 00:00:00 2001 From: David Galloway Date: Thu, 5 Mar 2020 11:31:56 -0500 Subject: [PATCH] ansible: Install python3 deps on Bionic and up Again, I don't know how this was working before but I also had to set `executable:` under the pip tasks in order for them to work on all distros. Signed-off-by: David Galloway --- ansible/examples/slave.yml | 26 ++++++++++++++++++++--- ansible/examples/slave_static.yml | 35 ++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/ansible/examples/slave.yml b/ansible/examples/slave.yml index 062a6ac9..64a4fbc1 100644 --- a/ansible/examples/slave.yml +++ b/ansible/examples/slave.yml @@ -313,12 +313,15 @@ - ant when: ansible_pkg_mgr == "apt" - # For now schroot/dchroot are the only package differences. This may change. - # Just change this to be a list if that happens. - name: Install DEB requirements (>=18.04) apt: - name: schroot + name: "{{ item }}" state: present + with_items: + - schroot + - python3-dev + - python3-pip + - python3-virtualenv when: - ansible_pkg_mgr == "apt" - ansible_distribution_major_version|int >= 18 @@ -445,11 +448,21 @@ failed_when: false when: ansible_os_family == "Suse" + - set_fact: + pip_version: pip + when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 7) or + ansible_os_family == "Debian" or + ansible_os_family == "Suse" + + - set_fact: + pip_version: pip3 + when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 8 - name: install six, latest one pip: name: six state: latest + executable: "{{ pip_version }}" when: ansible_os_family != "Suse" - name: install python-jenkins @@ -457,6 +470,7 @@ pip: name: python-jenkins version: 0.4.15 + executable: "{{ pip_version }}" - name: add github.com host key known_hosts: @@ -467,6 +481,12 @@ key: "{{ lookup('file', 'playbook/files/ssh/hostkeys/github.com.pub') }}" tags: github + # The jenkins_node library tries to use pip3 with python-jenkins but it's not compatible. + - set_fact: + ansible_python_interpreter: /usr/bin/python + when: + - ansible_os_family == "Debian" + - name: register the new slave to jenkins master with ssh jenkins_node: username: "{{ api_user }}" diff --git a/ansible/examples/slave_static.yml b/ansible/examples/slave_static.yml index 36d286a9..dec9404e 100644 --- a/ansible/examples/slave_static.yml +++ b/ansible/examples/slave_static.yml @@ -218,12 +218,15 @@ - curl when: ansible_pkg_mgr == "apt" - # For now schroot/dchroot are the only package differences. This may change. - # Just change this to be a list if that happens. - name: Install DEB requirements (>=18.04) apt: - name: schroot + name: "{{ item }}" state: present + with_items: + - schroot + - python3-dev + - python3-pip + - python3-virtualenv when: - ansible_pkg_mgr == "apt" - ansible_distribution_major_version|int >= 18 @@ -321,14 +324,30 @@ regexp: '^(127\.0\.1\.1(?!.*\b{{ ansible_hostname }}\b).*)$' line: '127.0.1.1 {{ ansible_hostname }}' + - set_fact: + pip_version: pip + when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 7) or + ansible_os_family == "Debian" or + ansible_os_family == "Suse" + + - set_fact: + pip_version: pip3 + when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 8 + - name: install six, latest one become: true - pip: name=six state=latest + pip: + name: six + state: latest + executable: "{{ pip_version }}" - name: install python-jenkins become: true # https://review.openstack.org/460363 - pip: name=python-jenkins version=0.4.15 + pip: + name: python-jenkins + version: 0.4.15 + executable: "{{ pip_version }}" - name: add github.com host key become: true @@ -339,6 +358,12 @@ # github.com.pub is the output of `ssh-keyscan github.com` key: "{{ lookup('file', 'files/ssh/hostkeys/github.com.pub') }}" + # The jenkins_node library tries to use pip3 with python-jenkins but it's not compatible. + - set_fact: + ansible_python_interpreter: /usr/bin/python + when: + - ansible_os_family == "Debian" + - name: register the new slave to jenkins master with ssh jenkins_node: username: "{{ api_user }}" -- 2.39.5