---
- name: Getting ceph mgr keyring
  kolla_ceph_keyring:
    name: "mgr.{{ item }}"
    caps: "{{ ceph_client_mgr_keyring_caps }}"
  register: ceph_mgr_keyring
  run_once: true
  delegate_to: "{{ groups['ceph-mon'][0] }}"
  with_items: "{{ groups['ceph-mgr'] }}"

- name: Pushing ceph mgr keyring to ceph-mgr
  become: true
  copy:
    content: |
      [mgr.{{ item.item }}]
          key = {{ item.keyring.key }}
    dest: "{{ node_config_directory }}/ceph-mgr/ceph.mgr.{{ inventory_hostname }}.keyring"
    mode: 0600
  when:
    - inventory_hostname == item.item
  with_items: "{{ ceph_mgr_keyring.results }}"

- name: Starting ceph-mgr container
  become: true
  kolla_docker:
    action: "start_container"
    common_options: "{{ docker_common_options }}"
    image: "{{ ceph_mgr_image_full }}"
    name: "ceph_mgr"
    volumes:
      - "{{ node_config_directory }}/ceph-mgr/:{{ container_config_directory }}/:ro"
      - "/etc/localtime:/etc/localtime:ro"
      - "kolla_logs:/var/log/kolla"
