ceph-dashboard: Add run_once on delegate tasks

Because we need to execute commands from a monitor node (the first one
in the mons list) we are using delegate_to option.
If there's multiple nodes running the ceph-dashboard role then the
delegated task will be executed multiple times.
Also remove a mgr config-key option not present for nautilus+ releases.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
pull/4315/head
Dimitri Savineau 2019-08-02 10:58:11 -04:00 committed by Guillaume Abrioux
parent 5ee3d96fb4
commit f545b5be0d
1 changed files with 24 additions and 5 deletions

View File

@ -7,11 +7,13 @@
- name: disable SSL for dashboard - name: disable SSL for dashboard
command: "{{ container_exec_cmd }} ceph config set mgr mgr/dashboard/ssl false" command: "{{ container_exec_cmd }} ceph config set mgr mgr/dashboard/ssl false"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
when: dashboard_protocol == "http" when: dashboard_protocol == "http"
- name: enable SSL for dashboard - name: enable SSL for dashboard
command: "{{ container_exec_cmd }} ceph config set mgr mgr/dashboard/ssl true" command: "{{ container_exec_cmd }} ceph config set mgr mgr/dashboard/ssl true"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
when: dashboard_protocol == "https" when: dashboard_protocol == "https"
- name: copy dashboard SSL certificate file - name: copy dashboard SSL certificate file
@ -48,33 +50,36 @@
command: "{{ container_exec_cmd }} ceph config-key set mgr/dashboard/crt -i /etc/ceph/ceph-dashboard.crt" command: "{{ container_exec_cmd }} ceph config-key set mgr/dashboard/crt -i /etc/ceph/ceph-dashboard.crt"
changed_when: false changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
when: dashboard_protocol == "https" when: dashboard_protocol == "https"
- name: import dashboard certificate key - name: import dashboard certificate key
command: "{{ container_exec_cmd }} ceph config-key set mgr/dashboard/key -i /etc/ceph/ceph-dashboard.key" command: "{{ container_exec_cmd }} ceph config-key set mgr/dashboard/key -i /etc/ceph/ceph-dashboard.key"
changed_when: false changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
when: dashboard_protocol == "https" when: dashboard_protocol == "https"
- name: "set the dashboard port ({{ dashboard_port }})" - name: "set the dashboard port ({{ dashboard_port }})"
shell: | command: "{{ container_exec_cmd }} ceph config set mgr mgr/dashboard/server_port {{ dashboard_port }}"
{{ container_exec_cmd }} ceph config set mgr mgr/dashboard/server_port {{ dashboard_port }} || \
{{ container_exec_cmd }} ceph config-key set mgr/dashboard/server_port {{ dashboard_port }}
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
- name: "set the dashboard SSL port ({{ dashboard_port }})" - name: "set the dashboard SSL port ({{ dashboard_port }})"
command: "{{ container_exec_cmd }} ceph config set mgr mgr/dashboard/ssl_server_port {{ dashboard_port }}" # Do not use the old fashioned config-key way ssl_server_port, it was not supported when this option was introduced command: "{{ container_exec_cmd }} ceph config set mgr mgr/dashboard/ssl_server_port {{ dashboard_port }}"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
failed_when: false # Do not fail if the option does not exist, it only exists post-14.2.0 run_once: true
- name: disable mgr dashboard module (restart) - name: disable mgr dashboard module (restart)
command: "{{ container_exec_cmd }} ceph mgr module disable dashboard" command: "{{ container_exec_cmd }} ceph mgr module disable dashboard"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
changed_when: false changed_when: false
- name: enable mgr dashboard module (restart) - name: enable mgr dashboard module (restart)
command: "{{ container_exec_cmd }} ceph mgr module enable dashboard" command: "{{ container_exec_cmd }} ceph mgr module enable dashboard"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
changed_when: false changed_when: false
- name: set or update dashboard admin username and password - name: set or update dashboard admin username and password
@ -88,16 +93,19 @@
delay: 5 delay: 5
register: ac_result register: ac_result
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
until: ac_result.rc == 0 until: ac_result.rc == 0
- name: set grafana url - name: set grafana url
command: "{{ container_exec_cmd }} ceph dashboard set-grafana-api-url {{ dashboard_protocol }}://{{ dashboard_url }}:{{ grafana_port }}/" command: "{{ container_exec_cmd }} ceph dashboard set-grafana-api-url {{ dashboard_protocol }}://{{ dashboard_url }}:{{ grafana_port }}/"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
changed_when: false changed_when: false
- name: set alertmanager host - name: set alertmanager host
command: "{{ container_exec_cmd }} ceph dashboard set-alertmanager-api-host {{ dashboard_protocol }}://{{ dashboard_url }}:{{ alertmanager_port }}/" command: "{{ container_exec_cmd }} ceph dashboard set-alertmanager-api-host {{ dashboard_protocol }}://{{ dashboard_url }}:{{ alertmanager_port }}/"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
changed_when: false changed_when: false
- name: dashboard object gateway management frontend - name: dashboard object gateway management frontend
@ -109,6 +117,7 @@
until: rgw_user_output.rc == 0 until: rgw_user_output.rc == 0
retries: 3 retries: 3
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
- name: get the rgw access and secret keys - name: get the rgw access and secret keys
set_fact: set_fact:
@ -118,54 +127,64 @@
- name: set the rgw user - name: set the rgw user
command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-user-id {{ dashboard_rgw_api_user_id }}" command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-user-id {{ dashboard_rgw_api_user_id }}"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
changed_when: false changed_when: false
- name: set the rgw access key - name: set the rgw access key
command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-access-key {{ rgw_access_key }}" command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-access-key {{ rgw_access_key }}"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
changed_when: false changed_when: false
- name: set the rgw secret key - name: set the rgw secret key
command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-secret-key {{ rgw_secret_key }}" command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-secret-key {{ rgw_secret_key }}"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
changed_when: false changed_when: false
- name: set the rgw host - name: set the rgw host
command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-host {{ dashboard_rgw_api_host }}" command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-host {{ dashboard_rgw_api_host }}"
changed_when: false changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
when: dashboard_rgw_api_host != '' when: dashboard_rgw_api_host != ''
- name: set the rgw port - name: set the rgw port
command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-port {{ dashboard_rgw_api_port }}" command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-port {{ dashboard_rgw_api_port }}"
changed_when: false changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
when: dashboard_rgw_api_port != '' when: dashboard_rgw_api_port != ''
- name: set the rgw scheme - name: set the rgw scheme
command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-scheme {{ dashboard_rgw_api_scheme }}" command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-scheme {{ dashboard_rgw_api_scheme }}"
changed_when: false changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
when: dashboard_rgw_api_scheme != '' when: dashboard_rgw_api_scheme != ''
- name: set the rgw admin resource - name: set the rgw admin resource
command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-admin-resource {{ dashboard_rgw_api_admin_resource }}" command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-admin-resource {{ dashboard_rgw_api_admin_resource }}"
changed_when: false changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
when: dashboard_rgw_api_admin_resource != '' when: dashboard_rgw_api_admin_resource != ''
- name: disable ssl verification for rgw - name: disable ssl verification for rgw
command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-ssl-verify False" command: "{{ container_exec_cmd }} ceph dashboard set-rgw-api-ssl-verify False"
changed_when: false changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
when: dashboard_rgw_api_no_ssl_verify | bool when: dashboard_rgw_api_no_ssl_verify | bool
- name: disable mgr dashboard module (restart) - name: disable mgr dashboard module (restart)
command: "{{ container_exec_cmd }} ceph mgr module disable dashboard" command: "{{ container_exec_cmd }} ceph mgr module disable dashboard"
changed_when: false changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
- name: enable mgr dashboard module (restart) - name: enable mgr dashboard module (restart)
command: "{{ container_exec_cmd }} ceph mgr module enable dashboard" command: "{{ container_exec_cmd }} ceph mgr module enable dashboard"
changed_when: false changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true