Skip to content

Commit

Permalink
updated prefilight and added debain tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
0lzi committed Jul 11, 2024
1 parent ae3f080 commit c62acd8
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 102 deletions.
106 changes: 4 additions & 102 deletions cephadm-preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,109 +216,11 @@

- name: Ubuntu related tasks
when: ansible_facts['distribution'] == 'Ubuntu'
block:
- name: enable repo from download.ceph.com
block:
- name: prevent ceph certificate error
apt:
name: ca-certificates
state: latest
update_cache: true
register: result
until: result is succeeded

- name: configure ceph community repository stable key
apt_key:
url: "{{ ceph_stable_key }}"
state: present

- name: configure Ceph community repository
when: ceph_origin == 'community'
apt_repository:
repo: "deb https://download.ceph.com/debian-{{ ceph_release }}/ {{ ansible_facts['distribution_release'] }} main"
state: present
filename: ceph
update_cache: false

- name: configure Ceph testing repository
when: ceph_origin == 'testing'
apt_repository:
repo: "deb https://download.ceph.com/debian-testing/ {{ ansible_facts['distribution_release'] }} main"
state: present
filename: ceph
update_cache: false

- name: configure Ceph custom repositories
when: ceph_origin == 'custom'
apt_repository:
repo: "deb {{ item.baseurl }}/ {{ ansible_facts['distribution_release'] }} {{ item.components }}"
state: "{{ item.state | default(omit) }}"
filename: ceph_custom
update_cache: false
loop: "{{ ceph_custom_repositories }}"

- name: install prerequisites packages
apt:
name: "{{ ['python3','chrony'] + ceph_pkgs }}"
state: "{{ (upgrade_ceph_packages | bool) | ternary('latest', 'present') }}"
update_cache: true
register: result
until: result is succeeded

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

- name: install container engine
block:
- name: install podman
when: ansible_facts['distribution_version'] is version('20.10', '>=')
apt:
name: podman
state: present
update_cache: true
register: result
until: result is succeeded

- name: install docker
when: ansible_facts['distribution_version'] is version('20.10', '<')
block:
- name: uninstall old version packages
apt:
name: "{{ item }}"
state: absent
loop:
- docker
- docker-engine
- docker.io
- containerd
- runc

- name: configure docker repository key
apt_key:
url: "https://download.docker.com/linux/ubuntu/gpg"
state: present

- name: setup docker repository
apt_repository:
repo: "deb https://download.docker.com/linux/ubuntu {{ ansible_facts['distribution_release'] }} stable"
state: present
filename: docker
update_cache: false
import_tasks: tasks/ubuntu.yml

- name: install docker
apt:
name: "{{ item }}"
state: present
update_cache: true
register: result
until: result is succeeded
loop:
- docker-ce
- docker-ce-cli
- containerd.io
- 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
103 changes: 103 additions & 0 deletions tasks/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
- name: enable repo from download.ceph.com
block:
- name: prevent ceph certificate error
apt:
name: ca-certificates
state: latest
update_cache: true
register: result
until: result is succeeded

- name: configure ceph community repository stable key
apt_key:
url: "{{ ceph_stable_key }}"
state: present

- name: configure Ceph community repository
when: ceph_origin == 'community'
apt_repository:
repo: "deb https://download.ceph.com/debian-{{ ceph_release }}/ {{ ansible_facts['distribution_release'] }} main"
state: present
filename: ceph
update_cache: false

- name: configure Ceph testing repository
when: ceph_origin == 'testing'
apt_repository:
repo: "deb https://download.ceph.com/debian-testing/ {{ ansible_facts['distribution_release'] }} main"
state: present
filename: ceph
update_cache: false

- name: configure Ceph custom repositories
when: ceph_origin == 'custom'
apt_repository:
repo: "deb {{ item.baseurl }}/ {{ ansible_facts['distribution_release'] }} {{ item.components }}"
state: "{{ item.state | default(omit) }}"
filename: ceph_custom
update_cache: false
loop: "{{ ceph_custom_repositories }}"

- name: install prerequisites packages
apt:
name: "{{ ['python3','chrony'] + ceph_pkgs }}"
state: "{{ (upgrade_ceph_packages | bool) | ternary('latest', 'present') }}"
update_cache: true
register: result
until: result is succeeded

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

- name: install container engine
block:
- name: install podman
when: ansible_facts['distribution_version'] is version('11', '>=')
apt:
name: podman
state: present
update_cache: true
register: result
until: result is succeeded

- name: install docker
when: ansible_facts['distribution_version'] is version('10', '<')
block:
- name: uninstall old version packages
apt:
name: "{{ item }}"
state: absent
loop:
- docker
- docker-engine
- docker.io
- containerd
- runc

- name: configure docker repository key
apt_key:
url: "https://download.docker.com/linux/debian/gpg"
state: present

- name: setup docker repository
apt_repository:
repo: "deb https://download.docker.com/linux/debian {{ ansible_facts['distribution_release'] }} stable"
state: present
filename: docker
update_cache: false

- name: install docker
apt:
name: "{{ item }}"
state: present
update_cache: true
register: result
until: result is succeeded
loop:
- docker-ce
- docker-ce-cli
- containerd.io

166 changes: 166 additions & 0 deletions tasks/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
- 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: 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 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: group_names == [client_group]


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

Loading

0 comments on commit c62acd8

Please sign in to comment.