ansible-ceph/roles/ceph-osd/tasks/main.yml
2026-04-06 07:08:17 +03:00

102 lines
3.4 KiB
YAML

---
- name: Set_fact add_osd
ansible.builtin.set_fact:
add_osd: "{{ groups[osd_group_name] | length != ansible_play_hosts_all | length }}"
- name: Set_fact container_exec_cmd
ansible.builtin.set_fact:
container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[item]['ansible_facts']['hostname'] }}"
with_items: "{{ groups.get(mon_group_name, []) }}"
delegate_to: "{{ item }}"
delegate_facts: true
run_once: true
when: containerized_deployment | bool
- name: Include_tasks system_tuning.yml
ansible.builtin.include_tasks: system_tuning.yml
- name: Install dependencies
ansible.builtin.package:
name: parted
state: present
register: result
until: result is succeeded
when:
- not containerized_deployment | bool
- ansible_facts['os_family'] != 'ClearLinux'
- name: Install numactl when needed
ansible.builtin.package:
name: numactl
register: result
until: result is succeeded
when:
- containerized_deployment | bool
- ceph_osd_numactl_opts | length > 0
tags: with_pkg
- name: Include_tasks common.yml
ansible.builtin.include_tasks: common.yml
- name: Set noup flag
ceph_osd_flag:
name: noup
cluster: "{{ cluster }}"
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] }}"
run_once: true
when:
- not rolling_update | default(False) | bool
- not switch_to_containers | default(False) | bool
- name: Include_tasks scenarios/lvm.yml
ansible.builtin.include_tasks: scenarios/lvm.yml
when:
- lvm_volumes|length > 0
- not rolling_update|default(False) | bool
- name: Include_tasks scenarios/lvm-batch.yml
ansible.builtin.include_tasks: scenarios/lvm-batch.yml
when:
- devices|length > 0
- not rolling_update|default(False) | bool
- name: Include_tasks start_osds.yml
ansible.builtin.include_tasks: start_osds.yml
- name: Unset noup flag
ceph_osd_flag:
name: noup
cluster: "{{ cluster }}"
state: absent
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] }}"
when:
- not rolling_update | default(False) | bool
- not switch_to_containers | default(False) | bool
- inventory_hostname == ansible_play_hosts_all | last
- name: Wait for all osd to be up
ansible.builtin.command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd stat -f json"
register: wait_for_all_osds_up
retries: "{{ nb_retry_wait_osd_up }}"
delay: "{{ delay_wait_osd_up }}"
changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}"
until:
- (wait_for_all_osds_up.stdout | from_json)["num_osds"] | int > 0
- (wait_for_all_osds_up.stdout | from_json)["num_osds"] == (wait_for_all_osds_up.stdout | from_json)["num_up_osds"]
when:
- not ansible_check_mode
- inventory_hostname == ansible_play_hosts_all | last
tags: wait_all_osds_up
- name: Include crush_rules.yml
ansible.builtin.include_tasks: crush_rules.yml
when: hostvars[groups[mon_group_name][0]]['crush_rule_config'] | default(crush_rule_config) | bool
tags: wait_all_osds_up