]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Move basics facts to `ceph-defaults`
authorGuillaume Abrioux <gabrioux@redhat.com>
Fri, 28 Jul 2017 21:02:51 +0000 (23:02 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Wed, 2 Aug 2017 15:12:20 +0000 (17:12 +0200)
Move `fsid`,`monitor_name`,`docker_exec_cmd` and `ceph_release` set_fact
to `ceph-defaults` role.
It will allow to reuse these facts without having to play `ceph-common`
or `ceph-docker-common`.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
roles/ceph-common/tasks/facts.yml [deleted file]
roles/ceph-common/tasks/generate_cluster_fsid.yml [deleted file]
roles/ceph-common/tasks/main.yml
roles/ceph-common/tasks/release.yml [deleted file]
roles/ceph-defaults/tasks/facts.yml [new file with mode: 0644]
roles/ceph-defaults/tasks/main.yml [new file with mode: 0644]
roles/ceph-mon/tasks/docker/main.yml

diff --git a/roles/ceph-common/tasks/facts.yml b/roles/ceph-common/tasks/facts.yml
deleted file mode 100644 (file)
index 2056ce9..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
----
-- name: get ceph version
-  command: ceph --version
-  changed_when: false
-  always_run: yes
-  register: ceph_version
-
-# this task shouldn't run in a rolling_update situation
-# because it blindly picks a mon, which may be down because
-# of the rolling update
-- 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] }}"
-  when: not rolling_update
-
-# set this as a default when performing a rolling_update
-# so the rest of the tasks here will succeed
-- set_fact:
-    ceph_current_fsid:
-      rc: 1
-  when: rolling_update
-
-- name: create a local fetch directory if it does not exist
-  local_action: file path={{ fetch_directory }} state=directory
-  changed_when: false
-  become: false
-  run_once: true
-  when: cephx or generate_fsid
-
-- set_fact:
-    fsid: "{{ ceph_current_fsid.stdout }}"
-  when:
-    - ceph_current_fsid.rc == 0
-
-- set_fact:
-    monitor_name: "{{ ansible_hostname }}"
-  when: not mon_use_fqdn
-
-- set_fact:
-    monitor_name: "{{ ansible_fqdn }}"
-  when: mon_use_fqdn
-
-# We want this check to be run only on one mon
-- name: check if {{ fetch_directory }} directory exists
-  local_action: stat path="{{ fetch_directory }}/monitor_keyring.conf"
-  become: false
-  register: monitor_keyring_conf
-  run_once: true
-
-- include: facts_mon_fsid.yml
-  run_once: true
-  when:
-    - cephx
-    - not monitor_keyring_conf.stat.exists
-    - ceph_current_fsid.rc == 0
-    - mon_group_name in group_names
-
-- set_fact:
-    ceph_version: "{{ ceph_version.stdout.split(' ')[2] }}"
-
-- set_fact:
-    mds_name: "{{ ansible_hostname }}"
-  when: not mds_use_fqdn
-
-- set_fact:
-    mds_name: "{{ ansible_fqdn }}"
-  when: mds_use_fqdn
-
-- set_fact:
-    rbd_client_directory_owner: ceph
-  when:
-    - rbd_client_directory_owner is not defined
-      or not rbd_client_directory_owner
-
-- set_fact:
-    rbd_client_directory_group: ceph
-  when:
-    - rbd_client_directory_group is not defined
-      or not rbd_client_directory_group
-
-- set_fact:
-    rbd_client_directory_mode: "0770"
-  when:
-    - rbd_client_directory_mode is not defined
-      or not rbd_client_directory_mode
diff --git a/roles/ceph-common/tasks/generate_cluster_fsid.yml b/roles/ceph-common/tasks/generate_cluster_fsid.yml
deleted file mode 100644 (file)
index 5f49612..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
----
-- name: generate cluster fsid
-  local_action: shell python -c 'import uuid; print(str(uuid.uuid4()))' | tee {{ fetch_directory }}/ceph_cluster_uuid.conf
-    creates="{{ fetch_directory }}/ceph_cluster_uuid.conf"
-  register: cluster_uuid
-  become: false
-  when:
-    - generate_fsid
-    - ceph_current_fsid.rc != 0
-
-- name: reuse cluster fsid when cluster is already running
-  local_action: shell echo {{ fsid }} | tee {{ fetch_directory }}/ceph_cluster_uuid.conf
-    creates="{{ fetch_directory }}/ceph_cluster_uuid.conf"
-  become: false
-  when: ceph_current_fsid.rc == 0
-
-- name: read cluster fsid if it already exists
-  local_action: command cat {{ fetch_directory }}/ceph_cluster_uuid.conf
-    removes="{{ fetch_directory }}/ceph_cluster_uuid.conf"
-  changed_when: false
-  register: cluster_uuid
-  become: false
-  always_run: true
-  when: generate_fsid
-
-- name: set fsid fact when generate_fsid = true
-  set_fact:
-    fsid: "{{ cluster_uuid.stdout }}"
-  when: generate_fsid
index 71b482cbae7e2e8bd115a19d073e622c237c759e..b2c1a0e3f271b96acd427c7d83780f0acb9543eb 100644 (file)
@@ -2,11 +2,6 @@
 - include: ./checks/check_system.yml
 - include: ./checks/check_mandatory_vars.yml
 
-# Set ceph_release
-- include: ./release.yml
-  tags:
-    - always
-
 - include: ./checks/check_firewall.yml
   when: check_firewall
   # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent)
   # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent)
   static: False
 
-- include: facts.yml
+- name: get ceph version
+  command: ceph --version
+  changed_when: false
+  always_run: yes
+  register: ceph_version
+
+- set_fact:
+    ceph_version: "{{ ceph_version.stdout.split(' ')[2] }}"
+
+- include: facts_mon_fsid.yml
+  run_once: true
+  when:
+    - cephx
+    - not monitor_keyring_conf.stat.exists
+    - ceph_current_fsid.rc == 0
+    - mon_group_name in group_names
+
 - include: ./checks/check_socket.yml
 - include: create_ceph_initial_dirs.yml
-- include: generate_cluster_fsid.yml
 - include: generate_ceph_conf.yml
 - include: create_rbd_client_dir.yml
 - include: configure_cluster_name.yml
diff --git a/roles/ceph-common/tasks/release.yml b/roles/ceph-common/tasks/release.yml
deleted file mode 100644 (file)
index f3e33a3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
----
-# Set ceph_release to ceph_stable by default
-- set_fact:
-    ceph_release: "{{ ceph_stable_release }}"
diff --git a/roles/ceph-defaults/tasks/facts.yml b/roles/ceph-defaults/tasks/facts.yml
new file mode 100644 (file)
index 0000000..d650259
--- /dev/null
@@ -0,0 +1,110 @@
+---
+- set_fact:
+    monitor_name: "{{ ansible_hostname }}"
+  when: not mon_use_fqdn
+
+- set_fact:
+    monitor_name: "{{ ansible_fqdn }}"
+  when: mon_use_fqdn
+
+# this task shouldn't run in a rolling_update situation
+# because it blindly picks a mon, which may be down because
+# of the rolling update
+- 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] }}"
+  when: not rolling_update
+
+# We want this check to be run only on the first node
+- name: check if {{ fetch_directory }} directory exists
+  local_action: stat path="{{ fetch_directory }}/monitor_keyring.conf"
+  become: false
+  register: monitor_keyring_conf
+  run_once: true
+
+# set this as a default when performing a rolling_update
+# so the rest of the tasks here will succeed
+- set_fact:
+    ceph_current_fsid:
+      rc: 1
+  when: rolling_update
+
+- name: create a local fetch directory if it does not exist
+  local_action: file path={{ fetch_directory }} state=directory
+  changed_when: false
+  become: false
+  run_once: true
+  when: cephx or generate_fsid
+
+- set_fact:
+    fsid: "{{ ceph_current_fsid.stdout }}"
+  when:
+    - ceph_current_fsid.rc == 0
+
+# Set ceph_release to ceph_stable by default
+- set_fact:
+    ceph_release: "{{ ceph_stable_release }}"
+
+- name: generate cluster fsid
+  local_action: shell python -c 'import uuid; print(str(uuid.uuid4()))' | tee {{ fetch_directory }}/ceph_cluster_uuid.conf
+    creates="{{ fetch_directory }}/ceph_cluster_uuid.conf"
+  register: cluster_uuid
+  become: false
+  when:
+    - generate_fsid
+    - ceph_current_fsid.rc != 0
+
+- name: reuse cluster fsid when cluster is already running
+  local_action: shell echo {{ fsid }} | tee {{ fetch_directory }}/ceph_cluster_uuid.conf
+    creates="{{ fetch_directory }}/ceph_cluster_uuid.conf"
+  become: false
+  when: ceph_current_fsid.rc == 0
+
+- name: read cluster fsid if it already exists
+  local_action: command cat {{ fetch_directory }}/ceph_cluster_uuid.conf
+    removes="{{ fetch_directory }}/ceph_cluster_uuid.conf"
+  changed_when: false
+  register: cluster_uuid
+  become: false
+  always_run: true
+  when: generate_fsid
+
+- name: set fsid fact when generate_fsid = true
+  set_fact:
+    fsid: "{{ cluster_uuid.stdout }}"
+  when: generate_fsid
+
+- name: set docker_exec_cmd fact
+  set_fact:
+    docker_exec_cmd: "docker exec ceph-mon-{{ ansible_hostname }}"
+  when: containerized_deployment
+
+- set_fact:
+    mds_name: "{{ ansible_hostname }}"
+  when: not mds_use_fqdn
+
+- set_fact:
+    mds_name: "{{ ansible_fqdn }}"
+  when: mds_use_fqdn
+
+- set_fact:
+    rbd_client_directory_owner: ceph
+  when:
+    - rbd_client_directory_owner is not defined
+      or not rbd_client_directory_owner
+
+- set_fact:
+    rbd_client_directory_group: ceph
+  when:
+    - rbd_client_directory_group is not defined
+      or not rbd_client_directory_group
+
+- set_fact:
+    rbd_client_directory_mode: "0770"
+  when:
+    - rbd_client_directory_mode is not defined
+      or not rbd_client_directory_mode
diff --git a/roles/ceph-defaults/tasks/main.yml b/roles/ceph-defaults/tasks/main.yml
new file mode 100644 (file)
index 0000000..1634648
--- /dev/null
@@ -0,0 +1,2 @@
+---
+- include: facts.yml
index f7d073d9de1e9d63d55142da78ddce760dd86386..1b5291526a7cd7fa90045118e9a665fcdd8edfc0 100644 (file)
@@ -1,8 +1,4 @@
 ---
-- name: set docker_exec_cmd fact
-  set_fact:
-    docker_exec_cmd: "docker exec ceph-mon-{{ ansible_hostname }}"
-
 - include: start_docker_monitor.yml
 
 - name: wait for monitor socket to exist