Use 'package' module instead of yum, apt and dnf

Refactor the code using 'package' module

Fix Issue #520

(However it doesn't cover all cases because some cases are not refactorable.
Ex: because of diverging packages name between distribution)
pull/1125/head
Guillaume Abrioux 2016-11-28 15:16:56 +01:00
parent 3bdae23e42
commit 76220ed719
16 changed files with 61 additions and 416 deletions

View File

@ -6,21 +6,12 @@
always_run: true
when: ansible_os_family == 'RedHat'
- name: install dependencies
apt:
pkg: rhscon-agent
state: present
when: ansible_os_family == 'Debian'
tags:
- package-install
- name: install dependencies
# XXX Determine what RH repository this will belong to so that it can be
# properly checked and errored if the repository is not enabled.
yum:
package:
name: rhscon-agent
state: present
when: ansible_os_family == 'RedHat'
tags:
- package-install

View File

@ -26,8 +26,8 @@
when: ceph_dev
- name: add ubuntu cloud archive key package
apt:
pkg: ubuntu-cloud-keyring
package:
name: ubuntu-cloud-keyring
when: ceph_stable_uca
- name: add ubuntu cloud archive repository

View File

@ -1,39 +1,17 @@
---
- name: install redhat dependencies via yum
yum:
- name: install redhat dependencies
package:
name: "{{ item }}"
state: present
with_items: "{{ redhat_package_dependencies }}"
when:
- ansible_distribution == "RedHat"
- ansible_pkg_mgr == "yum"
when: ansible_distribution == "RedHat"
- name: install redhat dependencies via dnf
dnf:
name: "{{ item }}"
state: present
with_items: "{{ redhat_package_dependencies }}"
when:
- ansible_distribution == "RedHat"
- ansible_pkg_mgr == "dnf"
- name: install centos dependencies via yum
yum:
- name: install centos dependencies
package:
name: "{{ item }}"
state: present
with_items: "{{ centos_package_dependencies }}"
when:
- ansible_distribution == "CentOS"
- ansible_pkg_mgr == "yum"
- name: install centos dependencies via dnf
dnf:
name: "{{ item }}"
state: present
with_items: "{{ centos_package_dependencies }}"
when:
- ansible_distribution == "CentOS"
- ansible_pkg_mgr == "dnf"
when: ansible_distribution == "CentOS"
- name: configure ceph yum repository
include: redhat_ceph_repository.yml
@ -99,184 +77,82 @@
when:
- ceph_origin == 'local'
- name: install distro or red hat storage ceph mon via yum
yum:
- name: install distro or red hat storage ceph mon
package:
name: "ceph-mon"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- mon_group_name in group_names
- ansible_pkg_mgr == "yum"
- ceph_release_num.{{ ceph_release }} > ceph_release_num.infernalis
or ceph_origin == "distro"
or ceph_custom
- name: install distro or red hat storage ceph mon via dnf
dnf:
name: "ceph-mon"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- mon_group_name in group_names
- ansible_pkg_mgr == "dnf"
- ceph_release_num.{{ ceph_release }} > ceph_release_num.infernalis
or ceph_origin == "distro"
or ceph_custom
- name: install distro or red hat storage ceph osd via yum
yum:
- name: install distro or red hat storage ceph osd
package:
name: "ceph-osd"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- osd_group_name in group_names
- ansible_pkg_mgr == "yum"
- ceph_release_num.{{ ceph_release }} > ceph_release_num.infernalis
or ceph_origin == "distro"
or ceph_custom
- name: install distro or red hat storage ceph osd via dnf
dnf:
name: "ceph-osd"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- osd_group_name in group_names
- ansible_pkg_mgr == "dnf"
- ceph_release_num.{{ ceph_release }} > ceph_release_num.infernalis
or ceph_origin == "distro"
or ceph_custom
- name: install distro or red hat storage ceph mds via yum
yum:
- name: install distro or red hat storage ceph mds
package:
name: "ceph-mds"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- mds_group_name in group_names
- ansible_pkg_mgr == "yum"
- ceph_release_num.{{ ceph_release }} > ceph_release_num.infernalis
or ceph_origin == "distro"
or ceph_custom
- name: install distro or red hat storage ceph mds via dnf
dnf:
name: "ceph-mds"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- mds_group_name in group_names
- ansible_pkg_mgr == "dnf"
- ceph_release_num.{{ ceph_release }} > ceph_release_num.infernalis
or ceph_origin == "distro"
or ceph_custom
- name: install distro or red hat storage ceph-fuse via yum
yum:
- name: install distro or red hat storage ceph-fuse
package:
name: "ceph-fuse"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- client_group_name in group_names
- ansible_pkg_mgr == "yum"
- ceph_release_num.{{ ceph_release }} > ceph_release_num.infernalis
or ceph_origin == "distro"
or ceph_dev
or ceph_custom
- name: install distro or red hat storage ceph-fuse via dnf
dnf:
name: "ceph-fuse"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- client_group_name in group_names
- ansible_pkg_mgr == "dnf"
- ceph_release_num.{{ ceph_release }} > ceph_release_num.infernalis
or ceph_origin == "distro"
or ceph_dev
or ceph_custom
- name: install distro or red hat storage ceph base via yum
yum:
- name: install distro or red hat storage ceph base
package:
name: "ceph-base"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- client_group_name in group_names
- ansible_pkg_mgr == "yum"
- ceph_release_num.{{ ceph_release }} > ceph_release_num.infernalis
or ceph_origin == "distro"
or ceph_custom
- name: install distro or red hat storage ceph base via dnf
dnf:
name: "ceph-base"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- client_group_name in group_names
- ansible_pkg_mgr == "dnf"
- ceph_release_num.{{ ceph_release }} > ceph_release_num.infernalis
or ceph_origin == "distro"
or ceph_custom
- name: install ceph-test
yum:
package:
name: ceph-test
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- ceph_test
- ansible_pkg_mgr == "yum"
- name: install ceph-test
dnf:
name: ceph-test
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- ceph_test
- ansible_pkg_mgr == "dnf"
when: ceph_test
- name: install rados gateway
yum:
package:
name: ceph-radosgw
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- rgw_group_name in group_names
- ansible_pkg_mgr == "yum"
- name: install rados gateway
dnf:
name: ceph-radosgw
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- rgw_group_name in group_names
- ansible_pkg_mgr == "dnf"
when: rgw_group_name in group_names
- name: install nfs ceph gateway
yum:
package:
name: nfs-ganesha-ceph
when:
- nfs_group_name in group_names
- ansible_pkg_mgr == "yum"
- nfs_file_gw
- name: install nfs ceph gateway
dnf:
name: nfs-ganesha-ceph
when:
- nfs_group_name in group_names
- ansible_pkg_mgr == "dnf"
- nfs_file_gw
- name: install nfs rgw gateway
yum:
package:
name: "{{ item }}"
with_items:
- nfs-ganesha-rgw
- ceph-radosgw
when:
- nfs_group_name in group_names
- ansible_pkg_mgr == "yum"
- nfs_obj_gw
- name: install nfs rgw gateway
dnf:
name: "{{ item }}"
with_items:
- nfs-ganesha-rgw
- ceph-radosgw
when:
- nfs_group_name in group_names
- ansible_pkg_mgr == "dnf"
- nfs_obj_gw

View File

@ -17,57 +17,55 @@
- ceph_rhcs_iso_install
- name: install dependencies
yum:
package:
name: "{{ item }}"
state: present
with_items: "{{ redhat_package_dependencies }}"
when:
- ansible_pkg_mgr == "yum"
- name: install red hat storage ceph mon
yum:
package:
name: "ceph-mon"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- mon_group_name in group_names
- name: install red hat storage ceph osd
yum:
package:
name: "ceph-osd"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- osd_group_name in group_names
- name: install red hat storage ceph mds
yum:
package:
name: "ceph-mds"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- mds_group_name in group_names
- name: install red hat storage ceph-common
yum:
package:
name: "ceph-common"
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- client_group_name in group_names
- name: install ceph-test
yum:
package:
name: ceph-test
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- ceph_test
- name: install rados gateway
yum:
package:
name: ceph-radosgw
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:
- rgw_group_name in group_names
- name: install NFS gateway
yum:
package:
name: nfs-ganesha-ceph
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
when:

View File

@ -12,36 +12,18 @@
when: ceph_dev
- name: add ceph stable repository
yum:
package:
name: http://download.ceph.com/rpm-{{ ceph_stable_release }}/{{ ceph_stable_redhat_distro }}/noarch/ceph-release-1-0.{{ ceph_stable_redhat_distro|replace('rhel', 'el') }}.noarch.rpm
state: present
changed_when: false
when:
- ceph_stable
- ansible_pkg_mgr == "yum"
- name: add ceph stable repository
dnf:
name: http://download.ceph.com/rpm-{{ ceph_stable_release }}/{{ ceph_stable_redhat_distro }}/noarch/ceph-release-1-0.{{ ceph_stable_redhat_distro|replace('rhel', 'el') }}.noarch.rpm
changed_when: false
when:
- ceph_stable
- ansible_pkg_mgr == "dnf"
when: ceph_stable
- name: add ceph development repository
yum:
package:
name: http://gitbuilder.ceph.com/ceph-rpm-{{ ceph_dev_redhat_distro }}-x86_64-basic/ref/{{ ceph_dev_branch }}/noarch/ceph-release-1-0.{{ ceph_stable_redhat_distro }}.noarch.rpm
state: present
changed_when: false
when:
- ceph_dev
- ansible_pkg_mgr == "yum"
- name: add ceph development repository
dnf:
name: http://gitbuilder.ceph.com/ceph-rpm-{{ ceph_dev_redhat_distro }}-x86_64-basic/ref/{{ ceph_dev_branch }}/noarch/ceph-release-1-0.{{ ceph_stable_redhat_distro }}.noarch.rpm
changed_when: false
when:
- ceph_dev
- ansible_pkg_mgr == "dnf"
when: ceph_dev
- name: add custom repo
get_url:

View File

@ -134,34 +134,11 @@
with_pkg
when: ansible_version['full'] | version_compare('2.1.0.0', '>=')
- name: install ntp on redhat using yum
yum:
- name: install ntp
package:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'yum'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on redhat using dnf
dnf:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'dnf'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on debian
apt:
name: ntp
state: present
when:
- ansible_os_family == 'Debian'
- ntp_service_enabled
tags:
with_pkg

View File

@ -1,17 +1,8 @@
---
- name: install calamari server
apt:
pkg: calamari-server
package:
name: calamari-server
state: present
when: ansible_os_family == 'Debian'
tags:
- package-install
- name: install calamari server
yum:
pkg: calamari-server
state: present
when: ansible_os_family == 'RedHat'
tags:
- package-install

View File

@ -138,34 +138,11 @@
with_pkg
when: ansible_version['full'] | version_compare('2.1.0.0', '>=')
- name: install ntp on redhat using yum
yum:
- name: install ntp
package:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'yum'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on redhat using dnf
dnf:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'dnf'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on debian
apt:
name: ntp
state: present
when:
- ansible_os_family == 'Debian'
- ntp_service_enabled
tags:
with_pkg

View File

@ -107,34 +107,11 @@
tags:
with_pkg
- name: install ntp on redhat using yum
yum:
- name: install ntp
package:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'yum'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on redhat using dnf
dnf:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'dnf'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on debian
apt:
name: ntp
state: present
when:
- ansible_os_family == 'Debian'
- ntp_service_enabled
tags:
with_pkg

View File

@ -126,34 +126,11 @@
with_pkg
when: ansible_version['full'] | version_compare('2.1.0.0', '>=')
- name: install ntp on redhat using yum
yum:
- name: install ntp
package:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'yum'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on redhat using dnf
dnf:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'dnf'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on debian
apt:
name: ntp
state: present
when:
- ansible_os_family == 'Debian'
- ntp_service_enabled
tags:
with_pkg

View File

@ -1,10 +1,4 @@
---
- name: install debian dependencies
apt:
pkg: parted
state: present
when: ansible_os_family == 'Debian'
- name: enable extras repo for centos
ini_file:
dest: /etc/yum.repos.d/CentOS-Base.repo
@ -13,21 +7,10 @@
value: 1
when: ansible_distribution == 'CentOS'
- name: install redhat dependencies via yum
yum:
- name: install rependencies
package:
name: parted
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == "yum"
- name: install redhat rependencies via dnf
dnf:
name: parted
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == "dnf"
- name: create bootstrap-osd directory
file:

View File

@ -134,34 +134,11 @@
with_pkg
when: ansible_version['full'] | version_compare('2.1.0.0', '>=')
- name: install ntp on redhat using yum
yum:
- name: install ntp
package:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'yum'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on redhat using dnf
dnf:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'dnf'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on debian
apt:
name: ntp
state: present
when:
- ansible_os_family == 'Debian'
- ntp_service_enabled
tags:
with_pkg

View File

@ -1,19 +1,10 @@
---
- name: install dependencies
apt:
pkg: rbd-mirror
state: present
when: ansible_os_family == 'Debian'
tags:
- package-install
- name: install dependencies
# XXX Determine what RH repository this will belong to so that it can be
# properly checked and errored if the repository is not enabled.
yum:
package:
name: rbd-mirror
state: present
when: ansible_os_family == 'RedHat'
tags:
- package-install

View File

@ -132,34 +132,11 @@
tags:
with_pkg
- name: install ntp on redhat using yum
yum:
- name: install ntp
package:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'yum'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on redhat using dnf
dnf:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'dnf'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on debian
apt:
name: ntp
state: present
when:
- ansible_os_family == 'Debian'
- ntp_service_enabled
tags:
with_pkg

View File

@ -120,34 +120,11 @@
tags:
with_pkg
- name: install ntp on redhat using yum
yum:
- name: install ntp
package:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'yum'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on redhat using dnf
dnf:
name: ntp
state: present
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'dnf'
- ntp_service_enabled
tags:
with_pkg
- name: install ntp on debian
apt:
name: ntp
state: present
when:
- ansible_os_family == 'Debian'
- ntp_service_enabled
tags:
with_pkg

View File

@ -1,18 +1,12 @@
---
- name: install nss-tools on redhat
yum:
package:
name: nss-tools
state: present
when: ansible_pkg_mgr == "yum"
- name: install nss-tools on redhat
dnf:
name: nss-tools
state: present
when: ansible_pkg_mgr == "dnf"
when: ansible_pkg_mgr == "yum" or ansible_pkg_mgr == "dnf"
- name: install libnss3-tools on debian
apt:
package:
name: libnss3-tools
state: present
when: ansible_pkg_mgr == 'apt'