From 1505353333fbac1666efb2f96db905382923e8ba Mon Sep 17 00:00:00 2001 From: Alexey Odinokov Date: Sat, 11 Apr 2020 03:56:05 +0000 Subject: [PATCH] Switching local gating scripts to Python3 to comply with Zuul The initial version of gating playbook contained ability to run them either on Python2 or Python3 ansible. But it causes a lot of issues e.g. a need to install[1] both versions of libs to support both possible ways to run, discrepancy between local and Zuul run[2] Zuul testing is done with ansible running on Python3 [3]. Meanwhile ppa repo for ansible contains ansible pachage that depends only from python2. There is no package for Python3 and we used only Python2-ansyble. The fact that Zuul runs it with different configuration means that we'll keep facing the issues with dependencies in future, since Gating doesn't test it. This patch changes makes local scripts run as Zuul. PS The script partially takes care of reverting intallation from its previous runs. To cleanup completely it's possible to run [4] in case these pacakges are not used by anyone else [1] https://opendev.org/airship/airshipctl/src/branch/master/roles/libvirt-install/tasks/main.yaml#L38 [2] https://review.opendev.org/#/c/717841/ https://review.opendev.org/#/c/718590/ [3] https://zuul.opendev.org/t/openstack/build/4096513604a84cd2b2f2578fc3f98660/log/zuul-info/host-info.primary.yaml#498 [4] if dpkg -l | grep "ansible.*ppa~bionic"; then sudo apt -y remove ansible sudo apt -y autoremove sudo add-apt-repository -r -y ppa:ansible/ansible sudo apt-get -y update fi + possibly sudo apt remove virtinst python-libvirt python-docker python-requests python-lxml python-libvirt Change-Id: Ia1ac3aa4128f6c4797dea1709ccb8516ae342a66 --- roles/airshipctl-publish-images/tasks/main.yaml | 4 +--- roles/libvirt-install/tasks/main.yaml | 4 ---- roles/redfish-emulator/tasks/install.yaml | 1 - roles/reverse-proxy/tasks/dependencies.yaml | 1 - tools/gate/00_setup.sh | 9 ++++----- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/roles/airshipctl-publish-images/tasks/main.yaml b/roles/airshipctl-publish-images/tasks/main.yaml index 7a0321af4..0afa7c2ff 100644 --- a/roles/airshipctl-publish-images/tasks/main.yaml +++ b/roles/airshipctl-publish-images/tasks/main.yaml @@ -10,12 +10,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Install python-docker Module +- name: Install python3-docker and python3-requests Modules apt: pkg: - - python-docker - python3-docker - - python-requests - python3-requests state: present when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/roles/libvirt-install/tasks/main.yaml b/roles/libvirt-install/tasks/main.yaml index d60be5593..05ce2b60a 100644 --- a/roles/libvirt-install/tasks/main.yaml +++ b/roles/libvirt-install/tasks/main.yaml @@ -22,7 +22,6 @@ - libvirt-devel - libvirt-daemon-kvm - qemu-kvm - - virt-install state: present - name: Ensuring Libvirt, Qemu and support packages are present become: true @@ -33,11 +32,8 @@ - libvirt-bin - libguestfs-tools - qemu-kvm - - virtinst - - python-lxml - python3-lxml - python3-libvirt - - python-libvirt - dnsmasq - ebtables state: present diff --git a/roles/redfish-emulator/tasks/install.yaml b/roles/redfish-emulator/tasks/install.yaml index f827e4217..95dd0ad89 100644 --- a/roles/redfish-emulator/tasks/install.yaml +++ b/roles/redfish-emulator/tasks/install.yaml @@ -23,7 +23,6 @@ name: - python3-pip - python3-libvirt - - python-libvirt state: present - name: Install sushy-tools diff --git a/roles/reverse-proxy/tasks/dependencies.yaml b/roles/reverse-proxy/tasks/dependencies.yaml index 6b9293811..a0ebb508c 100644 --- a/roles/reverse-proxy/tasks/dependencies.yaml +++ b/roles/reverse-proxy/tasks/dependencies.yaml @@ -11,7 +11,6 @@ name: - python3-pip - python3-libvirt - - python-libvirt state: present - name: Install required pip packages diff --git a/tools/gate/00_setup.sh b/tools/gate/00_setup.sh index 185d9befc..a7c21aa0d 100755 --- a/tools/gate/00_setup.sh +++ b/tools/gate/00_setup.sh @@ -32,10 +32,9 @@ mkdir -p "$TMP_DIR" envsubst <"${AIRSHIPCTL_WS}/tools/gate/config_template.yaml" > "$PLAYBOOK_CONFIG" # use new version of ansible, Ubuntu has old one -sudo apt install software-properties-common -sudo apt-add-repository --yes --update ppa:ansible/ansible -sudo apt-get -y update -sudo apt-get -y --no-install-recommends install docker.io ansible make python-passlib +sudo apt install software-properties-common python3-pip +sudo apt-get -y --no-install-recommends install docker.io make +sudo pip3 install ansible -echo "primary ansible_host=localhost ansible_connection=local" > "$ANSIBLE_HOSTS" +echo "primary ansible_host=localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3" > "$ANSIBLE_HOSTS" printf "[defaults]\nroles_path = %s/roles\n" "$AIRSHIPCTL_WS" > "$ANSIBLE_CFG"