don't loop over a task using package management modules

For tasks using (Ansible) modules for package management utilities,
pass the list of packages to be installed instead of repeating the task
for each package. Using the latter manner of installing a list of
packages leads to a deprecation warning by ansible-playbook command.

Fixes: https://github.com/ceph/ceph-ansible/issues/3293
Signed-off-by: Rishabh Dave <ridave@redhat.com>
pull/3311/head
Rishabh Dave 2018-10-31 12:07:25 -04:00 committed by mergify[bot]
parent 640cad3fd8
commit da6f384223
2 changed files with 12 additions and 35 deletions

View File

@ -550,49 +550,43 @@
- name: purge ceph packages with yum - name: purge ceph packages with yum
yum: yum:
name: "{{ item }}" name: "{{ ceph_packages }}"
state: absent state: absent
with_items: "{{ ceph_packages }}"
when: ansible_pkg_mgr == 'yum' when: ansible_pkg_mgr == 'yum'
- name: purge ceph packages with dnf - name: purge ceph packages with dnf
dnf: dnf:
name: "{{ item }}" name: "{{ ceph_packages }}"
state: absent state: absent
with_items: "{{ ceph_packages }}"
when: ansible_pkg_mgr == 'dnf' when: ansible_pkg_mgr == 'dnf'
- name: purge ceph packages with apt - name: purge ceph packages with apt
apt: apt:
name: "{{ item }}" name: "{{ ceph_packages }}"
state: absent state: absent
purge: true purge: true
with_items: "{{ ceph_packages }}"
when: ansible_pkg_mgr == 'apt' when: ansible_pkg_mgr == 'apt'
- name: purge remaining ceph packages with yum - name: purge remaining ceph packages with yum
yum: yum:
name: "{{ item }}" name: "{{ ceph_remaining_packages }}"
state: absent state: absent
with_items: "{{ ceph_remaining_packages }}"
when: when:
- ansible_pkg_mgr == 'yum' - ansible_pkg_mgr == 'yum'
- purge_all_packages == true - purge_all_packages == true
- name: purge remaining ceph packages with dnf - name: purge remaining ceph packages with dnf
dnf: dnf:
name: "{{ item }}" name: "{{ ceph_remaining_packages }}"
state: absent state: absent
with_items: "{{ ceph_remaining_packages }}"
when: when:
- ansible_pkg_mgr == 'dnf' - ansible_pkg_mgr == 'dnf'
- purge_all_packages == true - purge_all_packages == true
- name: purge remaining ceph packages with apt - name: purge remaining ceph packages with apt
apt: apt:
name: "{{ item }}" name: "{{ ceph_remaining_packages }}"
state: absent state: absent
with_items: "{{ ceph_remaining_packages }}"
when: when:
- ansible_pkg_mgr == 'apt' - ansible_pkg_mgr == 'apt'
- purge_all_packages == true - purge_all_packages == true

View File

@ -507,25 +507,18 @@
- name: remove pip and docker on debian - name: remove pip and docker on debian
apt: apt:
name: "{{ item }}" name: [python-pip, docker-engine]
state: absent state: absent
update_cache: yes update_cache: yes
autoremove: yes autoremove: yes
with_items:
- python-pip
- docker-engine
when: ansible_distribution == 'Debian' when: ansible_distribution == 'Debian'
- name: remove pip and docker on ubuntu - name: remove pip and docker on ubuntu
apt: apt:
name: "{{ item }}" name: [python-pip, docker, docker.io]
state: absent state: absent
update_cache: yes update_cache: yes
autoremove: yes autoremove: yes
with_items:
- python-pip
- docker
- docker.io
when: ansible_distribution == 'Ubuntu' when: ansible_distribution == 'Ubuntu'
- name: red hat based systems tasks - name: red hat based systems tasks
@ -539,25 +532,19 @@
block: block:
- name: remove pip on redhat - name: remove pip on redhat
yum: yum:
name: "{{ item }}" name: python-pip
state: absent state: absent
with_items:
- python-pip
- name: remove docker-engine on redhat - name: remove docker-engine on redhat
yum: yum:
name: "{{ item }}" name: docker-engine
state: absent state: absent
with_items:
- docker-engine
# for CentOS # for CentOS
- name: remove docker on redhat - name: remove docker on redhat
yum: yum:
name: "{{ item }}" name: docker
state: absent state: absent
with_items:
- docker
- name: remove package dependencies on redhat - name: remove package dependencies on redhat
command: yum -y autoremove command: yum -y autoremove
@ -575,12 +562,8 @@
block: block:
- name: remove pip and docker on redhat - name: remove pip and docker on redhat
dnf: dnf:
name: "{{ item }}" name: [python-pip, docker-engine, docker]
state: absent state: absent
with_items:
- python-pip
- docker-engine
- docker
- name: remove package dependencies on redhat - name: remove package dependencies on redhat
command: dnf -y autoremove command: dnf -y autoremove