---
- name: start and add that the rbd mirror service to the init sequence (ubuntu)
  command: initctl emit ceph-rbd-mirror cluster={{ cluster }} id={{ ansible_hostname }}
  changed_when: false
  failed_when: false
  when: ansible_distribution == "Ubuntu"

# NOTE (leseb): somehow the service ansible module is messing things up
# as a safety measure we run the raw command
- name: start and add that the rbd mirror service to the init sequence
  command: service ceph start ceph-rbd-mirror
  changed_when: false
  when:
    ansible_distribution != "Ubuntu" and
    is_before_infernalis

- name: enable systemd unit file for the rbd mirror service (for or after infernalis)
  file:
    src: /usr/lib/systemd/system/ceph-rbd-mirror@.service
    dest: "/etc/systemd/system/multi-user.target.wants/ceph-rbd-mirror@{{ ceph_rbd_mirror_local_user }}.service"
    state: link
  changed_when: false
  failed_when: false
  when:
    ansible_distribution != "Ubuntu" and
    is_after_hammer

- name: start and add that the rbd mirror service to the init sequence (for or after infernalis)
  service:
      name: "ceph-rbd-mirror@{{ ceph_rbd_mirror_local_user }}"
      state: started
      enabled: yes
  changed_when: false
  when:
    ansible_distribution != "Ubuntu" and
    is_after_hammer

---
- name: start and add that the rbd mirror service to the init sequence (upstart)
  command: initctl emit ceph-rbd-mirror cluster={{ cluster }} id={{ ansible_hostname }}
  changed_when: false
  failed_when: false
  when: not use_systemd

# NOTE (leseb): somehow the service ansible module is messing things up
# as a safety measure we run the raw command
- name: start and add that the rbd mirror service to the init sequence (systemd before infernalis)
  command: service ceph start ceph-rbd-mirror
  changed_when: false
  when:
    use_systemd and
    is_before_infernalis

- name: enable systemd unit file for the rbd mirror service (systemd after hammer)
  file:
    src: /usr/lib/systemd/system/ceph-rbd-mirror@.service
    dest: "/etc/systemd/system/multi-user.target.wants/ceph-rbd-mirror@{{ ceph_rbd_mirror_local_user }}.service"
    state: link
  changed_when: false
  failed_when: false
  when:
    use_systemd and
    is_after_hammer

- name: start and add that the rbd mirror service to the init sequence (systemd after hammer)
  service:
      name: "ceph-rbd-mirror@{{ ceph_rbd_mirror_local_user }}"
      state: started
      enabled: yes
  changed_when: false
  when:
    use_systemd and
    is_after_hammer

Use the use_systemd fact when starting rbd
Use the use_systemd fact when starting rbd

Signed-off-by: Andrew Schoen <1bb641dc23c3a93cce4eee683bcf4b2bea7903a3@redhat.com>
