---
- name: get ceph version
  command: ceph --version
  changed_when: false
  always_run: yes
  register: ceph_version

- name: is ceph running already?
  command: ceph --connect-timeout 3 --cluster {{ cluster }} fsid
  changed_when: false
  failed_when: false
  always_run: yes
  register: ceph_current_fsid
  delegate_to: "{{ groups.mons[0] }}"

- set_fact:
    fsid: "{{ ceph_current_fsid.stdout }}"
  when: ceph_current_fsid.rc == 0

- set_fact:
    ceph_version: "{{ ceph_version.stdout.split(' ')[2] }}"

# NOTE(mattt): On ansible 2.x we can use ansible_service_mgr instead
- name: check init system
  slurp:
    src: /proc/1/comm
  always_run: yes
  register: init_system

- set_fact:
    init_system={{ init_system.content | b64decode | trim }}

- set_fact:
    use_systemd={{ init_system.strip() == 'systemd' }}

- set_fact:
    mds_name: "{{ ansible_hostname }}"
  when: not mds_use_fqdn

- set_fact:
    mds_name: "{{ ansible_fqdn }}"
  when: mds_use_fqdn

---
- name: get ceph version
  command: ceph --version
  changed_when: false
  always_run: yes
  register: ceph_version

- name: is ceph running already?
  command: ceph --connect-timeout 3 --cluster {{ cluster }} fsid
  changed_when: false
  failed_when: false
  always_run: yes
  register: ceph_current_fsid
  delegate_to: "{{ groups[mon_group_name][0] }}"

- set_fact:
    fsid: "{{ ceph_current_fsid.stdout }}"
  when: ceph_current_fsid.rc == 0

- set_fact:
    ceph_version: "{{ ceph_version.stdout.split(' ')[2] }}"

# NOTE(mattt): On ansible 2.x we can use ansible_service_mgr instead
- name: check init system
  slurp:
    src: /proc/1/comm
  always_run: yes
  register: init_system

- set_fact:
    init_system={{ init_system.content | b64decode | trim }}

- set_fact:
    use_systemd={{ init_system.strip() == 'systemd' }}

- set_fact:
    mds_name: "{{ ansible_hostname }}"
  when: not mds_use_fqdn

- set_fact:
    mds_name: "{{ ansible_fqdn }}"
  when: mds_use_fqdn

Fix the mons running check to use group name var
Fix the mons running check to use group name var

mon_group_name variable can be used to override mons group, but
this task assumes the group is always 'mons'. So we need to use
the var to find the group name instead.
