From 876c6043ee829cc0bc16b65137785b8db31daed9 Mon Sep 17 00:00:00 2001 From: Ruslan Aliev Date: Fri, 26 Jun 2020 03:54:52 -0500 Subject: [PATCH] Replace apt/yum ansible modules, use package instead apt/yum use is not convenient, package module automatically uses the underlying OS package manager. Also, some ansible roles currently use only apt module without yum, therefore patch fixes this bug too. Change-Id: I5dd49d513d1a791ab51ca6ce6eb1c079542c5624 Signed-off-by: Ruslan Aliev --- ...rship-airshipctl-update-github-issues.yaml | 2 +- .../airshipctl-publish-images/tasks/main.yaml | 5 +-- roles/apache-server/tasks/htpasswd.yaml | 2 +- roles/apache-server/tasks/install.yaml | 21 ++++------ roles/apache-server/tasks/ssl.yaml | 2 +- .../tasks/backend.yaml | 17 +++++--- roles/docker-install/tasks/main.yaml | 13 +----- roles/libvirt-install/tasks/main.yaml | 41 +++++++++---------- roles/libvirt-network/tests/main.yaml | 2 +- 9 files changed, 46 insertions(+), 59 deletions(-) diff --git a/playbooks/airship-airshipctl-update-github-issues.yaml b/playbooks/airship-airshipctl-update-github-issues.yaml index 817ac4cde..dbadfc94e 100644 --- a/playbooks/airship-airshipctl-update-github-issues.yaml +++ b/playbooks/airship-airshipctl-update-github-issues.yaml @@ -13,7 +13,7 @@ - hosts: primary tasks: - name: Install python setuptools - apt: + package: name: - python3-pip - python3-setuptools diff --git a/roles/airshipctl-publish-images/tasks/main.yaml b/roles/airshipctl-publish-images/tasks/main.yaml index 75e5b60bc..7bd6565ce 100644 --- a/roles/airshipctl-publish-images/tasks/main.yaml +++ b/roles/airshipctl-publish-images/tasks/main.yaml @@ -11,12 +11,11 @@ # limitations under the License. - name: Install python3-docker and python3-requests Modules - apt: - pkg: + package: + name: - python3-docker - python3-requests state: present - when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - name: List Docker Images shell: docker image ls diff --git a/roles/apache-server/tasks/htpasswd.yaml b/roles/apache-server/tasks/htpasswd.yaml index e9869ccd3..c28414abd 100644 --- a/roles/apache-server/tasks/htpasswd.yaml +++ b/roles/apache-server/tasks/htpasswd.yaml @@ -15,7 +15,7 @@ become: yes block: - name: Ensure needed packages - apt: + package: name: - python3-passlib state: present diff --git a/roles/apache-server/tasks/install.yaml b/roles/apache-server/tasks/install.yaml index 18503fac4..747062065 100644 --- a/roles/apache-server/tasks/install.yaml +++ b/roles/apache-server/tasks/install.yaml @@ -11,21 +11,16 @@ # limitations under the License. --- -- name: redhat | ensuring apache packages are present +- name: ensure apache packages are present become: yes - when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' - yum: - name: - - httpd - update_cache: yes - state: present - -- name: ubuntu | ensuring apache packages are present - become: yes - when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - apt: - name: + vars: + - packages: + Debian: - apache2 + RedHat: + - httpd + package: + name: "{{ packages[ansible_os_family] }}" update_cache: yes state: present diff --git a/roles/apache-server/tasks/ssl.yaml b/roles/apache-server/tasks/ssl.yaml index e815dadf6..12dd5edc5 100644 --- a/roles/apache-server/tasks/ssl.yaml +++ b/roles/apache-server/tasks/ssl.yaml @@ -14,7 +14,7 @@ become: yes block: - name: Ensure needed packages - apt: + package: name: - python3-passlib - python3-openssl diff --git a/roles/apache-wsgi-sushy-emulator/tasks/backend.yaml b/roles/apache-wsgi-sushy-emulator/tasks/backend.yaml index 8ed7eb024..4a51a6069 100644 --- a/roles/apache-wsgi-sushy-emulator/tasks/backend.yaml +++ b/roles/apache-wsgi-sushy-emulator/tasks/backend.yaml @@ -24,11 +24,18 @@ name: apache-server - name: Install needed packages - apt: - name: - - python3-pip - - python3-setuptools - - libapache2-mod-wsgi-py3 + vars: + - packages: + Debian: + - python3-pip + - python3-setuptools + - libapache2-mod-wsgi-py3 + RedHat: + - python3-pip + - python3-setuptools + - python3-mod_wsgi + package: + name: "{{ packages[ansible_os_family] }}" state: present - name: Install sushy-tools diff --git a/roles/docker-install/tasks/main.yaml b/roles/docker-install/tasks/main.yaml index 428d3338f..00963b9df 100644 --- a/roles/docker-install/tasks/main.yaml +++ b/roles/docker-install/tasks/main.yaml @@ -13,18 +13,7 @@ --- - name: Ensuring docker and support packages are present become: yes - when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' - yum: - name: - - docker.io - - runc - update_cache: yes - state: present - -- name: Ensuring docker and support packages are present - become: yes - when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - apt: + package: name: - docker.io - runc diff --git a/roles/libvirt-install/tasks/main.yaml b/roles/libvirt-install/tasks/main.yaml index 082dc777a..9d050d8dd 100644 --- a/roles/libvirt-install/tasks/main.yaml +++ b/roles/libvirt-install/tasks/main.yaml @@ -14,28 +14,25 @@ - block: - name: Ensuring Libvirt, Qemu and support packages are present become: yes - when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' - yum: - name: - - libguestfs-tools - - libvirt - - libvirt-devel - - libvirt-daemon-kvm - - qemu-kvm - state: present - - name: Ensuring Libvirt, Qemu and support packages are present - become: yes - when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - apt: - name: - - qemu - - libvirt-bin - - libguestfs-tools - - qemu-kvm - - python3-lxml - - python3-libvirt - - dnsmasq - - ebtables + vars: + - packages: + Debian: + - qemu + - libvirt-bin + - libguestfs-tools + - qemu-kvm + - python3-lxml + - python3-libvirt + - dnsmasq + - ebtables + RedHat: + - libguestfs-tools + - libvirt + - libvirt-devel + - libvirt-daemon-kvm + - qemu-kvm + package: + name: "{{ packages[ansible_os_family] }}" state: present - name: Add user "{{ ansible_user }}" to libvirt group become: yes diff --git a/roles/libvirt-network/tests/main.yaml b/roles/libvirt-network/tests/main.yaml index 6c463b08b..efdd01f04 100644 --- a/roles/libvirt-network/tests/main.yaml +++ b/roles/libvirt-network/tests/main.yaml @@ -25,7 +25,7 @@ vars: network_action: "{{ libvirt_network.network_action }}" - name: install required packages - apt: + package: name: - bridge-utils state: present