|
213 | 213 | run_once: true
|
214 | 214 | delegate_to: '{{ groups[mon_group_name][0] }}'
|
215 | 215 |
|
216 |
| - - name: generate cephadm ssh key |
| 216 | + - name: check if there is an existing ssh keypair |
| 217 | + stat: |
| 218 | + path: "{{ item }}" |
| 219 | + loop: |
| 220 | + - "{{ cephadm_ssh_priv_key_path }}" |
| 221 | + - "{{ cephadm_ssh_pub_key_path }}" |
| 222 | + register: ssh_keys |
| 223 | + changed_when: false |
| 224 | + run_once: true |
| 225 | + delegate_to: '{{ groups[mon_group_name][0] }}' |
| 226 | + |
| 227 | + - name: set fact |
| 228 | + set_fact: |
| 229 | + stat_ssh_key_pair: "{{ ssh_keys.results | map(attribute='stat.exists') | list }}" |
| 230 | + |
| 231 | + - name: fail if either ssh public or private key is missing |
| 232 | + fail: |
| 233 | + msg: "One part of the ssh keypair of user {{ cephadm_ssh_user }} is missing" |
| 234 | + when: |
| 235 | + - false in stat_ssh_key_pair |
| 236 | + - true in stat_ssh_key_pair |
| 237 | + |
| 238 | + - name: generate cephadm ssh key if there is none |
217 | 239 | command: "{{ ceph_cmd }} cephadm generate-key"
|
| 240 | + when: not true in stat_ssh_key_pair |
218 | 241 | changed_when: false
|
219 | 242 | run_once: true
|
220 | 243 | delegate_to: '{{ groups[mon_group_name][0] }}'
|
221 | 244 |
|
| 245 | + - name: use existing user keypair for remote connections |
| 246 | + when: not false in stat_ssh_key_pair |
| 247 | + delegate_to: "{{ groups[mon_group_name][0] }}" |
| 248 | + run_once: true |
| 249 | + command: > |
| 250 | + {{ container_binary + ' run --rm --net=host --security-opt label=disable |
| 251 | + -v /etc/ceph:/etc/ceph:z |
| 252 | + -v /var/lib/ceph:/var/lib/ceph:ro |
| 253 | + -v /var/run/ceph:/var/run/ceph:z |
| 254 | + -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' }} |
| 255 | + --cluster {{ cluster }} config-key set mgr/cephadm/ssh_identity_{{ item.0 }} -i /etc/ceph/cephadm.{{ item.0 }} |
| 256 | + with_together: |
| 257 | + - [ 'pub', 'key' ] |
| 258 | + - [ '{{ cephadm_ssh_pub_key_path }}', '{{ cephadm_ssh_priv_key_path }}' ] |
| 259 | + |
222 | 260 | - name: get the cephadm ssh pub key
|
223 | 261 | command: "{{ ceph_cmd }} cephadm get-pub-key"
|
224 | 262 | changed_when: false
|
225 | 263 | run_once: true
|
226 | 264 | register: cephadm_pubpkey
|
227 | 265 | delegate_to: '{{ groups[mon_group_name][0] }}'
|
228 | 266 |
|
229 |
| - - name: allow cephadm key for {{ cephadm_ssh_user | default('root') }} account |
| 267 | + - name: allow cephadm key for {{ cephadm_ssh_user }} account |
230 | 268 | authorized_key:
|
231 |
| - user: "{{ cephadm_ssh_user | default('root') }}" |
| 269 | + user: "{{ cephadm_ssh_user }}" |
232 | 270 | key: '{{ cephadm_pubpkey.stdout }}'
|
233 | 271 |
|
234 |
| - - name: set cephadm ssh user to {{ cephadm_ssh_user | default('root') }} |
235 |
| - command: "{{ ceph_cmd }} cephadm set-user {{ cephadm_ssh_user | default('root') }}" |
| 272 | + - name: set cephadm ssh user to {{ cephadm_ssh_user }} |
| 273 | + command: "{{ ceph_cmd }} cephadm set-user {{ cephadm_ssh_user }}" |
236 | 274 | changed_when: false
|
237 | 275 | run_once: true
|
238 | 276 | delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
287 | 325 | when: is_hci | bool
|
288 | 326 |
|
289 | 327 | - name: manage nodes with cephadm - ipv4
|
290 |
| - command: "{{ ceph_cmd }} orch host add {{ ansible_facts['nodename'] }} {{ ansible_facts['all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | first }} {{ group_names | join(' ') }}" |
| 328 | + command: "{{ ceph_cmd }} orch host add {{ ansible_facts['nodename'] }} {{ ansible_facts['all_ipv4_addresses'] | ips_in_ranges(cephadm_mgmt_network.split(',')) | first }} {{ group_names | join(' ') }}" |
291 | 329 | changed_when: false
|
292 | 330 | delegate_to: '{{ groups[mon_group_name][0] }}'
|
293 | 331 | when: ip_version == 'ipv4'
|
294 | 332 |
|
295 | 333 | - name: manage nodes with cephadm - ipv6
|
296 |
| - command: "{{ ceph_cmd }} orch host add {{ ansible_facts['nodename'] }} {{ ansible_facts['all_ipv6_addresses'] | ips_in_ranges(public_network.split(',')) | last | ipwrap }} {{ group_names | join(' ') }}" |
| 334 | + command: "{{ ceph_cmd }} orch host add {{ ansible_facts['nodename'] }} {{ ansible_facts['all_ipv6_addresses'] | ips_in_ranges(cephadm_mgmt_network.split(',')) | last | ipwrap }} {{ group_names | join(' ') }}" |
297 | 335 | changed_when: false
|
298 | 336 | delegate_to: '{{ groups[mon_group_name][0] }}'
|
299 | 337 | when: ip_version == 'ipv6'
|
|
0 commit comments