Fix osd monitors ip address
Since we are defining the monmap based
on the ceph public network, we should
build ceph.conf on osd nodes that points
to the correct ip addresses instead of
the host default ipv4.
Sem-Ver: fixes
Change-Id: I5df4d28391c67bb4e6862dac8464281fc0e8e4bc
diff --git a/releasenotes/notes/fix_osd_mon_hosts-aa7bd5fa08241131.yaml b/releasenotes/notes/fix_osd_mon_hosts-aa7bd5fa08241131.yaml
new file mode 100644
index 0000000..5b718d6
--- /dev/null
+++ b/releasenotes/notes/fix_osd_mon_hosts-aa7bd5fa08241131.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+ - |
+ Since we define the monmap based on the
+ ceph public network, we should build ceph.conf
+ for osd with the correct ip addresses.
\ No newline at end of file
diff --git a/roles/ceph_osd/tasks/main.yml b/roles/ceph_osd/tasks/main.yml
index 0ea9046..e67a6b6 100644
--- a/roles/ceph_osd/tasks/main.yml
+++ b/roles/ceph_osd/tasks/main.yml
@@ -23,13 +23,17 @@
changed_when: false
ansible.builtin.command: ceph fsid
-- name: collect facts for all monitors
- delegate_to: "{{ item }}"
- delegate_facts: true
- ansible.builtin.setup:
- gather_subset: network
- loop: "{{ groups[ceph_osd_mons_group] }}"
- when: inventory_hostname == ansible_play_hosts_all[0]
+- name: Collect "ceph mon dump" output from a monitor
+ delegate_to: "{{ groups[ceph_osd_mons_group][0] }}"
+ run_once: true
+ ansible.builtin.command: ceph mon dump -f json
+ changed_when: false
+ register: _ceph_mon_dump
+
+- name: Generate fact with list of Ceph monitors
+ run_once: true
+ ansible.builtin.set_fact:
+ ceph_monitors: "{{ _ceph_mon_dump.stdout | from_json | community.general.json_query('mons[*].addr') | map('regex_replace', '(.*):(.*)', '\\1') }}"
- name: generate basic configuration file
community.general.ini_file:
@@ -44,7 +48,7 @@
- option: fsid
value: "{{ _ceph_fsid.stdout | trim }}"
- option: mon host
- value: "{{ groups[ceph_osd_mons_group] | map('extract', hostvars, ['ansible_default_ipv4', 'address']) | join(',') }}"
+ value: "{{ ceph_monitors | join(',') }}"
- name: grab bootstrap-osd from monitors
delegate_to: "{{ groups[ceph_osd_mons_group][0] }}"