Skip to content

Commit 6d407c1

Browse files
committed
Fix delegation issue
When adding OSDs for a host not in the mons group, I discovered that the commands were not run on the delegated host (the first mon) but on the host with the OSDs to add. This can cause issues as cephadm may not be configured correctly on this host.
1 parent 4414131 commit 6d407c1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

roles/cephadm/tasks/osds.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
# We need to register this as a variable, otherwise it will not be interpreted
3+
# correctly when setting ansible_host in the next task.
4+
- name: Set a fact about the Ansible host
5+
set_fact:
6+
mon_ansible_host: "{{ hostvars[inventory_hostname].ansible_host }}"
27

38
- name: Add OSDs individually
49
command:
@@ -14,4 +19,4 @@
1419
vars:
1520
# NOTE: Without this, the delegate hosts's ansible_host variable will not
1621
# be respected.
17-
ansible_host: "{{ hostvars[inventory_hostname].ansible_host if 'mons' in group_names else hostvars[groups['mons'][0]].ansible_host }}"
22+
ansible_host: "{{ mon_ansible_host if 'mons' in group_names else hostvars[groups['mons'][0]].ansible_host }}"

0 commit comments

Comments
 (0)