|
249 | 249 | run_once: true
|
250 | 250 | delegate_to: '{{ groups[mon_group_name][0] }}'
|
251 | 251 |
|
252 |
| - - name: generate cephadm ssh key |
| 252 | + - name: check if there is an existing ssh keypair |
| 253 | + stat: |
| 254 | + path: "{{ item }}" |
| 255 | + loop: |
| 256 | + - "{{ cephadm_ssh_priv_key_path }}" |
| 257 | + - "{{ cephadm_ssh_pub_key_path }}" |
| 258 | + register: ssh_keys |
| 259 | + changed_when: false |
| 260 | + run_once: true |
| 261 | + delegate_to: '{{ groups[mon_group_name][0] }}' |
| 262 | + |
| 263 | + - name: set fact |
| 264 | + set_fact: |
| 265 | + stat_ssh_key_pair: "{{ ssh_keys.results | map(attribute='stat.exists') | list }}" |
| 266 | + |
| 267 | + - name: fail if either ssh public or private key is missing |
| 268 | + fail: |
| 269 | + msg: "One part of the ssh keypair of user {{ cephadm_ssh_user }} is missing" |
| 270 | + when: |
| 271 | + - false in stat_ssh_key_pair |
| 272 | + - true in stat_ssh_key_pair |
| 273 | + |
| 274 | + - name: generate cephadm ssh key if there is none |
253 | 275 | command: "{{ ceph_cmd }} cephadm generate-key"
|
| 276 | + when: not true in stat_ssh_key_pair |
254 | 277 | changed_when: false
|
255 | 278 | run_once: true
|
256 | 279 | delegate_to: '{{ groups[mon_group_name][0] }}'
|
257 | 280 |
|
| 281 | + - name: use existing user keypair for remote connections |
| 282 | + when: not false in stat_ssh_key_pair |
| 283 | + delegate_to: "{{ groups[mon_group_name][0] }}" |
| 284 | + run_once: true |
| 285 | + command: > |
| 286 | + {{ container_binary + ' run --rm --net=host --security-opt label=disable |
| 287 | + -v /etc/ceph:/etc/ceph:z |
| 288 | + -v /var/lib/ceph:/var/lib/ceph:ro |
| 289 | + -v /var/run/ceph:/var/run/ceph:z |
| 290 | + -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' }} |
| 291 | + --cluster {{ cluster }} config-key set mgr/cephadm/ssh_identity_{{ item.0 }} -i /etc/ceph/cephadm.{{ item.0 }} |
| 292 | + with_together: |
| 293 | + - [ 'pub', 'key' ] |
| 294 | + - [ '{{ cephadm_ssh_pub_key_path }}', '{{ cephadm_ssh_priv_key_path }}' ] |
| 295 | + |
258 | 296 | - name: get the cephadm ssh pub key
|
259 | 297 | command: "{{ ceph_cmd }} cephadm get-pub-key"
|
260 | 298 | changed_when: false
|
261 | 299 | run_once: true
|
262 | 300 | register: cephadm_pubpkey
|
263 | 301 | delegate_to: '{{ groups[mon_group_name][0] }}'
|
264 | 302 |
|
265 |
| - - name: allow cephadm key for {{ cephadm_ssh_user | default('root') }} account |
| 303 | + - name: allow cephadm key for {{ cephadm_ssh_user }} account |
266 | 304 | authorized_key:
|
267 |
| - user: "{{ cephadm_ssh_user | default('root') }}" |
| 305 | + user: "{{ cephadm_ssh_user }}" |
268 | 306 | key: '{{ cephadm_pubpkey.stdout }}'
|
269 | 307 |
|
270 |
| - - name: set cephadm ssh user to {{ cephadm_ssh_user | default('root') }} |
271 |
| - command: "{{ ceph_cmd }} cephadm set-user {{ cephadm_ssh_user | default('root') }}" |
| 308 | + - name: set cephadm ssh user to {{ cephadm_ssh_user }} |
| 309 | + command: "{{ ceph_cmd }} cephadm set-user {{ cephadm_ssh_user }}" |
272 | 310 | changed_when: false
|
273 | 311 | run_once: true
|
274 | 312 | delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
323 | 361 | when: is_hci | bool
|
324 | 362 |
|
325 | 363 | - name: manage nodes with cephadm - ipv4
|
326 |
| - command: "{{ ceph_cmd }} orch host add {{ ansible_facts['nodename'] }} {{ ansible_facts['all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | first }} {{ group_names | join(' ') }}" |
| 364 | + 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(' ') }}" |
327 | 365 | changed_when: false
|
328 | 366 | delegate_to: '{{ groups[mon_group_name][0] }}'
|
329 | 367 | when: ip_version == 'ipv4'
|
330 | 368 |
|
331 | 369 | - name: manage nodes with cephadm - ipv6
|
332 |
| - 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(' ') }}" |
| 370 | + 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(' ') }}" |
333 | 371 | changed_when: false
|
334 | 372 | delegate_to: '{{ groups[mon_group_name][0] }}'
|
335 | 373 | when: ip_version == 'ipv6'
|
|
0 commit comments