2020-04-10 05:50:54 +08:00
|
|
|
---
|
|
|
|
#
|
|
|
|
# This playbook does a cephadm adopt for all the Ceph services
|
|
|
|
#
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Confirm whether user really meant to adopt the cluster by cephadm
|
2020-04-10 05:50:54 +08:00
|
|
|
hosts: localhost
|
|
|
|
connection: local
|
|
|
|
become: false
|
|
|
|
gather_facts: false
|
|
|
|
vars_prompt:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: ireallymeanit # noqa: name[casing]
|
2020-04-10 05:50:54 +08:00
|
|
|
prompt: Are you sure you want to adopt the cluster by cephadm ?
|
|
|
|
default: 'no'
|
2024-02-14 18:14:02 +08:00
|
|
|
private: false
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Exit playbook, if user did not mean to adopt the cluster by cephadm
|
|
|
|
ansible.builtin.fail:
|
2020-04-10 05:50:54 +08:00
|
|
|
msg: >
|
|
|
|
Exiting cephadm-adopt playbook, cluster was NOT adopted.
|
|
|
|
To adopt the cluster, either say 'yes' on the prompt or
|
|
|
|
use `-e ireallymeanit=yes` on the command line when
|
|
|
|
invoking the playbook
|
|
|
|
when: ireallymeanit != 'yes'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import_role ceph-defaults
|
|
|
|
ansible.builtin.import_role:
|
2021-03-16 23:33:27 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Gather facts and prepare system for cephadm
|
2020-04-10 05:50:54 +08:00
|
|
|
hosts:
|
|
|
|
- "{{ mon_group_name|default('mons') }}"
|
|
|
|
- "{{ osd_group_name|default('osds') }}"
|
|
|
|
- "{{ mds_group_name|default('mdss') }}"
|
|
|
|
- "{{ rgw_group_name|default('rgws') }}"
|
|
|
|
- "{{ mgr_group_name|default('mgrs') }}"
|
|
|
|
- "{{ rbdmirror_group_name|default('rbdmirrors') }}"
|
2024-06-17 22:35:10 +08:00
|
|
|
- "{{ nfs_group_name|default('nfss') }}"
|
2020-07-25 06:05:41 +08:00
|
|
|
- "{{ monitoring_group_name|default('monitoring') }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
become: true
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
gather_facts: false
|
|
|
|
vars:
|
|
|
|
delegate_facts_host: true
|
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Gather facts
|
|
|
|
ansible.builtin.setup:
|
2020-06-30 22:13:42 +08:00
|
|
|
gather_subset:
|
|
|
|
- 'all'
|
|
|
|
- '!facter'
|
|
|
|
- '!ohai'
|
2020-04-10 05:50:54 +08:00
|
|
|
when: not delegate_facts_host | bool or inventory_hostname in groups.get(client_group_name, [])
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Gather and delegate facts
|
|
|
|
ansible.builtin.setup:
|
2020-06-30 22:13:42 +08:00
|
|
|
gather_subset:
|
|
|
|
- 'all'
|
|
|
|
- '!facter'
|
|
|
|
- '!ohai'
|
2020-04-10 05:50:54 +08:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
delegate_facts: true
|
|
|
|
with_items: "{{ groups['all'] | difference(groups.get('clients', [])) }}"
|
|
|
|
run_once: true
|
|
|
|
when: delegate_facts_host | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-facts role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: container_binary.yml
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact ceph_cmd
|
|
|
|
ansible.builtin.set_fact:
|
2022-02-07 23:08:40 +08:00
|
|
|
ceph_cmd: "{{ container_binary + ' run --rm --net=host -v /etc/ceph:/etc/ceph:z -v /var/lib/ceph:/var/lib/ceph:ro -v /var/run/ceph:/var/run/ceph:z --entrypoint=ceph ' + ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else 'ceph' }} --cluster {{ cluster }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Check pools have an application enabled
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} health detail --format json"
|
2022-02-07 23:08:40 +08:00
|
|
|
register: health_detail
|
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Check for POOL_APP_NOT_ENABLED warning
|
|
|
|
ansible.builtin.fail:
|
2022-02-07 23:08:40 +08:00
|
|
|
msg: "Make sure all your pool have an application enabled."
|
|
|
|
run_once: true
|
|
|
|
delegate_to: localhost
|
|
|
|
when:
|
|
|
|
- (health_detail.stdout | default('{}', True) | from_json)['status'] == "HEALTH_WARN"
|
|
|
|
- "'POOL_APP_NOT_ENABLED' in (health_detail.stdout | default('{}', True) | from_json)['checks']"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get the ceph version
|
|
|
|
ansible.builtin.command: "{{ container_binary + ' run --rm --entrypoint=ceph ' + ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else 'ceph' }} --version"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
register: ceph_version_out
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact ceph_version
|
|
|
|
ansible.builtin.set_fact:
|
2020-04-10 05:50:54 +08:00
|
|
|
ceph_version: "{{ ceph_version_out.stdout.split(' ')[2] }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Fail on pre octopus ceph releases
|
|
|
|
ansible.builtin.fail:
|
2020-04-10 05:50:54 +08:00
|
|
|
msg: >
|
|
|
|
Your Ceph version {{ ceph_version }} is not supported for this operation.
|
|
|
|
Please upgrade your cluster with the rolling_update.yml playbook first.
|
|
|
|
when: ceph_version is version('15.2', '<')
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Check if it is atomic host
|
|
|
|
ansible.builtin.stat:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: /run/ostree-booted
|
|
|
|
register: stat_ostree
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact is_atomic
|
|
|
|
ansible.builtin.set_fact:
|
2020-04-10 05:50:54 +08:00
|
|
|
is_atomic: "{{ stat_ostree.stat.exists }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-container-engine role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-container-engine
|
|
|
|
when: not containerized_deployment | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-container-common role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-container-common
|
|
|
|
tasks_from: registry.yml
|
|
|
|
when:
|
|
|
|
- not containerized_deployment | bool
|
|
|
|
- ceph_docker_registry_auth | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Pulling Ceph container image
|
|
|
|
ansible.builtin.command: "{{ timeout_command }} {{ container_binary }} pull {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
register: docker_image
|
|
|
|
until: docker_image.rc == 0
|
|
|
|
retries: "{{ docker_pull_retry }}"
|
|
|
|
delay: 10
|
|
|
|
when:
|
|
|
|
- not containerized_deployment | bool
|
|
|
|
- inventory_hostname in groups.get(mon_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(osd_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(mds_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(rgw_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(mgr_group_name, []) or
|
2024-06-17 22:35:10 +08:00
|
|
|
inventory_hostname in groups.get(rbdmirror_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(nfs_group_name, [])
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Configure repository for installing cephadm
|
2021-08-05 23:48:38 +08:00
|
|
|
when: containerized_deployment | bool
|
2022-02-01 00:25:19 +08:00
|
|
|
tags: with_pkg
|
2021-08-05 23:48:38 +08:00
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact ceph_origin
|
|
|
|
ansible.builtin.set_fact:
|
2021-11-29 17:48:23 +08:00
|
|
|
ceph_origin: repository
|
|
|
|
when: ceph_origin == 'dummy'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact ceph_repository
|
|
|
|
ansible.builtin.set_fact:
|
2021-11-29 17:48:23 +08:00
|
|
|
ceph_repository: community
|
|
|
|
when: ceph_repository == 'dummy'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Validate repository variables
|
|
|
|
ansible.builtin.import_role:
|
2021-08-05 23:48:38 +08:00
|
|
|
name: ceph-validate
|
|
|
|
tasks_from: check_repository.yml
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Configure repository
|
|
|
|
ansible.builtin.import_role:
|
2021-08-05 23:48:38 +08:00
|
|
|
name: ceph-common
|
|
|
|
tasks_from: "configure_repository.yml"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Install cephadm requirements
|
2022-02-01 00:25:19 +08:00
|
|
|
tags: with_pkg
|
2024-02-14 18:14:02 +08:00
|
|
|
ansible.builtin.package:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ['python3', 'lvm2']
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Install cephadm
|
2022-02-01 00:25:19 +08:00
|
|
|
tags: with_pkg
|
2024-02-14 18:14:02 +08:00
|
|
|
ansible.builtin.package:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: cephadm
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Install cephadm mgr module
|
2022-02-01 00:25:19 +08:00
|
|
|
tags: with_pkg
|
2024-02-14 18:14:02 +08:00
|
|
|
ansible.builtin.package:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-mgr-cephadm
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
when:
|
|
|
|
- not containerized_deployment | bool
|
|
|
|
- mgr_group_name in group_names
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get current fsid
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} fsid"
|
2020-04-10 05:50:54 +08:00
|
|
|
register: current_fsid
|
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get a minimal ceph configuration
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} config generate-minimal-conf"
|
2021-03-17 17:07:27 +08:00
|
|
|
register: minimal_config
|
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact fsid
|
|
|
|
ansible.builtin.set_fact:
|
2021-01-21 06:39:44 +08:00
|
|
|
fsid: "{{ current_fsid.stdout }}"
|
|
|
|
run_once: true
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Enable cephadm mgr module
|
2020-11-16 23:11:20 +08:00
|
|
|
ceph_mgr_module:
|
|
|
|
name: cephadm
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
state: enable
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
run_once: true
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set cephadm as orchestrator backend
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} orch set backend cephadm"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
run_once: true
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Check if there is an existing ssh keypair
|
|
|
|
ansible.builtin.stat:
|
2022-02-07 21:23:49 +08:00
|
|
|
path: "{{ item }}"
|
|
|
|
loop:
|
|
|
|
- "{{ cephadm_ssh_priv_key_path }}"
|
|
|
|
- "{{ cephadm_ssh_pub_key_path }}"
|
|
|
|
register: ssh_keys
|
|
|
|
changed_when: false
|
|
|
|
run_once: true
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set fact
|
|
|
|
ansible.builtin.set_fact:
|
2022-02-07 21:23:49 +08:00
|
|
|
stat_ssh_key_pair: "{{ ssh_keys.results | map(attribute='stat.exists') | list }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Fail if either ssh public or private key is missing
|
|
|
|
ansible.builtin.fail:
|
2022-02-07 21:23:49 +08:00
|
|
|
msg: "One part of the ssh keypair of user {{ cephadm_ssh_user }} is missing"
|
|
|
|
when:
|
|
|
|
- false in stat_ssh_key_pair
|
|
|
|
- true in stat_ssh_key_pair
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Generate cephadm ssh key if there is none
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} cephadm generate-key"
|
2022-02-07 21:23:49 +08:00
|
|
|
when: not true in stat_ssh_key_pair
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
run_once: true
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Use existing user keypair for remote connections
|
2022-02-07 21:23:49 +08:00
|
|
|
when: not false in stat_ssh_key_pair
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
2024-02-14 18:14:02 +08:00
|
|
|
ansible.builtin.command: >
|
2022-02-07 21:23:49 +08:00
|
|
|
{{ container_binary + ' run --rm --net=host --security-opt label=disable
|
|
|
|
-v /etc/ceph:/etc/ceph:z
|
|
|
|
-v /var/lib/ceph:/var/lib/ceph:ro
|
|
|
|
-v /var/run/ceph:/var/run/ceph:z
|
|
|
|
-v ' + item.1 + ':/etc/ceph/cephadm.' + item.0 + ':ro --entrypoint=ceph '+ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else 'ceph' }}
|
2022-03-17 22:13:06 +08:00
|
|
|
--cluster {{ cluster }} cephadm set-{{ item.0 }}-key -i /etc/ceph/cephadm.{{ item.0 }}
|
2024-02-14 18:14:02 +08:00
|
|
|
changed_when: false
|
2022-02-07 21:23:49 +08:00
|
|
|
with_together:
|
2024-02-14 18:14:02 +08:00
|
|
|
- ['pub', 'priv']
|
|
|
|
- ['{{ cephadm_ssh_pub_key_path }}', '{{ cephadm_ssh_priv_key_path }}']
|
2022-02-07 21:23:49 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get the cephadm ssh pub key
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} cephadm get-pub-key"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
run_once: true
|
|
|
|
register: cephadm_pubpkey
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Allow cephadm key
|
|
|
|
ansible.posix.authorized_key:
|
2022-02-07 21:23:49 +08:00
|
|
|
user: "{{ cephadm_ssh_user }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
key: '{{ cephadm_pubpkey.stdout }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set cephadm ssh user to {{ cephadm_ssh_user }}
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} cephadm set-user {{ cephadm_ssh_user }}"
|
2021-07-28 01:44:38 +08:00
|
|
|
changed_when: false
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
2024-07-17 12:42:44 +08:00
|
|
|
- name: Set cephadm ssh config
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} cephadm set-ssh-config -i {{ cephadm_ssh_config_path }}"
|
|
|
|
changed_when: false
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
when: cephadm_ssh_config_path is defined
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Run cephadm prepare-host
|
|
|
|
ansible.builtin.command: cephadm prepare-host
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set default container image in ceph configuration
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} config set global container_image {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
run_once: true
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set container image base in ceph configuration
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} config set mgr mgr/cephadm/container_image_base {{ ceph_docker_registry }}/{{ ceph_docker_image }}"
|
2020-07-10 06:38:17 +08:00
|
|
|
changed_when: false
|
|
|
|
run_once: true
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set dashboard container image in ceph mgr configuration
|
2020-07-10 06:38:17 +08:00
|
|
|
when: dashboard_enabled | bool
|
|
|
|
run_once: true
|
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set alertmanager container image in ceph configuration
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} config set mgr mgr/cephadm/container_image_alertmanager {{ alertmanager_container_image }}"
|
2020-07-10 06:38:17 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set grafana container image in ceph configuration
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} config set mgr mgr/cephadm/container_image_grafana {{ grafana_container_image }}"
|
2020-07-10 06:38:17 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set node-exporter container image in ceph configuration
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} config set mgr mgr/cephadm/container_image_node_exporter {{ node_exporter_container_image }}"
|
2020-07-10 06:38:17 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set prometheus container image in ceph configuration
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} config set mgr mgr/cephadm/container_image_prometheus {{ prometheus_container_image }}"
|
2020-07-10 06:38:17 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Enable the osd memory autotune for hci environment
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} config set osd osd_memory_target_autotune true"
|
2021-07-12 20:58:42 +08:00
|
|
|
changed_when: false
|
|
|
|
run_once: true
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
when: is_hci | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set autotune_memory_target_ratio
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} config set mgr mgr/cephadm/autotune_memory_target_ratio {{ '0.2' if is_hci | bool else '0.7' }}"
|
2022-05-13 19:28:55 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Manage nodes with cephadm - ipv4
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} orch host add {{ ansible_facts['nodename'] }} {{ ansible_facts['all_ipv4_addresses'] | ips_in_ranges(cephadm_mgmt_network.split(',')) | first }} {{ group_names | intersect(adopt_label_group_names) | join(' ') }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
2023-08-16 22:02:29 +08:00
|
|
|
when: cephadm_mgmt_network.split(',')[0] is ansible.utils.ipv4
|
2021-10-28 20:12:46 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Manage nodes with cephadm - ipv6
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} orch host add {{ ansible_facts['nodename'] }} {{ ansible_facts['all_ipv6_addresses'] | ips_in_ranges(cephadm_mgmt_network.split(',')) | last | ansible.utils.ipwrap }} {{ group_names | intersect(adopt_label_group_names) | join(' ') }}"
|
2021-10-28 20:12:46 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
2023-08-16 22:02:29 +08:00
|
|
|
when: cephadm_mgmt_network.split(',')[0] is ansible.utils.ipv6
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Add ceph label for core component
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} orch host label add {{ ansible_facts['nodename'] }} ceph"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
2020-12-10 06:05:25 +08:00
|
|
|
when: inventory_hostname in groups.get(mon_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(osd_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(mds_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(rgw_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(mgr_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(rbdmirror_group_name, [])
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get the client.admin keyring
|
2020-10-24 03:19:53 +08:00
|
|
|
ceph_key:
|
|
|
|
name: client.admin
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
output_format: plain
|
|
|
|
state: info
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
2020-07-09 23:19:41 +08:00
|
|
|
run_once: true
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
register: client_admin_keyring
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Copy the client.admin keyring
|
|
|
|
ansible.builtin.copy:
|
2020-07-09 23:19:41 +08:00
|
|
|
dest: "/etc/ceph/{{ cluster }}.client.admin.keyring"
|
|
|
|
content: "{{ client_admin_keyring.stdout + '\n' }}"
|
|
|
|
owner: "{{ ceph_uid | int if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid | int if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
mode: "{{ ceph_keyring_permissions }}"
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items:
|
|
|
|
- "{{ groups.get(osd_group_name, []) }}"
|
|
|
|
- "{{ groups.get(mds_group_name, []) }}"
|
|
|
|
- "{{ groups.get(rgw_group_name, []) }}"
|
|
|
|
- "{{ groups.get(mgr_group_name, []) }}"
|
|
|
|
- "{{ groups.get(rbdmirror_group_name, []) }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Assimilate ceph configuration
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} config assimilate-conf -i /etc/ceph/{{ cluster }}.conf"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
when: inventory_hostname in groups.get(mon_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(osd_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(mds_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(rgw_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(mgr_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(rbdmirror_group_name, [])
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact cephadm_cmd
|
|
|
|
ansible.builtin.set_fact:
|
2020-07-20 22:41:53 +08:00
|
|
|
cephadm_cmd: "cephadm {{ '--docker' if container_binary == 'docker' else '' }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set container registry info
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} cephadm registry-login {{ ceph_docker_registry }} {{ ceph_docker_registry_username }} {{ ceph_docker_registry_password }}"
|
2021-09-10 05:14:10 +08:00
|
|
|
changed_when: false
|
2021-09-21 16:41:53 +08:00
|
|
|
no_log: true
|
2021-09-10 05:14:10 +08:00
|
|
|
run_once: true
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
|
|
|
when: ceph_docker_registry_auth | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove logrotate configuration
|
|
|
|
ansible.builtin.file:
|
2021-10-29 05:15:49 +08:00
|
|
|
path: /etc/logrotate.d/ceph
|
|
|
|
state: absent
|
|
|
|
when: inventory_hostname in groups.get(mon_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(osd_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(mds_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(rgw_group_name, []) or
|
|
|
|
inventory_hostname in groups.get(mgr_group_name, []) or
|
2024-02-16 08:16:55 +08:00
|
|
|
inventory_hostname in groups.get(rbdmirror_group_name, [])
|
2021-10-12 22:01:20 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Store existing rbd mirror peers in monitor config store
|
2021-10-12 22:01:20 +08:00
|
|
|
hosts: "{{ rbdmirror_group_name|default('rbdmirrors') }}"
|
|
|
|
become: true
|
|
|
|
any_errors_fatal: true
|
|
|
|
gather_facts: true
|
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Store existing rbd mirror peers in monitor config store
|
2022-11-14 19:29:37 +08:00
|
|
|
when:
|
|
|
|
- ceph_rbd_mirror_configure | default(True) | bool
|
2023-08-04 20:37:39 +08:00
|
|
|
- ceph_rbd_mirror_remote_user is defined
|
|
|
|
- ceph_rbd_mirror_remote_cluster is defined
|
2021-10-12 22:01:20 +08:00
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults
|
|
|
|
ansible.builtin.import_role:
|
2021-10-12 22:01:20 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-validate
|
|
|
|
ansible.builtin.import_role:
|
2021-10-12 22:01:20 +08:00
|
|
|
name: ceph-validate
|
|
|
|
tasks_from: check_rbdmirror.yml
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import container_binary
|
|
|
|
ansible.builtin.import_role:
|
2021-10-12 22:01:20 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: container_binary.yml
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact rbd_cmd
|
|
|
|
ansible.builtin.set_fact:
|
2021-10-12 22:01:20 +08:00
|
|
|
rbd_cmd: "{{ container_binary + ' run --rm --net=host -v /etc/ceph:/etc/ceph:z -v /var/lib/ceph:/var/lib/ceph:z -v /var/run/ceph:/var/run/ceph:z --entrypoint=rbd ' + ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else 'ceph' }} --cluster {{ cluster }} -n client.rbd-mirror.{{ ansible_facts['hostname'] }} -k /etc/ceph/{{ cluster }}.client.rbd-mirror.{{ ansible_facts['hostname'] }}.keyring"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact admin_rbd_cmd
|
|
|
|
ansible.builtin.set_fact:
|
2021-10-12 22:01:20 +08:00
|
|
|
admin_rbd_cmd: "{{ container_binary + ' run --rm --net=host -v /etc/ceph:/etc/ceph:z -v /var/lib/ceph:/var/lib/ceph:z -v /var/run/ceph:/var/run/ceph:z --entrypoint=rbd ' + ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else 'ceph' }} --cluster {{ cluster }}"
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get mirror pool info
|
|
|
|
ansible.builtin.command: "{{ rbd_cmd }} mirror pool info {{ ceph_rbd_mirror_pool }} --format json"
|
2021-10-12 22:01:20 +08:00
|
|
|
register: mirror_pool_info
|
|
|
|
changed_when: false
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact mirror_peer_found
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
mirror_peer_uuid: "{{ ((mirror_pool_info.stdout | default('{}') | from_json)['peers'] | selectattr('site_name', 'match', '^' + ceph_rbd_mirror_remote_cluster + '$') | map(attribute='uuid') | list) }}"
|
2021-10-12 22:01:20 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove current rbd mirror peer, add new peer into mon config store
|
2021-10-12 22:01:20 +08:00
|
|
|
when: mirror_peer_uuid | length > 0
|
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get remote user keyring
|
|
|
|
ansible.builtin.slurp:
|
2021-10-12 22:01:20 +08:00
|
|
|
src: "/etc/ceph/{{ ceph_rbd_mirror_remote_cluster }}.{{ ceph_rbd_mirror_remote_user }}.keyring"
|
|
|
|
register: remote_user_keyring
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get quorum_status
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph quorum_status --format json"
|
2021-10-12 22:01:20 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
register: quorum_status
|
|
|
|
run_once: true
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact mon_ip_list
|
|
|
|
ansible.builtin.set_fact:
|
2021-10-12 22:01:20 +08:00
|
|
|
mon_ip_list: "{{ mon_ip_list | default([]) | union([item['addr'].split(':')[0]]) }}"
|
2022-02-09 01:02:24 +08:00
|
|
|
loop: "{{ (quorum_status.stdout | default('{}') | from_json)['monmap']['mons'] }}"
|
2021-10-12 22:01:20 +08:00
|
|
|
run_once: true
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove current mirror peer
|
|
|
|
ansible.builtin.command: "{{ admin_rbd_cmd }} mirror pool peer remove {{ ceph_rbd_mirror_pool }} {{ ((mirror_pool_info.stdout | default('{}') | from_json)['peers'] | selectattr('site_name', 'match', '^' + ceph_rbd_mirror_remote_cluster + '$') | map(attribute='uuid') | list)[0] }}"
|
2021-10-12 22:01:20 +08:00
|
|
|
delegate_to: "{{ groups.get(mon_group_name | default('mons'))[0] }}"
|
|
|
|
changed_when: false
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get remote user keyring secret
|
|
|
|
ansible.builtin.set_fact:
|
2021-10-12 22:01:20 +08:00
|
|
|
remote_user_keyring_secret: "{{ item.split('=', 1)[1] | trim }}"
|
|
|
|
with_items: "{{ (remote_user_keyring.content | b64decode).split('\n') }}"
|
|
|
|
when: "'key = ' in item"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Create a temporary file
|
|
|
|
ansible.builtin.tempfile:
|
2021-10-12 22:01:20 +08:00
|
|
|
path: /etc/ceph
|
|
|
|
state: file
|
|
|
|
suffix: _ceph-ansible
|
|
|
|
register: tmp_file
|
|
|
|
delegate_to: "{{ groups.get(mon_group_name | default('mons'))[0] }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Write secret to temporary file
|
|
|
|
ansible.builtin.copy:
|
2021-10-12 22:01:20 +08:00
|
|
|
dest: "{{ tmp_file.path }}"
|
|
|
|
content: "{{ remote_user_keyring_secret }}"
|
2024-02-14 18:14:02 +08:00
|
|
|
mode: preserve
|
2021-10-12 22:01:20 +08:00
|
|
|
delegate_to: "{{ groups.get(mon_group_name | default('mons'))[0] }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Re-add mirror peer
|
|
|
|
ansible.builtin.command: "{{ admin_rbd_cmd }} mirror pool peer add {{ ceph_rbd_mirror_pool }} {{ ceph_rbd_mirror_remote_user }}@{{ ceph_rbd_mirror_remote_cluster }} --remote-mon-host {{ ','.join(mon_ip_list) }} --remote-key-file {{ tmp_file.path }}"
|
2021-10-12 22:01:20 +08:00
|
|
|
delegate_to: "{{ groups.get(mon_group_name | default('mons'))[0] }}"
|
|
|
|
changed_when: false
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Rm temporary file
|
|
|
|
ansible.builtin.file:
|
2021-10-12 22:01:20 +08:00
|
|
|
path: "{{ tmp_file.path }}"
|
|
|
|
state: absent
|
|
|
|
delegate_to: "{{ groups.get(mon_group_name | default('mons'))[0] }}"
|
|
|
|
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Adopt ceph mon daemons
|
2020-04-10 05:50:54 +08:00
|
|
|
hosts: "{{ mon_group_name|default('mons') }}"
|
|
|
|
serial: 1
|
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Adopt mon daemon
|
2020-12-01 03:32:54 +08:00
|
|
|
cephadm_adopt:
|
2021-03-03 22:43:50 +08:00
|
|
|
name: "mon.{{ ansible_facts['hostname'] }}"
|
2020-12-01 03:32:54 +08:00
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
image: "{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}"
|
|
|
|
docker: "{{ true if container_binary == 'docker' else false }}"
|
|
|
|
pull: false
|
|
|
|
firewalld: "{{ true if configure_firewall | bool else false }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Reset failed ceph-mon systemd unit
|
|
|
|
ansible.builtin.command: "systemctl reset-failed ceph-mon@{{ ansible_facts['hostname'] }}" # noqa command-instead-of-module
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
2020-07-09 23:23:33 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
when: containerized_deployment | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove ceph-mon systemd files
|
|
|
|
ansible.builtin.file:
|
2021-08-10 21:21:19 +08:00
|
|
|
path: "{{ item }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: absent
|
2021-08-10 21:21:19 +08:00
|
|
|
loop:
|
|
|
|
- /etc/systemd/system/ceph-mon@.service
|
|
|
|
- /etc/systemd/system/ceph-mon@.service.d
|
|
|
|
- /etc/systemd/system/ceph-mon.target
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Waiting for the monitor to join the quorum...
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph quorum_status --format json"
|
2020-07-11 05:41:32 +08:00
|
|
|
changed_when: false
|
|
|
|
register: ceph_health_raw
|
|
|
|
until: >
|
2021-03-03 22:43:50 +08:00
|
|
|
ansible_facts['hostname'] in (ceph_health_raw.stdout | from_json)["quorum_names"]
|
2020-07-11 05:41:32 +08:00
|
|
|
retries: "{{ health_mon_check_retries }}"
|
|
|
|
delay: "{{ health_mon_check_delay }}"
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Adopt ceph mgr daemons
|
2023-08-04 15:54:22 +08:00
|
|
|
hosts: "{{ groups['mgrs'] | default(groups['mons']) | default(omit) }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
serial: 1
|
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Adopt mgr daemon
|
2020-12-01 03:32:54 +08:00
|
|
|
cephadm_adopt:
|
2021-03-03 22:43:50 +08:00
|
|
|
name: "mgr.{{ ansible_facts['hostname'] }}"
|
2020-12-01 03:32:54 +08:00
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
image: "{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}"
|
|
|
|
docker: "{{ true if container_binary == 'docker' else false }}"
|
|
|
|
pull: false
|
|
|
|
firewalld: "{{ true if configure_firewall | bool else false }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Reset failed ceph-mgr systemd unit
|
|
|
|
ansible.builtin.command: "systemctl reset-failed ceph-mgr@{{ ansible_facts['hostname'] }}" # noqa command-instead-of-module
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
2020-07-09 23:23:33 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
when: containerized_deployment | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove ceph-mgr systemd files
|
|
|
|
ansible.builtin.file:
|
2021-08-10 21:21:19 +08:00
|
|
|
path: "{{ item }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: absent
|
2021-08-10 21:21:19 +08:00
|
|
|
loop:
|
|
|
|
- /etc/systemd/system/ceph-mgr@.service
|
|
|
|
- /etc/systemd/system/ceph-mgr@.service.d
|
|
|
|
- /etc/systemd/system/ceph-mgr.target
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set osd flags
|
2021-01-22 01:12:17 +08:00
|
|
|
hosts: "{{ osd_group_name|default('osds') }}"
|
2020-07-11 03:24:24 +08:00
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-07-11 03:24:24 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-07-11 03:24:24 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get pool list
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} --cluster {{ cluster }} osd pool ls detail -f json"
|
2021-06-15 00:01:41 +08:00
|
|
|
register: pool_list
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
2021-07-26 23:10:19 +08:00
|
|
|
check_mode: false
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get balancer module status
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer status -f json"
|
2021-08-03 23:58:49 +08:00
|
|
|
register: balancer_status_adopt
|
2021-06-15 00:01:41 +08:00
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
2021-07-26 23:10:19 +08:00
|
|
|
check_mode: false
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact pools_pgautoscaler_mode
|
|
|
|
ansible.builtin.set_fact:
|
2021-06-15 00:01:41 +08:00
|
|
|
pools_pgautoscaler_mode: "{{ pools_pgautoscaler_mode | default([]) | union([{'name': item.pool_name, 'mode': item.pg_autoscale_mode}]) }}"
|
|
|
|
run_once: true
|
2021-07-29 02:54:15 +08:00
|
|
|
with_items: "{{ pool_list.stdout | default('{}') | from_json }}"
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Disable balancer
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer off"
|
2021-06-15 00:01:41 +08:00
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
2021-08-03 23:58:49 +08:00
|
|
|
when: (balancer_status_adopt.stdout | from_json)['active'] | bool
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Disable pg autoscale on pools
|
2021-06-15 00:01:41 +08:00
|
|
|
ceph_pool:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
pg_autoscale_mode: false
|
|
|
|
with_items: "{{ pools_pgautoscaler_mode }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
|
|
|
when:
|
|
|
|
- pools_pgautoscaler_mode is defined
|
|
|
|
- item.mode == 'on'
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set osd flags
|
2021-01-22 01:12:17 +08:00
|
|
|
ceph_osd_flag:
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
2020-07-11 03:24:24 +08:00
|
|
|
with_items:
|
|
|
|
- noout
|
|
|
|
- nodeep-scrub
|
2021-01-22 01:12:17 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
2020-07-11 03:24:24 +08:00
|
|
|
environment:
|
2021-01-22 01:12:17 +08:00
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
2020-07-11 03:24:24 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Adopt ceph osd daemons
|
2020-04-10 05:50:54 +08:00
|
|
|
hosts: "{{ osd_group_name|default('osd') }}"
|
|
|
|
serial: 1
|
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-facts role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: container_binary.yml
|
|
|
|
when: containerized_deployment | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get osd list
|
2020-11-19 06:20:45 +08:00
|
|
|
ceph_volume:
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
action: list
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
register: osd_list
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set osd fsid for containerized deployment
|
|
|
|
ansible.builtin.lineinfile:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: '/var/lib/ceph/osd/{{ cluster }}-{{ item.key }}/fsid'
|
|
|
|
line: "{{ (item.value | selectattr('type', 'equalto', 'block') | map(attribute='tags') | first)['ceph.osd_fsid'] }}"
|
|
|
|
owner: '{{ ceph_uid }}'
|
|
|
|
group: '{{ ceph_uid }}'
|
|
|
|
create: true
|
2024-02-14 18:14:02 +08:00
|
|
|
mode: "0644"
|
2020-04-10 05:50:54 +08:00
|
|
|
with_dict: '{{ osd_list.stdout | from_json }}'
|
|
|
|
when: containerized_deployment | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set osd type for containerized deployment
|
|
|
|
ansible.builtin.lineinfile:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: '/var/lib/ceph/osd/{{ cluster }}-{{ item }}/type'
|
|
|
|
line: 'bluestore'
|
|
|
|
owner: '{{ ceph_uid }}'
|
|
|
|
group: '{{ ceph_uid }}'
|
|
|
|
create: true
|
2024-02-14 18:14:02 +08:00
|
|
|
mode: "0644"
|
2020-04-10 05:50:54 +08:00
|
|
|
loop: '{{ (osd_list.stdout | from_json).keys() | list }}'
|
|
|
|
when: containerized_deployment | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Adopt osd daemon
|
2020-12-01 03:32:54 +08:00
|
|
|
cephadm_adopt:
|
|
|
|
name: "osd.{{ item }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
image: "{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}"
|
|
|
|
docker: "{{ true if container_binary == 'docker' else false }}"
|
|
|
|
pull: false
|
|
|
|
firewalld: "{{ true if configure_firewall | bool else false }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
loop: '{{ (osd_list.stdout | from_json).keys() | list }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove ceph-osd systemd and ceph-osd-run.sh files
|
|
|
|
ansible.builtin.file:
|
2021-08-10 21:21:19 +08:00
|
|
|
path: "{{ item }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- /etc/systemd/system/ceph-osd@.service
|
2021-08-10 21:21:19 +08:00
|
|
|
- /etc/systemd/system/ceph-osd@.service.d
|
|
|
|
- /etc/systemd/system/ceph-osd.target
|
2020-04-10 05:50:54 +08:00
|
|
|
- "{{ ceph_osd_docker_run_script_path | default('/usr/share') }}/ceph-osd-run.sh"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove osd directory
|
|
|
|
ansible.builtin.file:
|
2021-01-21 06:39:44 +08:00
|
|
|
path: "/var/lib/ceph/osd/{{ cluster }}-{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop: '{{ (osd_list.stdout | from_json).keys() | list }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove any legacy directories in /var/lib/ceph/mon (workaround)
|
|
|
|
ansible.builtin.file:
|
2022-05-11 19:47:46 +08:00
|
|
|
path: "/var/lib/ceph/mon/{{ cluster }}-{{ ansible_facts['hostname'] }}"
|
|
|
|
state: absent
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Waiting for clean pgs...
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph pg stat --format json"
|
2020-07-11 03:24:24 +08:00
|
|
|
changed_when: false
|
|
|
|
register: ceph_health_post
|
|
|
|
until: >
|
2020-10-26 23:23:01 +08:00
|
|
|
(((ceph_health_post.stdout | from_json).pg_summary.num_pg_by_state | length) > 0)
|
2020-07-11 03:24:24 +08:00
|
|
|
and
|
2020-10-26 23:23:01 +08:00
|
|
|
(((ceph_health_post.stdout | from_json).pg_summary.num_pg_by_state | selectattr('name', 'search', '^active\\+clean') | map(attribute='num') | list | sum) == (ceph_health_post.stdout | from_json).pg_summary.num_pgs)
|
2020-07-11 03:24:24 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
retries: "{{ health_osd_check_retries }}"
|
|
|
|
delay: "{{ health_osd_check_delay }}"
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Unset osd flags
|
2021-01-22 01:12:17 +08:00
|
|
|
hosts: "{{ osd_group_name|default('osds') }}"
|
2020-07-11 03:24:24 +08:00
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-07-11 03:24:24 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-07-11 03:24:24 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Re-enable pg autoscale on pools
|
2021-06-15 00:01:41 +08:00
|
|
|
ceph_pool:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
pg_autoscale_mode: true
|
|
|
|
with_items: "{{ pools_pgautoscaler_mode }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
|
|
|
when:
|
|
|
|
- pools_pgautoscaler_mode is defined
|
|
|
|
- item.mode == 'on'
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Unset osd flags
|
2021-01-22 01:12:17 +08:00
|
|
|
ceph_osd_flag:
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
2020-07-11 03:24:24 +08:00
|
|
|
with_items:
|
|
|
|
- noout
|
|
|
|
- nodeep-scrub
|
2021-01-22 01:12:17 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
2020-07-11 03:24:24 +08:00
|
|
|
environment:
|
2021-01-22 01:12:17 +08:00
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
2020-07-11 03:24:24 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Re-enable balancer
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer on"
|
2021-06-15 00:01:41 +08:00
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
2021-08-03 23:58:49 +08:00
|
|
|
when: (balancer_status_adopt.stdout | from_json)['active'] | bool
|
2021-06-15 00:01:41 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Redeploy mds daemons
|
2020-07-16 06:25:57 +08:00
|
|
|
hosts: "{{ mds_group_name|default('mdss') }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update the placement of metadata hosts
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph orch apply mds {{ cephfs }} --placement='{{ groups.get(mds_group_name, []) | length }} label:{{ mds_group_name }}'"
|
2020-04-10 05:50:54 +08:00
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
2020-07-16 06:25:57 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and remove legacy ceph mds daemons
|
2020-04-10 05:50:54 +08:00
|
|
|
hosts: "{{ mds_group_name|default('mdss') }}"
|
|
|
|
serial: 1
|
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable ceph-mds systemd service
|
|
|
|
ansible.builtin.service:
|
2021-03-03 22:43:50 +08:00
|
|
|
name: "ceph-mds@{{ ansible_facts['hostname'] }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2021-01-21 06:39:44 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable ceph-mds systemd target
|
|
|
|
ansible.builtin.service:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-mds.target
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2021-08-10 21:21:19 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Reset failed ceph-mds systemd unit
|
|
|
|
ansible.builtin.command: "systemctl reset-failed ceph-mds@{{ ansible_facts['hostname'] }}" # noqa command-instead-of-module
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
2020-07-09 23:23:33 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
when: containerized_deployment | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove ceph-mds systemd files
|
|
|
|
ansible.builtin.file:
|
2021-08-10 21:21:19 +08:00
|
|
|
path: "{{ item }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: absent
|
2021-08-10 21:21:19 +08:00
|
|
|
loop:
|
|
|
|
- /etc/systemd/system/ceph-mds@.service
|
|
|
|
- /etc/systemd/system/ceph-mds@.service.d
|
|
|
|
- /etc/systemd/system/ceph-mds.target
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove legacy ceph mds data
|
|
|
|
ansible.builtin.file:
|
2021-03-03 22:43:50 +08:00
|
|
|
path: "/var/lib/ceph/mds/{{ cluster }}-{{ ansible_facts['hostname'] }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: absent
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Redeploy rgw daemons
|
2021-07-29 03:50:15 +08:00
|
|
|
hosts: "{{ rgw_group_name | default('rgws') }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-facts role
|
|
|
|
ansible.builtin.import_role:
|
2021-06-23 21:24:23 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: set_radosgw_address.yml
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import rgw ssl certificate into kv store
|
2021-07-29 03:50:15 +08:00
|
|
|
when: radosgw_frontend_ssl_certificate | length > 0
|
2020-04-10 05:50:54 +08:00
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Slurp rgw ssl certificate
|
|
|
|
ansible.builtin.slurp:
|
2021-07-29 03:50:15 +08:00
|
|
|
src: "{{ radosgw_frontend_ssl_certificate }}"
|
|
|
|
register: rgw_ssl_cert
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Store ssl certificate in kv store
|
|
|
|
ansible.builtin.command: >
|
2021-07-29 03:50:15 +08:00
|
|
|
{{ container_binary }} run --rm -i -v /etc/ceph:/etc/ceph:z --entrypoint=ceph {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} --cluster {{ cluster }}
|
|
|
|
config-key set rgw/cert/rgw.{{ ansible_facts['hostname'] }} -i -
|
|
|
|
args:
|
|
|
|
stdin: "{{ rgw_ssl_cert.content | b64decode }}"
|
2024-02-14 18:14:02 +08:00
|
|
|
stdin_add_newline: false
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
2021-06-23 21:24:23 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact rgw_subnet
|
|
|
|
ansible.builtin.set_fact:
|
2023-08-04 17:17:44 +08:00
|
|
|
rgw_subnet: "--networks {{ radosgw_address_block }}"
|
|
|
|
when:
|
|
|
|
- radosgw_address_block is defined
|
|
|
|
- radosgw_address_block != 'subnet'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update the placement of radosgw hosts
|
2024-04-25 03:32:39 +08:00
|
|
|
ceph_orch_apply:
|
|
|
|
fsid: "{{ fsid }}"
|
|
|
|
spec: |
|
|
|
|
service_type: rgw
|
|
|
|
service_id: {{ ansible_facts['hostname'] }}
|
|
|
|
placement:
|
|
|
|
count_per_host: {{ radosgw_num_instances }}
|
|
|
|
hosts:
|
|
|
|
- {{ ansible_facts['nodename'] }}
|
2024-07-05 17:40:17 +08:00
|
|
|
{% if rgw_subnet is defined %}
|
2024-08-21 23:33:19 +08:00
|
|
|
networks: "{{ radosgw_address_block }}"
|
2024-07-05 17:40:17 +08:00
|
|
|
{% endif %}
|
2024-04-25 03:32:39 +08:00
|
|
|
spec:
|
|
|
|
rgw_frontend_port: {{ radosgw_frontend_port }}
|
2024-07-05 17:40:17 +08:00
|
|
|
{% if radosgw_frontend_ssl_certificate is defined %}
|
|
|
|
{{ "ssl: true" }}
|
|
|
|
{% endif %}
|
2024-04-25 03:32:39 +08:00
|
|
|
extra_container_args:
|
|
|
|
- -v
|
|
|
|
- /etc/pki/ca-trust:/etc/pki/ca-trust:ro
|
2021-07-29 03:50:15 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2020-07-10 06:28:49 +08:00
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and remove legacy ceph rgw daemons
|
2020-04-10 05:50:54 +08:00
|
|
|
hosts: "{{ rgw_group_name|default('rgws') }}"
|
|
|
|
serial: 1
|
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-facts role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: set_radosgw_address.yml
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable ceph-radosgw systemd service
|
|
|
|
ansible.builtin.service:
|
2024-05-08 02:41:53 +08:00
|
|
|
name: "ceph-radosgw@rgw.{{ rgw_zone }}.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2021-01-21 06:39:44 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
loop: '{{ rgw_instances }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable ceph-radosgw systemd target
|
|
|
|
ansible.builtin.service:
|
2021-08-10 21:21:19 +08:00
|
|
|
name: ceph-radosgw.target
|
2020-04-10 05:50:54 +08:00
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2021-08-10 21:21:19 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Reset failed ceph-radosgw systemd unit
|
2024-05-08 02:41:53 +08:00
|
|
|
ansible.builtin.command: "systemctl reset-failed ceph-radosgw@rgw.{{ rgw_zone }}.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}" # noqa command-instead-of-module
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
2020-07-09 23:23:33 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
loop: '{{ rgw_instances }}'
|
|
|
|
when: containerized_deployment | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove ceph-radosgw systemd files
|
|
|
|
ansible.builtin.file:
|
2021-08-10 21:21:19 +08:00
|
|
|
path: "{{ item }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: absent
|
2021-08-10 21:21:19 +08:00
|
|
|
loop:
|
|
|
|
- /etc/systemd/system/ceph-radosgw@.service
|
|
|
|
- /etc/systemd/system/ceph-radosgw@.service.d
|
|
|
|
- /etc/systemd/system/ceph-radosgw.target
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove legacy ceph radosgw data
|
|
|
|
ansible.builtin.file:
|
2024-05-08 02:41:53 +08:00
|
|
|
path: "/var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ rgw_zone }}.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: absent
|
|
|
|
loop: '{{ rgw_instances }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove legacy ceph radosgw directory
|
|
|
|
ansible.builtin.file:
|
2024-05-08 02:41:53 +08:00
|
|
|
path: "/var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ rgw_zone }}.{{ ansible_facts['hostname'] }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: absent
|
|
|
|
|
2024-06-17 22:35:10 +08:00
|
|
|
- name: Stop and remove legacy ceph nfs daemons
|
|
|
|
hosts: "{{ nfs_group_name|default('nfss') }}"
|
|
|
|
tags: 'ceph_nfs_adopt'
|
|
|
|
serial: 1
|
|
|
|
become: true
|
|
|
|
gather_facts: false
|
|
|
|
any_errors_fatal: true
|
|
|
|
tasks:
|
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
|
|
|
name: ceph-defaults
|
|
|
|
|
|
|
|
- name: Import ceph-nfs role
|
|
|
|
ansible.builtin.import_role:
|
|
|
|
name: ceph-nfs
|
|
|
|
tasks_from: create_rgw_nfs_user.yml
|
|
|
|
|
|
|
|
- name: Enable ceph mgr nfs module
|
|
|
|
ceph_mgr_module:
|
|
|
|
name: "nfs"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
state: enable
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
|
|
|
- name: Stop and disable ceph-nfs systemd service
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: "ceph-nfs@{{ ansible_facts['hostname'] }}"
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: Reset failed ceph-nfs systemd unit
|
|
|
|
ansible.builtin.command: "systemctl reset-failed ceph-nfs@{{ ansible_facts['hostname'] }}" # noqa command-instead-of-module
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
when: containerized_deployment | bool
|
|
|
|
|
|
|
|
- name: Remove ceph-nfs systemd unit files
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- /etc/systemd/system/ceph-nfs@.service
|
|
|
|
- /etc/systemd/system/ceph-nfs@.service.d
|
|
|
|
|
|
|
|
- name: Remove legacy ceph radosgw directory
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "/var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ ansible_facts['hostname'] }}"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: Create nfs ganesha cluster
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph nfs cluster create {{ ansible_facts['hostname'] }} {{ ansible_facts['hostname'] }}"
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
|
|
|
- name: Create cephfs export
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph nfs export create cephfs {{ cephfs }} {{ ansible_facts['hostname'] }} {{ ceph_nfs_ceph_pseudo_path }} --squash {{ ceph_nfs_ceph_squash }}"
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
when: nfs_file_gw | bool
|
|
|
|
|
|
|
|
- name: Create rgw export
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph nfs export create rgw --cluster-id {{ ansible_facts['hostname'] }} --pseudo-path {{ ceph_nfs_rgw_pseudo_path }} --user-id {{ ceph_nfs_rgw_user }} --squash {{ ceph_nfs_rgw_squash }}"
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
when: nfs_obj_gw | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Redeploy rbd-mirror daemons
|
2020-07-16 06:25:57 +08:00
|
|
|
hosts: "{{ rbdmirror_group_name|default('rbdmirrors') }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update the placement of rbd-mirror hosts
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph orch apply rbd-mirror --placement='{{ groups.get(rbdmirror_group_name, []) | length }} label:{{ rbdmirror_group_name }}'"
|
2020-04-10 05:50:54 +08:00
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
2020-07-16 06:25:57 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and remove legacy rbd-mirror daemons
|
2020-04-10 05:50:54 +08:00
|
|
|
hosts: "{{ rbdmirror_group_name|default('rbdmirrors') }}"
|
|
|
|
serial: 1
|
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable rbd-mirror systemd service
|
|
|
|
ansible.builtin.service:
|
2021-03-03 22:43:50 +08:00
|
|
|
name: "ceph-rbd-mirror@rbd-mirror.{{ ansible_facts['hostname'] }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2021-01-21 06:39:44 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable rbd-mirror systemd target
|
|
|
|
ansible.builtin.service:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-rbd-mirror.target
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2021-08-10 21:21:19 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Reset failed rbd-mirror systemd unit
|
|
|
|
ansible.builtin.command: "systemctl reset-failed ceph-rbd-mirror@rbd-mirror.{{ ansible_facts['hostname'] }}" # noqa command-instead-of-module
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
2020-07-09 23:23:33 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
when: containerized_deployment | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove rbd-mirror systemd files
|
|
|
|
ansible.builtin.file:
|
2021-08-10 21:21:19 +08:00
|
|
|
path: "{{ item }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: absent
|
2021-08-10 21:21:19 +08:00
|
|
|
loop:
|
|
|
|
- /etc/systemd/system/ceph-rbd-mirror@.service
|
|
|
|
- /etc/systemd/system/ceph-rbd-mirror@.service.d
|
|
|
|
- /etc/systemd/system/ceph-rbd-mirror.target
|
2020-04-10 05:50:54 +08:00
|
|
|
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Redeploy ceph-crash daemons
|
2020-04-10 05:50:54 +08:00
|
|
|
hosts:
|
|
|
|
- "{{ mon_group_name|default('mons') }}"
|
|
|
|
- "{{ osd_group_name|default('osds') }}"
|
|
|
|
- "{{ mds_group_name|default('mdss') }}"
|
|
|
|
- "{{ rgw_group_name|default('rgws') }}"
|
|
|
|
- "{{ mgr_group_name|default('mgrs') }}"
|
|
|
|
- "{{ rbdmirror_group_name|default('rbdmirrors') }}"
|
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable ceph-crash systemd service
|
|
|
|
ansible.builtin.service:
|
2021-04-28 21:11:25 +08:00
|
|
|
name: "{{ 'ceph-crash@' + ansible_facts['hostname'] if containerized_deployment | bool else 'ceph-crash.service' }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
state: stopped
|
|
|
|
enabled: false
|
|
|
|
failed_when: false
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove ceph-crash systemd unit file
|
|
|
|
ansible.builtin.file:
|
2021-08-10 21:21:19 +08:00
|
|
|
path: /etc/systemd/system/ceph-crash@.service
|
|
|
|
state: absent
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update the placement of ceph-crash hosts
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph orch apply crash --placement='label:ceph'"
|
2020-04-10 05:50:54 +08:00
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
2020-07-16 06:25:57 +08:00
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
2024-03-04 09:03:19 +08:00
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
|
|
|
|
|
|
|
- name: Redeploy ceph-exporter daemons
|
|
|
|
hosts:
|
|
|
|
- "{{ mon_group_name|default('mons') }}"
|
|
|
|
- "{{ osd_group_name|default('osds') }}"
|
|
|
|
- "{{ mds_group_name|default('mdss') }}"
|
|
|
|
- "{{ rgw_group_name|default('rgws') }}"
|
|
|
|
- "{{ mgr_group_name|default('mgrs') }}"
|
|
|
|
- "{{ rbdmirror_group_name|default('rbdmirrors') }}"
|
|
|
|
become: true
|
|
|
|
gather_facts: false
|
|
|
|
any_errors_fatal: true
|
|
|
|
tasks:
|
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
|
|
|
name: ceph-defaults
|
|
|
|
|
|
|
|
- name: Stop and disable ceph-exporter systemd service
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ 'ceph-exporter@' + ansible_facts['hostname'] if containerized_deployment | bool else 'ceph-exporter.service' }}"
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: Remove ceph-exporter systemd unit file
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: /etc/systemd/system/ceph-exporter@.service
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: Update the placement of ceph-exporter hosts
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph orch apply ceph-exporter --placement='label:ceph'"
|
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
2020-04-10 05:50:54 +08:00
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2021-08-10 21:21:19 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Redeploy alertmanager/grafana/prometheus daemons
|
2020-07-25 06:05:41 +08:00
|
|
|
hosts: "{{ monitoring_group_name|default('monitoring') }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
serial: 1
|
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Check whether a ceph config file is present
|
|
|
|
ansible.builtin.stat:
|
2021-03-17 17:07:27 +08:00
|
|
|
path: "/etc/ceph/{{ cluster }}.conf"
|
|
|
|
register: ceph_config
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Ensure /etc/ceph is present
|
|
|
|
ansible.builtin.file:
|
2021-12-08 04:11:50 +08:00
|
|
|
path: /etc/ceph
|
|
|
|
state: directory
|
|
|
|
owner: "{{ ceph_uid | int if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid | int if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
mode: "{{ ceph_directories_mode }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Write a ceph.conf with minimal config
|
|
|
|
ansible.builtin.copy:
|
2021-03-17 17:07:27 +08:00
|
|
|
dest: "/etc/ceph/{{ cluster }}.conf"
|
|
|
|
content: "{{ minimal_config.stdout }}"
|
|
|
|
owner: "{{ ceph_uid | int if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid | int if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
mode: "{{ ceph_keyring_permissions }}"
|
|
|
|
when: not ceph_config.stat.exists | bool
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: With dashboard enabled
|
2020-04-10 05:50:54 +08:00
|
|
|
when: dashboard_enabled | bool
|
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Ensure alertmanager/prometheus data directories are present
|
|
|
|
ansible.builtin.file:
|
2021-01-21 06:39:44 +08:00
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ prometheus_user_id }}"
|
|
|
|
group: "{{ prometheus_user_id }}"
|
2024-02-14 18:14:02 +08:00
|
|
|
mode: "0755"
|
2021-01-21 06:39:44 +08:00
|
|
|
with_items:
|
2024-02-14 18:14:02 +08:00
|
|
|
- "{{ alertmanager_data_dir }}"
|
|
|
|
- "{{ prometheus_data_dir }}"
|
2021-01-21 06:39:44 +08:00
|
|
|
|
2020-04-10 05:50:54 +08:00
|
|
|
# (workaround) cephadm adopt alertmanager only stops prometheus-alertmanager systemd service
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable alertmanager systemd unit
|
|
|
|
ansible.builtin.service:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: alertmanager
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2021-01-21 06:39:44 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
|
|
|
|
# (workaround) cephadm adopt alertmanager only uses /etc/prometheus/alertmanager.yml
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Create alertmanager config symlink
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: /etc/prometheus/alertmanager.yml
|
|
|
|
src: '{{ alertmanager_conf_dir }}/alertmanager.yml'
|
|
|
|
state: link
|
|
|
|
|
|
|
|
# (workaround) cephadm adopt alertmanager only uses /var/lib/prometheus/alertmanager/
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Create alertmanager data symlink
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: '{{ prometheus_data_dir }}/alertmanager'
|
|
|
|
src: '{{ alertmanager_data_dir }}'
|
|
|
|
state: link
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Adopt alertmanager daemon
|
2020-12-01 03:32:54 +08:00
|
|
|
cephadm_adopt:
|
2021-03-03 22:43:50 +08:00
|
|
|
name: "alertmanager.{{ ansible_facts['hostname'] }}"
|
2020-12-01 03:32:54 +08:00
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
image: "{{ alertmanager_container_image }}"
|
|
|
|
docker: "{{ true if container_binary == 'docker' else false }}"
|
|
|
|
pull: false
|
|
|
|
firewalld: "{{ true if configure_firewall | bool else false }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove alertmanager systemd unit file
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: /etc/systemd/system/alertmanager.service
|
|
|
|
state: absent
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove the legacy alertmanager data
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: '{{ alertmanager_data_dir }}'
|
|
|
|
state: absent
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable prometheus systemd unit
|
|
|
|
ansible.builtin.service:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: prometheus
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2021-01-21 06:39:44 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove alertmanager data symlink
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: '{{ prometheus_data_dir }}/alertmanager'
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
# (workaround) cephadm adopt prometheus only uses /var/lib/prometheus/metrics/
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Tmp copy the prometheus data
|
|
|
|
ansible.builtin.copy:
|
2020-04-10 05:50:54 +08:00
|
|
|
src: '{{ prometheus_data_dir }}/'
|
|
|
|
dest: /var/lib/prom_metrics
|
|
|
|
owner: 65534
|
|
|
|
group: 65534
|
2024-02-14 18:14:02 +08:00
|
|
|
mode: preserve
|
2020-04-10 05:50:54 +08:00
|
|
|
remote_src: true
|
|
|
|
|
|
|
|
# (workaround) cephadm adopt prometheus only uses /var/lib/prometheus/metrics/
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Restore the prometheus data
|
|
|
|
ansible.builtin.copy:
|
2020-04-10 05:50:54 +08:00
|
|
|
src: /var/lib/prom_metrics/
|
|
|
|
dest: /var/lib/prometheus/metrics
|
|
|
|
owner: 65534
|
|
|
|
group: 65534
|
2024-02-14 18:14:02 +08:00
|
|
|
mode: preserve
|
2020-04-10 05:50:54 +08:00
|
|
|
remote_src: true
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove the tmp prometheus data copy
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: /var/lib/prom_metrics
|
|
|
|
state: absent
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Adopt prometheus daemon
|
2020-12-01 03:32:54 +08:00
|
|
|
cephadm_adopt:
|
2021-03-03 22:43:50 +08:00
|
|
|
name: "prometheus.{{ ansible_facts['hostname'] }}"
|
2020-12-01 03:32:54 +08:00
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
image: "{{ prometheus_container_image }}"
|
|
|
|
docker: "{{ true if container_binary == 'docker' else false }}"
|
|
|
|
pull: false
|
|
|
|
firewalld: "{{ true if configure_firewall | bool else false }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove prometheus systemd unit file
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: /etc/systemd/system/prometheus.service
|
|
|
|
state: absent
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove the legacy prometheus data
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: '{{ prometheus_data_dir }}'
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
# (workaround) cephadm adopt grafana only stops grafana systemd service
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable grafana systemd unit
|
|
|
|
ansible.builtin.service:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: grafana-server
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2021-01-21 06:39:44 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Adopt grafana daemon
|
2020-12-01 03:32:54 +08:00
|
|
|
cephadm_adopt:
|
2021-03-03 22:43:50 +08:00
|
|
|
name: "grafana.{{ ansible_facts['hostname'] }}"
|
2020-12-01 03:32:54 +08:00
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
image: "{{ grafana_container_image }}"
|
|
|
|
docker: "{{ true if container_binary == 'docker' else false }}"
|
|
|
|
pull: false
|
|
|
|
firewalld: "{{ true if configure_firewall | bool else false }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove grafana systemd unit file
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: /etc/systemd/system/grafana-server.service
|
|
|
|
state: absent
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove the legacy grafana data
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: /var/lib/grafana
|
|
|
|
state: absent
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Redeploy node-exporter daemons
|
2020-04-10 05:50:54 +08:00
|
|
|
hosts:
|
|
|
|
- "{{ mon_group_name|default('mons') }}"
|
|
|
|
- "{{ osd_group_name|default('osds') }}"
|
|
|
|
- "{{ mds_group_name|default('mdss') }}"
|
|
|
|
- "{{ rgw_group_name|default('rgws') }}"
|
|
|
|
- "{{ mgr_group_name|default('mgrs') }}"
|
|
|
|
- "{{ rbdmirror_group_name|default('rbdmirrors') }}"
|
2024-06-17 22:35:10 +08:00
|
|
|
- "{{ nfs_group_name|default('nfss') }}"
|
2020-07-25 06:05:41 +08:00
|
|
|
- "{{ monitoring_group_name|default('monitoring') }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: With dashboard enabled
|
2020-04-10 05:50:54 +08:00
|
|
|
when: dashboard_enabled | bool
|
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Stop and disable node-exporter systemd service
|
|
|
|
ansible.builtin.service:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: node_exporter
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2021-01-21 06:39:44 +08:00
|
|
|
failed_when: false
|
2020-04-10 05:50:54 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove node_exporter systemd unit file
|
|
|
|
ansible.builtin.file:
|
2020-04-10 05:50:54 +08:00
|
|
|
path: /etc/systemd/system/node_exporter.service
|
|
|
|
state: absent
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update the placement of node-exporter hosts
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph orch apply node-exporter --placement='*'"
|
2020-04-10 05:50:54 +08:00
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
2020-07-16 06:25:57 +08:00
|
|
|
delegate_to: '{{ groups[mon_group_name][0] }}'
|
2020-04-10 05:50:54 +08:00
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2021-03-17 17:07:27 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Adjust placement daemons
|
2020-07-16 06:25:57 +08:00
|
|
|
hosts: "{{ mon_group_name|default('mons') }}[0]"
|
2020-04-10 05:50:54 +08:00
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-04-10 05:50:54 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-04-10 05:50:54 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update the placement of monitor hosts
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph orch apply mon --placement='{{ groups.get(mon_group_name, []) | length }} label:{{ mon_group_name }}'"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact mgr_placement
|
|
|
|
ansible.builtin.set_fact:
|
2021-06-10 21:12:41 +08:00
|
|
|
mgr_placement_count: "{{ groups.get(mgr_group_name, []) | length if groups.get(mgr_group_name, []) | length > 0 else groups.get(mon_group_name, []) | length }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact mgr_placement_label
|
|
|
|
ansible.builtin.set_fact:
|
2021-06-10 21:12:41 +08:00
|
|
|
mgr_placement_label: "{{ mgr_group_name if groups.get(mgr_group_name, []) | length > 0 else mon_group_name }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update the placement of manager hosts
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph orch apply mgr --placement='{{ mgr_placement_count }} label:{{ mgr_placement_label }}'"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: With dashboard enabled
|
2024-10-02 22:43:39 +08:00
|
|
|
when: dashboard_enabled | bool and groups.get(monitoring_group_name, []) | length > 0
|
2020-04-10 05:50:54 +08:00
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update the placement of alertmanager hosts
|
2024-07-11 17:35:22 +08:00
|
|
|
ceph_orch_apply:
|
|
|
|
fsid: "{{ fsid }}"
|
|
|
|
spec: |
|
|
|
|
service_type: alertmanager
|
|
|
|
service_id: "{{ ansible_facts['hostname'] }}"
|
|
|
|
placement:
|
|
|
|
label: "{{ monitoring_group_name }}"
|
2024-10-02 22:43:39 +08:00
|
|
|
count: "{{ groups.get(monitoring_group_name, []) | length }}"
|
2024-07-11 17:35:22 +08:00
|
|
|
{% if grafana_server_addr is defined %}
|
|
|
|
networks:
|
|
|
|
- {{ grafana_server_addr }}
|
|
|
|
{% endif %}
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2020-04-10 05:50:54 +08:00
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update the placement of grafana hosts
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph orch apply grafana --placement='{{ groups.get(monitoring_group_name, []) | length }} label:{{ monitoring_group_name }}'"
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update the placement of prometheus hosts
|
2024-10-02 22:36:31 +08:00
|
|
|
ceph_orch_apply:
|
|
|
|
fsid: "{{ fsid }}"
|
|
|
|
spec: |
|
|
|
|
service_name: prometheus
|
|
|
|
service_id: "{{ ansible_facts['hostname'] }}"
|
|
|
|
placement:
|
|
|
|
label: {{ monitoring_group_name }}
|
|
|
|
count: {{ groups.get(monitoring_group_name, []) | length }}
|
|
|
|
{% if prometheus_port is defined and prometheus_port != 9095 %}
|
|
|
|
spec:
|
|
|
|
port: {{ prometheus_port }}
|
|
|
|
{% endif %}
|
2020-04-10 05:50:54 +08:00
|
|
|
changed_when: false
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
2020-07-11 02:13:15 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Show ceph orchestrator status
|
2020-07-16 06:25:57 +08:00
|
|
|
hosts: "{{ mon_group_name|default('mons') }}[0]"
|
2020-07-11 02:13:15 +08:00
|
|
|
become: true
|
|
|
|
gather_facts: false
|
2024-02-14 18:14:02 +08:00
|
|
|
any_errors_fatal: true
|
2020-07-11 02:13:15 +08:00
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-defaults role
|
|
|
|
ansible.builtin.import_role:
|
2020-07-11 02:13:15 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Show ceph orchestrator services
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph orch ls --refresh"
|
2020-07-11 02:13:15 +08:00
|
|
|
changed_when: false
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Show ceph orchestrator daemons
|
|
|
|
ansible.builtin.command: "{{ cephadm_cmd }} shell -k /etc/ceph/{{ cluster }}.client.admin.keyring --fsid {{ fsid }} -- ceph orch ps --refresh"
|
2020-07-11 02:13:15 +08:00
|
|
|
changed_when: false
|
|
|
|
environment:
|
|
|
|
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
|
2020-07-16 03:21:25 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Inform users about cephadm
|
|
|
|
ansible.builtin.debug:
|
2020-07-16 03:21:25 +08:00
|
|
|
msg: |
|
|
|
|
This Ceph cluster is now managed by cephadm. Any new changes to the
|
|
|
|
cluster need to be achieved by using the cephadm CLI and you don't
|
|
|
|
need to use ceph-ansible playbooks anymore.
|