Skip to content

Commit

Permalink
Refactor ceph-mgr package installation
Browse files Browse the repository at this point in the history
The code for installing the ceph-mgr packages had several conditionals
which mean that certain features are only available on specific
operating systems and any OS specific packaging differences must be expressed
entirely in ansible tasks.

This patch takes a design pattern used extensively in openstack-ansible
and uses it for the ceph-mgr installation. The packages to install are
specificed in OS specific vars files which are loaded as required at
runtime and referenced through the role defaults.

This means that the OS specific conditionals are removed from the
ansible tasks, and the deployer can now override the package lists
supplied in the ceph-mgr vars if required.

This patch fixes two install failures, Centos-8 does not have python3-saml [1]
so this package is commented out as it is not generally available, and
all debian derivative OS are assumed to be running python3, so python3-routes
is preferred instead of python-routes which fixes installs on Ubuntu Focal.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1819302
  • Loading branch information
Jonathan Rosser committed Jun 18, 2020
1 parent d677596 commit e925910
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 33 deletions.
6 changes: 3 additions & 3 deletions roles/ceph-mgr/defaults/main.yml
Expand Up @@ -21,9 +21,9 @@ ceph_mgr_modules: []
# PACKAGES #
############
# Ceph mgr packages to install, ceph-mgr + extra module packages.
ceph_mgr_packages:
- ceph-mgr

ceph_mgr_packages: "{{ _ceph_mgr_packages }}"
ceph_mgr_dashboard_packages: "{{ _ceph_mgr_dashboard_packages }}"
ceph_mgr_all_packages: "{{ ceph_mgr_packages + ((dashboard_enabled | bool) | ternary(ceph_mgr_dashboard_packages, [])) }}"

##########
# DOCKER #
Expand Down
12 changes: 12 additions & 0 deletions roles/ceph-mgr/tasks/main.yml
@@ -1,4 +1,16 @@
---
- name: Gather variables for each operating system
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml"
- "{{ ansible_os_family | lower }}.yml"
tags:
- always

- name: set_fact container_exec_cmd
set_fact:
container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[item]['ansible_hostname'] }}"
Expand Down
32 changes: 2 additions & 30 deletions roles/ceph-mgr/tasks/pre_requisite.yml
@@ -1,45 +1,17 @@
---
- name: set_fact ceph_mgr_packages for sso
set_fact:
ceph_mgr_packages: "{{ ceph_mgr_packages | union(['python3-saml' if ansible_distribution_major_version | int == 8 else 'python-saml']) }}"
when:
- dashboard_enabled | bool
- ansible_distribution == 'RedHat'

- name: set_fact ceph_mgr_packages for dashboard
set_fact:
ceph_mgr_packages: "{{ ceph_mgr_packages | union(['ceph-mgr-dashboard']) }}"
when: dashboard_enabled | bool

- name: set_fact ceph_mgr_packages for non el7 distribution
set_fact:
ceph_mgr_packages: "{{ ceph_mgr_packages | union(['ceph-mgr-diskprediction-local']) }}"
when:
- ansible_os_family != 'RedHat'
- ansible_distribution_major_version | int != 7

- name: install ceph-mgr packages on RedHat or SUSE
package:
name: '{{ ceph_mgr_packages }}'
name: '{{ ceph_mgr_all_packages }}'
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
register: result
until: result is succeeded
when: ansible_os_family in ['RedHat', 'Suse']

- name: install ceph-mgr packages for debian
apt:
name: '{{ ceph_mgr_packages }}'
name: '{{ ceph_mgr_all_packages }}'
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
default_release: "{{ ceph_stable_release_uca | default('') if ceph_origin == 'repository' and ceph_repository == 'uca' else ''}}{{ ansible_distribution_release ~ '-backports' if ceph_origin == 'distro' and ceph_use_distro_backports else '' }}"
register: result
until: result is succeeded
when: ansible_os_family == 'Debian'

- name: install routes python library for dashboard module
apt:
name: python-routes
register: result
until: result is succeeded
when:
- ansible_os_family == 'Debian'
- "'ceph-mgr-dashboard' in ceph_mgr_packages"
8 changes: 8 additions & 0 deletions roles/ceph-mgr/vars/debian.yml
@@ -0,0 +1,8 @@
---
_ceph_mgr_packages:
- ceph_mgr

This comment has been minimized.

Copy link
@mgariepy

mgariepy Jun 18, 2020

ceph-mgr

- ceph-mgr-diskprediction-local

_ceph_mgr_dashboard_packages:
- ceph_mgr_dashboard
- python3-routes
8 changes: 8 additions & 0 deletions roles/ceph-mgr/vars/redhat-7.yml
@@ -0,0 +1,8 @@
---
_ceph_mgr_packages:
- ceph_mgr

_ceph_mgr_dashboard_packages:
- ceph_mgr_dashboard
# python-saml does not appear to be available outside of RHEL subscriptions
# - python-saml
9 changes: 9 additions & 0 deletions roles/ceph-mgr/vars/redhat-8.yml
@@ -0,0 +1,9 @@
---
_ceph_mgr_packages:
- ceph_mgr
- ceph_mgr_diskprediction-local

_ceph_mgr_dashboard_packages:
- ceph_mgr_dashboard
# python3-saml does not appear to be available outside of RHEL subscriptions
# - python3-saml

0 comments on commit e925910

Please sign in to comment.