From f8aa8cdf60af6f315941629ec2a40d2edf2c7fd9 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Tue, 8 Jan 2019 10:57:51 +0100 Subject: [PATCH] facts: clean fsid generation code clean some leftover and duplicate code. Signed-off-by: Guillaume Abrioux --- roles/ceph-config/tasks/main.yml | 27 ------------------ roles/ceph-facts/tasks/facts.yml | 49 +++++++++++--------------------- 2 files changed, 16 insertions(+), 60 deletions(-) diff --git a/roles/ceph-config/tasks/main.yml b/roles/ceph-config/tasks/main.yml index 62fb1a2cf..e867a7297 100644 --- a/roles/ceph-config/tasks/main.yml +++ b/roles/ceph-config/tasks/main.yml @@ -133,28 +133,6 @@ - ((inventory_hostname in groups.get(mon_group_name, [])) or (groups.get(nfs_group_name, []) | length > 0) and inventory_hostname == groups.get(nfs_group_name, [])[0]) - - name: generate cluster uuid - shell: python -c 'import uuid; print(str(uuid.uuid4()))' | tee {{ fetch_directory }}/ceph_cluster_uuid.conf - args: - creates: "{{ fetch_directory }}/ceph_cluster_uuid.conf" - delegate_to: localhost - register: cluster_uuid - become: false - when: - - generate_fsid - - - name: read cluster uuid if it already exists - command: "cat {{ fetch_directory }}/ceph_cluster_uuid.conf" - args: - removes: "{{ fetch_directory }}/ceph_cluster_uuid.conf" - delegate_to: localhost - changed_when: false - register: cluster_uuid - check_mode: no - become: false - when: - - generate_fsid - - name: "generate {{ cluster }}.conf configuration file" action: config_template args: @@ -173,10 +151,5 @@ - restart ceph mgrs - restart ceph rbdmirrors - - name: set fsid fact when generate_fsid = true - set_fact: - fsid: "{{ cluster_uuid.stdout }}" - when: - - generate_fsid when: - containerized_deployment|bool diff --git a/roles/ceph-facts/tasks/facts.yml b/roles/ceph-facts/tasks/facts.yml index 3973797fc..aad7e8405 100644 --- a/roles/ceph-facts/tasks/facts.yml +++ b/roles/ceph-facts/tasks/facts.yml @@ -22,6 +22,11 @@ container_binary: "{{ 'podman' if is_podman and ansible_distribution == 'Fedora' else 'docker' }}" when: containerized_deployment +# Set ceph_release to ceph_stable by default +- name: set_fact ceph_release ceph_stable_release + set_fact: + ceph_release: "{{ ceph_stable_release }}" + - name: set_fact monitor_name ansible_hostname set_fact: monitor_name: "{{ ansible_hostname }}" @@ -98,43 +103,21 @@ when: - ceph_current_status.fsid is defined -- name: generate cluster fsid - shell: python -c 'import uuid; print(str(uuid.uuid4()))' | tee {{ fetch_directory }}/ceph_cluster_uuid.conf - args: - creates: "{{ fetch_directory }}/ceph_cluster_uuid.conf" - register: cluster_uuid - delegate_to: localhost - become: false - when: - - generate_fsid - - ceph_current_status.fsid is undefined - -- name: reuse cluster fsid when cluster is already running - shell: echo {{ fsid }} | tee {{ fetch_directory }}/ceph_cluster_uuid.conf - args: - creates: "{{ fetch_directory }}/ceph_cluster_uuid.conf" - delegate_to: localhost - become: false - when: - - ceph_current_status.fsid is defined +- block: + - name: generate cluster fsid + shell: python -c 'import uuid; print(str(uuid.uuid4()))' + register: cluster_uuid + delegate_to: localhost + become: false + run_once: true -- name: read cluster fsid if it already exists - command: cat {{ fetch_directory }}/ceph_cluster_uuid.conf - args: - removes: "{{ fetch_directory }}/ceph_cluster_uuid.conf" - delegate_to: localhost - changed_when: false - register: cluster_uuid - become: false - check_mode: no - when: - - generate_fsid + - name: set_fact fsid + set_fact: + fsid: "{{ cluster_uuid.stdout }}" -- name: set_fact fsid - set_fact: - fsid: "{{ cluster_uuid.stdout }}" when: - generate_fsid + - ceph_current_status.fsid is undefined - name: set_fact mds_name ansible_hostname set_fact: -- 2.39.5