From 43135840b1570d35314eee3115c2ec826cff4d8d Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Fri, 28 Jun 2019 10:39:38 -0400 Subject: [PATCH] dashboard: move code into a dedicated playbook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move dashboard, grafana/prometheus and node-exporter plays into a dedicated playbook in infrastructure-playbook directory. To avoid using 'dashboard_enabled | bool' condition multiple time in the main playbook we can just import the dashboard playbook or not. This patch also allows to use an unique dashboard playbook for both baremetal and container playbooks. Signed-off-by: Dimitri Savineau --- infrastructure-playbooks/dashboard.yml | 99 ++++++++++++++++++++++ site-container.yml.sample | 110 ++---------------------- site.yml.sample | 113 +------------------------ 3 files changed, 108 insertions(+), 214 deletions(-) create mode 100644 infrastructure-playbooks/dashboard.yml diff --git a/infrastructure-playbooks/dashboard.yml b/infrastructure-playbooks/dashboard.yml new file mode 100644 index 000000000..496311980 --- /dev/null +++ b/infrastructure-playbooks/dashboard.yml @@ -0,0 +1,99 @@ +--- +- hosts: all + become: true + pre_tasks: + - name: set ceph node exporter install 'In Progress' + run_once: true + set_stats: + data: + installer_phase_ceph_node_exporter: + status: "In Progress" + start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" + + tasks: + - block: + - import_role: + name: ceph-defaults + tags: ['ceph_update_config'] + - import_role: + name: ceph-facts + tags: ['ceph_update_config'] + - import_role: + name: ceph-container-engine + - import_role: + name: ceph-node-exporter + + post_tasks: + - name: set ceph node exporter install 'Complete' + run_once: true + set_stats: + data: + installer_phase_ceph_node_exporter: + status: "Complete" + end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" + +- hosts: '{{ groups["grafana-server"][0] | default(groups["mgrs"][0]) | default(groups["mons"][0]) | default(omit) }}' + become: true + pre_tasks: + - name: set ceph grafana install 'In Progress' + run_once: true + set_stats: + data: + installer_phase_ceph_grafana: + status: "In Progress" + start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" + + tasks: + - block: + - import_role: + name: ceph-defaults + tags: ['ceph_update_config'] + - import_role: + name: ceph-facts + tags: ['ceph_update_config'] + - import_role: + name: ceph-container-engine + - import_role: + name: ceph-prometheus + - import_role: + name: ceph-grafana + + post_tasks: + - name: set ceph grafana install 'Complete' + run_once: true + set_stats: + data: + installer_phase_ceph_grafana: + status: "Complete" + end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" + +- hosts: '{{ groups["mgrs"][0] | default(groups["mons"][0]) | default(omit) }}' + become: true + pre_tasks: + - name: set ceph dashboard install 'In Progress' + run_once: true + set_stats: + data: + installer_phase_ceph_dashboard: + status: "In Progress" + start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" + + tasks: + - block: + - import_role: + name: ceph-defaults + tags: ['ceph_update_config'] + - import_role: + name: ceph-facts + tags: ['ceph_update_config'] + - import_role: + name: ceph-dashboard + + post_tasks: + - name: set ceph dashboard install 'Complete' + run_once: true + set_stats: + data: + installer_phase_ceph_dashboard: + status: "Complete" + end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" diff --git a/site-container.yml.sample b/site-container.yml.sample index d38c5c970..d88a8dc56 100644 --- a/site-container.yml.sample +++ b/site-container.yml.sample @@ -105,9 +105,6 @@ name: ceph-container-engine - import_role: name: ceph-container-common - - import_role: - name: ceph-node-exporter - when: dashboard_enabled | bool - import_role: name: ceph-config tags: ['ceph_update_config'] @@ -154,9 +151,6 @@ name: ceph-container-engine - import_role: name: ceph-container-common - - import_role: - name: ceph-node-exporter - when: dashboard_enabled | bool - import_role: name: ceph-config tags: ['ceph_update_config'] @@ -198,9 +192,6 @@ name: ceph-container-engine - import_role: name: ceph-container-common - - import_role: - name: ceph-node-exporter - when: dashboard_enabled | bool - import_role: name: ceph-config tags: ['ceph_update_config'] @@ -242,9 +233,6 @@ name: ceph-container-engine - import_role: name: ceph-container-common - - import_role: - name: ceph-node-exporter - when: dashboard_enabled | bool - import_role: name: ceph-config tags: ['ceph_update_config'] @@ -286,9 +274,6 @@ name: ceph-container-engine - import_role: name: ceph-container-common - - import_role: - name: ceph-node-exporter - when: dashboard_enabled | bool - import_role: name: ceph-config tags: ['ceph_update_config'] @@ -330,9 +315,6 @@ name: ceph-container-engine - import_role: name: ceph-container-common - - import_role: - name: ceph-node-exporter - when: dashboard_enabled | bool - import_role: name: ceph-config tags: ['ceph_update_config'] @@ -374,9 +356,6 @@ name: ceph-container-engine - import_role: name: ceph-container-common - - import_role: - name: ceph-node-exporter - when: dashboard_enabled | bool - import_role: name: ceph-config tags: ['ceph_update_config'] @@ -416,13 +395,10 @@ name: ceph-handler - import_role: name: ceph-container-engine - when: inventory_hostname == groups.get('clients', ['']) | first or dashboard_enabled + when: inventory_hostname == groups.get('clients', ['']) | first - import_role: name: ceph-container-common when: inventory_hostname == groups.get('clients', ['']) | first - - import_role: - name: ceph-node-exporter - when: dashboard_enabled | bool - import_role: name: ceph-config tags: ['ceph_update_config'] @@ -466,9 +442,6 @@ name: ceph-container-engine - import_role: name: ceph-container-common - - import_role: - name: ceph-node-exporter - when: dashboard_enabled | bool - import_role: name: ceph-config tags: ['ceph_update_config'] @@ -517,80 +490,7 @@ run_once: true when: not ceph_status.failed -- hosts: '{{ groups["grafana-server"][0] | default(groups["mgrs"][0]) | default(groups["mons"][0]) | default(omit) }}' - become: true - pre_tasks: - - name: set ceph grafana install 'In Progress' - run_once: true - set_stats: - data: - installer_phase_ceph_grafana: - status: "In Progress" - start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" - when: dashboard_enabled | bool - - tasks: - - block: - - import_role: - name: ceph-defaults - tags: ['ceph_update_config'] - - import_role: - name: ceph-facts - tags: ['ceph_update_config'] - - import_role: - name: ceph-handler - - import_role: - name: ceph-container-engine - - import_role: - name: ceph-container-common - - import_role: - name: ceph-node-exporter - - import_role: - name: ceph-config - tags: ['ceph_update_config'] - - import_role: - name: ceph-prometheus - - import_role: - name: ceph-grafana - when: dashboard_enabled | bool - - post_tasks: - - name: set ceph grafana install 'Complete' - run_once: true - set_stats: - data: - installer_phase_ceph_grafana: - status: "Complete" - end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" - when: dashboard_enabled | bool - -- hosts: '{{ groups["mgrs"][0] | default(groups["mons"][0]) | default(omit) }}' - become: true - pre_tasks: - - name: set ceph dashboard install 'In Progress' - run_once: true - set_stats: - data: - installer_phase_ceph_dashboard: - status: "In Progress" - start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" - when: dashboard_enabled | bool - - tasks: - - block: - - import_role: - name: ceph-defaults - tags: ['ceph_update_config'] - - import_role: - name: ceph-dashboard - when: dashboard_enabled | bool - - post_tasks: - - name: set ceph dashboard install 'Complete' - run_once: true - set_stats: - data: - installer_phase_ceph_dashboard: - status: "Complete" - end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" - when: dashboard_enabled | bool +- import_playbook: infrastructure-playbooks/dashboard.yml + when: + - dashboard_enabled | bool + - groups.get(grafana_server_group_name, []) | length > 0 diff --git a/site.yml.sample b/site.yml.sample index 3ca4f1f60..fbf534b5d 100644 --- a/site.yml.sample +++ b/site.yml.sample @@ -481,112 +481,7 @@ run_once: true when: not ceph_status.failed -- hosts: all - become: true - pre_tasks: - - name: set ceph node exporter install 'In Progress' - run_once: true - set_stats: - data: - installer_phase_ceph_node_exporter: - status: "In Progress" - start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" - when: dashboard_enabled | bool - - tasks: - - block: - - import_role: - name: ceph-defaults - - import_role: - name: ceph-facts - - import_role: - name: ceph-handler - - import_role: - name: ceph-container-engine - - import_role: - name: ceph-node-exporter - when: dashboard_enabled | bool - - post_tasks: - - name: set ceph node exporter install 'Complete' - run_once: true - set_stats: - data: - installer_phase_ceph_node_exporter: - status: "Complete" - end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" - when: dashboard_enabled | bool - -- hosts: '{{ groups["grafana-server"][0] | default(groups["mgrs"][0]) | default(groups["mons"][0]) | default(omit) }}' - become: true - pre_tasks: - - name: set ceph grafana install 'In Progress' - run_once: true - set_stats: - data: - installer_phase_ceph_grafana: - status: "In Progress" - start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" - when: dashboard_enabled | bool - - tasks: - - block: - - import_role: - name: ceph-defaults - tags: ['ceph_update_config'] - - import_role: - name: ceph-facts - tags: ['ceph_update_config'] - - import_role: - name: ceph-handler - - import_role: - name: ceph-common - - import_role: - name: ceph-config - tags: ['ceph_update_config'] - - import_role: - name: ceph-prometheus - - import_role: - name: ceph-grafana - when: dashboard_enabled | bool - - post_tasks: - - name: set ceph grafana install 'Complete' - run_once: true - set_stats: - data: - installer_phase_ceph_grafana: - status: "Complete" - end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" - when: dashboard_enabled | bool - -- hosts: '{{ groups["mgrs"][0] | default(groups["mons"][0]) | default(omit) }}' - become: true - pre_tasks: - - name: set ceph dashboard install 'In Progress' - run_once: true - set_stats: - data: - installer_phase_ceph_dashboard: - status: "In Progress" - start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" - when: dashboard_enabled | bool - - tasks: - - block: - - import_role: - name: ceph-defaults - tags: ['ceph_update_config'] - - import_role: - name: ceph-dashboard - when: dashboard_enabled | bool - - post_tasks: - - name: set ceph dashboard install 'Complete' - run_once: true - set_stats: - data: - installer_phase_ceph_dashboard: - status: "Complete" - end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" - when: dashboard_enabled | bool +- import_playbook: infrastructure-playbooks/dashboard.yml + when: + - dashboard_enabled | bool + - groups.get(grafana_server_group_name, []) | length > 0