Skip to content

Commit

Permalink
changed to include_tasks from import_task for OS specific tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
0lzi committed Jul 11, 2024
1 parent c62acd8 commit 8d544de
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 176 deletions.
186 changes: 10 additions & 176 deletions cephadm-preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,186 +41,20 @@
- ceph-radosgw
- rbd-mirror
tasks:
- name: import_role ceph_defaults
- name: Import_role ceph_defaults
import_role:
name: ceph_defaults

- name: redhat family of OS related tasks
when: ansible_facts['os_family'] == 'RedHat'
block:
- name: rhcs related tasks
when: ceph_origin == 'rhcs'
block:
- name: enable red hat ceph storage tools repository
rhsm_repository:
name: "rhceph-{{ ceph_rhcs_version }}-tools-for-rhel-{{ ansible_facts['distribution_major_version'] }}-{{ ansible_facts['architecture'] }}-rpms"
- name: Import specific OS-related tasks
include_tasks: "{{ lookup('first_found', __OS_distribution) }}"
vars:
__OS_distribution:
files:
- "tasks/{{ ansible_facts['distribution'] }}.yml"
paths:
- "{{ playbook_dir }}"
skip: true

- name: disable older rhceph repositories if any on RHEL{{ansible_facts['distribution_major_version']}}
when: ansible_facts['distribution_major_version'] == '8'
rhsm_repository:
name: "{{ repos_4_to_disable + repos_5_to_disable }}"
state: absent

- name: disable older rhceph repositories if any on RHEL{{ansible_facts['distribution_major_version']}}
when: ansible_facts['distribution_major_version'] == '9'
rhsm_repository:
name: "{{ repos_5_to_disable + repos_6_to_disable }}"
state: absent

- name: enable ceph package repositories
when: ceph_origin in ['community', 'ibm']
block:
- name: set_fact _ceph_repo
set_fact:
_ceph_repo:
name: ceph_stable
description: "{{ 'Ceph Stable repo' if ceph_origin == 'community' else 'IBM Ceph repo' }}"
rpm_key: "{{ ceph_stable_key if ceph_origin == 'community' else ceph_ibm_key }}"
baseurl: "{{ ceph_community_repo_baseurl if ceph_origin == 'community' else ceph_ibm_repo_baseurl }}"
paths: "{{ [ 'noarch', '$basearch' ] if ceph_origin == 'community' else [ '$basearch' ] }}"

- name: configure ceph repository key
rpm_key:
key: "{{ _ceph_repo.rpm_key }}"
state: present
register: result
until: result is succeeded

- name: configure ceph stable repository
yum_repository:
name: "ceph_stable_{{ item }}"
description: "{{ _ceph_repo.description }} - {{ item }}"
gpgcheck: true
state: present
gpgkey: "{{ _ceph_repo.rpm_key }}"
baseurl: "{{ _ceph_repo.baseurl }}/{{ item }}"
file: "ceph_stable_{{ item }}"
priority: '2'
register: result
until: result is succeeded
loop: "{{ _ceph_repo.paths }}"

- name: enable repo from shaman - dev
when: ceph_origin == 'shaman'
block:
- name: fetch ceph development repository
uri:
url:
"https://shaman.ceph.com/api/repos/ceph/\
{{ ceph_dev_branch }}/\
{{ ceph_dev_sha1 }}/\
centos/{{ ansible_facts['distribution_major_version'] }}/\
repo?arch={{ ansible_facts['architecture'] }}"
return_content: true
register: ceph_dev_yum_repo

- name: configure ceph development repository
copy:
content: "{{ ceph_dev_yum_repo.content }}"
dest: /etc/yum.repos.d/ceph-dev.repo
owner: root
group: root
mode: '0644'
backup: true

- name: remove ceph_stable repositories
yum_repository:
name: '{{ item }}'
file: ceph_stable
state: absent
with_items:
- ceph_stable
- ceph_stable_noarch

- name: enable custom repo
when: ceph_origin == 'custom'
block:
- name: set_fact ceph_custom_repositories
set_fact:
ceph_custom_repositories:
- name: ceph_custom
description: Ceph custom repo
gpgcheck: "{{ 'yes' if custom_repo_gpgkey is defined else 'no' }}"
state: "{{ custom_repo_state | default('present') }}"
gpgkey: "{{ custom_repo_gpgkey | default(omit) }}"
baseurl: "{{ custom_repo_url }}"
enabled: "{{ custom_repo_enabled | default(1) }}"
file: ceph_custom
priority: '2'
when: ceph_custom_repositories is undefined

- name: setup custom repositories
yum_repository:
name: "{{ item.name }}"
description: "{{ item.description }}"
state: "{{ item.state | default(omit) }}"
gpgcheck: "{{ item.gpgcheck | default(omit) }}"
gpgkey: "{{ item.gpgkey | default(omit) }}"
baseurl: "{{ item.baseurl }}"
file: "{{ item.ceph_custom | default(omit) }}"
priority: "{{ item.priority | default(omit) }}"
enabled: "{{ item.enabled | default(omit) }}"
register: result
until: result is succeeded
loop: "{{ ceph_custom_repositories }}"

- name: install epel-release
when: ansible_facts['distribution'] != 'RedHat'
block:
- name: enable required CentOS repository for epel
command: dnf config-manager --set-enabled "{{ 'powertools' if ansible_facts['distribution_major_version'] == '8' else 'crb' }}"
changed_when: false

- name: install epel package
package:
name: epel-release
state: present
register: result
until: result is succeeded

- name: remove remaining local services ceph packages
dnf:
name: "{{ packages_to_uninstall }}"
state: absent
autoremove: false

- name: install ceph-common on rhel
package:
name: ceph-common
state: "{{ (upgrade_ceph_packages | bool) | ternary('latest', 'present') }}"
register: result
until: result is succeeded

- name: install prerequisites packages on servers
package:
name: "{{ ceph_pkgs + infra_pkgs }}"
state: "{{ (upgrade_ceph_packages | bool) | ternary('latest', 'present') }}"
register: result
until: result is succeeded
when: group_names != [client_group]

- name: install prerequisites packages on clients
package:
name: "{{ ceph_client_pkgs }}"
state: "{{ (upgrade_ceph_packages | bool) | ternary('latest', 'present') }}"
register: result
until: result is succeeded
when: client_group in group_names


- name: ensure chronyd is running
service:
name: chronyd
state: started
enabled: true

- name: Ubuntu related tasks
when: ansible_facts['distribution'] == 'Ubuntu'
import_tasks: tasks/ubuntu.yml

- name: Debain related tasks
when: ansible_facts['distribution'] == 'Debian'
import_tasks: tasks/debian.yml

- name: set insecure container registry in /etc/containers/registries.conf
ansible.builtin.import_playbook: cephadm-set-container-insecure-registries.yml
Expand Down
1 change: 1 addition & 0 deletions tasks/Centos.yml
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8d544de

Please sign in to comment.