|
| 1 | +--- |
| 2 | +- name: Gather Ceph configuration and keys and populate kayobe-config |
| 3 | + gather_facts: false |
| 4 | + hosts: mons |
| 5 | + run_once: true |
| 6 | + tags: |
| 7 | + - cephadm |
| 8 | + - cephadm-gather-keys |
| 9 | + vars: |
| 10 | + # Map from an OpenStack service to the directory in which to store Ceph keys for it. |
| 11 | + kolla_service_to_key_dir: |
| 12 | + cinder-backup: cinder/cinder-backup |
| 13 | + cinder-volume: cinder/cinder-volume |
| 14 | + glance: glance |
| 15 | + manila: manila |
| 16 | + nova: nova |
| 17 | + # Map from an OpenStack service to the directory in which to store Ceph configuration for it. |
| 18 | + kolla_service_to_conf_dir: |
| 19 | + cinder-backup: cinder |
| 20 | + cinder-volume: cinder |
| 21 | + glance: glance |
| 22 | + manila: manila |
| 23 | + nova: nova |
| 24 | + tasks: |
| 25 | + - name: Get Ceph keys |
| 26 | + stackhpc.cephadm.cephadm_key: |
| 27 | + name: "{{ item }}" |
| 28 | + state: info |
| 29 | + register: cephadm_key_info |
| 30 | + become: true |
| 31 | + loop: "{{ kolla_ceph_services | selectattr('required') | map(attribute='keys') | flatten | unique }}" |
| 32 | + |
| 33 | + - name: Generate ceph.conf |
| 34 | + command: "cephadm shell -- ceph config generate-minimal-conf" |
| 35 | + become: true |
| 36 | + register: cephadm_ceph_conf |
| 37 | + changed_when: false |
| 38 | + |
| 39 | + - name: Ensure Kolla config directories are present |
| 40 | + file: |
| 41 | + state: directory |
| 42 | + path: "{{ kayobe_env_config_path }}/kolla/config/{{ kolla_service_to_key_dir[item.name] }}" |
| 43 | + loop: "{{ kolla_ceph_services | selectattr('required') }}" |
| 44 | + loop_control: |
| 45 | + label: |
| 46 | + service: "{{ item.name }}" |
| 47 | + delegate_to: localhost |
| 48 | + |
| 49 | + - name: Save Ceph keys to Kayobe configuration |
| 50 | + vars: |
| 51 | + key_info: "{{ cephadm_key_info.results | selectattr('item', 'equalto', item.1) | first }}" |
| 52 | + cephadm_key: "{{ (key_info.stdout | from_json | first)['key'] }}" |
| 53 | + cephadm_user: "{{ (key_info.stdout | from_json | first)['entity'] }}" |
| 54 | + copy: |
| 55 | + content: "{{ cephadm_key }}" |
| 56 | + dest: "{{ kayobe_env_config_path }}/kolla/config/{{ kolla_service_to_key_dir[item.0.name] }}/ceph.{{ cephadm_user }}.keyring" |
| 57 | + loop: "{{ query('subelements', kolla_ceph_services | selectattr('required'), 'keys') }}" |
| 58 | + loop_control: |
| 59 | + label: |
| 60 | + service: "{{ item.0.name }}" |
| 61 | + key: "{{ item.1 }}" |
| 62 | + delegate_to: localhost |
| 63 | + notify: Please add and commit the Kayobe configuration |
| 64 | + |
| 65 | + - name: Save ceph.conf to Kayobe configuration |
| 66 | + copy: |
| 67 | + content: "{{ cephadm_ceph_conf.stdout }}" |
| 68 | + dest: "{{ kayobe_env_config_path }}/kolla/config/{{ kolla_service_to_conf_dir[item.0.name] }}/ceph.conf" |
| 69 | + loop: "{{ query('subelements', kolla_ceph_services | selectattr('required'), 'keys') }}" |
| 70 | + loop_control: |
| 71 | + label: |
| 72 | + service: "{{ item.0.name }}" |
| 73 | + key: "{{ item.1 }}" |
| 74 | + delegate_to: localhost |
| 75 | + notify: Please add and commit the Kayobe configuration |
| 76 | + |
| 77 | + handlers: |
| 78 | + - name: Please add and commit the Kayobe configuration |
| 79 | + debug: |
| 80 | + msg: >- |
| 81 | + Please add and commit the Ceph configuration files and keys in Kayobe |
| 82 | + configuration. Remember to encrypt the keys using Ansible Vault. |
0 commit comments