--- - name: collect admin and bootstrap keys (for or after kraken release) command: ceph-create-keys --cluster {{ cluster }} -i {{ monitor_name }} args: creates: /etc/ceph/{{ cluster }}.client.admin.keyring failed_when: false changed_when: false always_run: true when: - cephx # NOTE (leseb): wait for mon discovery and quorum resolution # the admin key is not instantaneously created so we have to wait a bit - name: "wait for {{ cluster }}.client.admin.keyring exists" wait_for: path: /etc/ceph/{{ cluster }}.client.admin.keyring when: cephx - name: test if initial mon keyring is in mon kv store command: ceph --cluster {{ cluster }} config-key get initial_mon_keyring changed_when: false ignore_errors: true always_run: true run_once: true register: is_initial_mon_keyring_in_kv - name: put initial mon keyring in mon kv store command: ceph --cluster {{ cluster }} config-key put initial_mon_keyring {{ monitor_keyring.stdout }} changed_when: false always_run: true run_once: true when: - is_initial_mon_keyring_in_kv.rc != 0 - cephx - name: create ceph rest api keyring when mon is not containerized command: ceph --cluster {{ cluster }} auth get-or-create client.restapi osd 'allow *' mon 'allow *' -o /etc/ceph/{{ cluster }}.client.restapi.keyring args: creates: /etc/ceph/{{ cluster }}.client.restapi.keyring changed_when: false when: - cephx - groups[restapi_group_name] is defined # NOTE(leseb): we add a conditional for backward compatibility # so people that had 'pool_default_pg_num' declared will get # the same behaviour # - name: check if does global key exist in ceph_conf_overrides set_fact: global_in_ceph_conf_overrides: "{{ 'global' in ceph_conf_overrides }}" - name: check if ceph_conf_overrides.global.osd_pool_default_pg_num is set set_fact: osd_pool_default_pg_num_in_overrides: "{{ 'osd_pool_default_pg_num' in ceph_conf_overrides.global }}" when: global_in_ceph_conf_overrides - name: get default value for osd_pool_default_pg_num shell: | ceph --cluster {{ cluster }} daemon mon.{{ monitor_name }} config get osd_pool_default_pg_num | grep -Po '(?<="osd_pool_default_pg_num": ")[^"]*' failed_when: false changed_when: false run_once: true register: default_pool_default_pg_num when: (pool_default_pg_num is not defined or not global_in_ceph_conf_overrides) - set_fact: osd_pool_default_pg_num: "{{ pool_default_pg_num }}" when: pool_default_pg_num is defined - set_fact: osd_pool_default_pg_num: "{{ default_pool_default_pg_num.stdout }}" when: - pool_default_pg_num is not defined - default_pool_default_pg_num.rc == 0 - ceph_conf_overrides.global.osd_pool_default_pg_num is not defined - set_fact: osd_pool_default_pg_num: "{{ ceph_conf_overrides.global.osd_pool_default_pg_num }}" when: ceph_conf_overrides.global.osd_pool_default_pg_num is defined - name: test if rbd exists command: ceph --cluster {{ cluster }} osd pool stats rbd changed_when: false failed_when: false register: rbd_pool_exist - include: rbd_pool.yml when: rbd_pool_exist.rc == 0 - include: rbd_pool_pgs.yml when: - rbd_pool_exist.rc == 0 - ceph_conf_overrides.global.osd_pool_default_pg_num is defined - include: rbd_pool_size.yml when: - rbd_pool_exist.rc == 0 - ceph_conf_overrides.global.osd_pool_default_size is defined - include: openstack_config.yml when: openstack_config - name: find ceph keys shell: ls -1 /etc/ceph/*.keyring changed_when: false register: ceph_keys always_run: true when: cephx - name: set keys permissions file: path: "{{ item }}" owner: "ceph" group: "ceph" mode: "0600" with_items: - "{{ ceph_keys.get('stdout_lines') | default([]) }}" when: cephx - name: copy keys to the ansible server fetch: src: "{{ item }}" dest: "{{ fetch_directory }}/{{ fsid }}/{{ item }}" flat: yes run_once: true with_items: - "{{ ceph_keys.get('stdout_lines') | default([]) }}" - /var/lib/ceph/bootstrap-osd/{{ cluster }}.keyring - /var/lib/ceph/bootstrap-rgw/{{ cluster }}.keyring - /var/lib/ceph/bootstrap-mds/{{ cluster }}.keyring when: cephx - name: drop in a motd script to report status when logging in copy: src: precise/92-ceph dest: /etc/update-motd.d/92-ceph owner: root group: root mode: 0755 when: ansible_distribution_release == 'precise'