2018-12-06 02:59:47 +08:00
|
|
|
---
|
2019-05-14 20:46:25 +08:00
|
|
|
- name: set_fact container_exec_cmd
|
2018-12-06 02:59:47 +08:00
|
|
|
set_fact:
|
2019-05-14 20:46:25 +08:00
|
|
|
container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"
|
2019-05-22 16:02:42 +08:00
|
|
|
when: containerized_deployment | bool
|
2018-12-06 02:59:47 +08:00
|
|
|
|
|
|
|
- name: disable SSL for dashboard
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} config set mgr mgr/dashboard/ssl false"
|
2019-05-14 20:46:25 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-05-15 20:35:24 +08:00
|
|
|
when: dashboard_protocol == "http"
|
2018-12-06 02:59:47 +08:00
|
|
|
|
2019-10-03 03:24:38 +08:00
|
|
|
- name: with SSL for dashboard
|
2018-12-06 02:59:47 +08:00
|
|
|
when: dashboard_protocol == "https"
|
2019-10-03 03:24:38 +08:00
|
|
|
block:
|
|
|
|
- name: enable SSL for dashboard
|
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} config set mgr mgr/dashboard/ssl true"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
2018-12-06 02:59:47 +08:00
|
|
|
|
2019-10-03 03:24:38 +08:00
|
|
|
- name: copy dashboard SSL certificate file
|
|
|
|
copy:
|
|
|
|
src: "{{ dashboard_crt }}"
|
|
|
|
dest: "/etc/ceph/ceph-dashboard.crt"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0440
|
|
|
|
when: dashboard_crt | length > 0
|
2018-12-06 02:59:47 +08:00
|
|
|
|
2019-10-03 03:24:38 +08:00
|
|
|
- name: copy dashboard SSL certificate key
|
|
|
|
copy:
|
|
|
|
src: "{{ dashboard_key }}"
|
|
|
|
dest: "/etc/ceph/ceph-dashboard.key"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0440
|
|
|
|
when: dashboard_key | length > 0
|
2018-12-06 02:59:47 +08:00
|
|
|
|
2019-10-03 03:24:38 +08:00
|
|
|
- name: generate a Self Signed OpenSSL certificate for dashboard
|
|
|
|
shell: |
|
|
|
|
test -f /etc/ceph/ceph-dashboard.key -a -f /etc/ceph/ceph-dashboard.crt || \
|
|
|
|
openssl req -new -nodes -x509 -subj '/O=IT/CN=ceph-dashboard' -days 3650 -keyout /etc/ceph/ceph-dashboard.key -out /etc/ceph/ceph-dashboard.crt -extensions v3_ca
|
|
|
|
when: dashboard_key | length == 0 or dashboard_crt | length == 0
|
2018-12-06 02:59:47 +08:00
|
|
|
|
2019-10-03 03:24:38 +08:00
|
|
|
- name: import dashboard certificate file
|
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} config-key set mgr/dashboard/crt -i /etc/ceph/ceph-dashboard.crt"
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
2018-12-06 02:59:47 +08:00
|
|
|
|
2019-10-03 03:24:38 +08:00
|
|
|
- name: import dashboard certificate key
|
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} config-key set mgr/dashboard/key -i /etc/ceph/ceph-dashboard.key"
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
2018-12-06 02:59:47 +08:00
|
|
|
|
|
|
|
- name: "set the dashboard port ({{ dashboard_port }})"
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} config set mgr mgr/dashboard/server_port {{ dashboard_port }}"
|
2019-07-31 15:51:12 +08:00
|
|
|
changed_when: false
|
2019-05-14 20:46:25 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2018-12-06 02:59:47 +08:00
|
|
|
|
2019-04-05 01:51:16 +08:00
|
|
|
- name: "set the dashboard SSL port ({{ dashboard_port }})"
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} config set mgr mgr/dashboard/ssl_server_port {{ dashboard_port }}"
|
2019-05-14 20:46:25 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-07-31 15:51:12 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false # Do not fail if the option does not exist, it only exists post-14.2.0
|
2019-04-05 01:51:16 +08:00
|
|
|
|
2018-12-06 02:59:47 +08:00
|
|
|
- name: disable mgr dashboard module (restart)
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} mgr module disable dashboard"
|
2019-05-14 20:46:25 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2018-12-06 02:59:47 +08:00
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: enable mgr dashboard module (restart)
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} mgr module enable dashboard"
|
2019-05-14 20:46:25 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2018-12-06 02:59:47 +08:00
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: set or update dashboard admin username and password
|
|
|
|
shell: |
|
2019-10-04 03:47:39 +08:00
|
|
|
if {{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard ac-user-show {{ dashboard_admin_user }}; then
|
|
|
|
{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard ac-user-set-password {{ dashboard_admin_user }} {{ dashboard_admin_password }}
|
2018-12-06 02:59:47 +08:00
|
|
|
else
|
2019-10-04 03:47:39 +08:00
|
|
|
{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard ac-user-create {{ dashboard_admin_user }} {{ dashboard_admin_password }} administrator
|
2018-12-06 02:59:47 +08:00
|
|
|
fi
|
|
|
|
retries: 6
|
|
|
|
delay: 5
|
|
|
|
register: ac_result
|
2019-05-14 20:46:25 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-07-31 15:51:12 +08:00
|
|
|
changed_when: false
|
2018-12-06 02:59:47 +08:00
|
|
|
until: ac_result.rc == 0
|
|
|
|
|
|
|
|
- name: set grafana url
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-grafana-api-url {{ dashboard_protocol }}://{{ grafana_server_addr }}:{{ grafana_port }}"
|
2019-05-14 20:46:25 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2018-12-06 02:59:47 +08:00
|
|
|
changed_when: false
|
|
|
|
|
2019-10-31 17:49:22 +08:00
|
|
|
- name: set grafana api user
|
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-grafana-api-username {{ grafana_admin_user }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: set grafana api password
|
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-grafana-api-password {{ grafana_admin_password }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
|
|
|
|
2018-12-06 02:59:47 +08:00
|
|
|
- name: set alertmanager host
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-alertmanager-api-host {{ dashboard_protocol }}://{{ grafana_server_addr }}:{{ alertmanager_port }}"
|
2019-09-27 00:56:10 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: set prometheus host
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-prometheus-api-host {{ dashboard_protocol }}://{{ grafana_server_addr }}:{{ prometheus_port }}"
|
2019-05-14 20:46:25 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2018-12-06 02:59:47 +08:00
|
|
|
changed_when: false
|
|
|
|
|
2019-07-11 22:38:44 +08:00
|
|
|
- name: dashboard object gateway management frontend
|
|
|
|
when: groups.get(rgw_group_name, []) | length > 0
|
|
|
|
block:
|
|
|
|
- name: create radosgw system user
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "timeout --foreground -s KILL 20 {{ container_exec_cmd }} radosgw-admin --cluster {{ cluster }} user create --uid={{ dashboard_rgw_api_user_id }} --display-name='Ceph dashboard' --system"
|
2019-07-11 22:38:44 +08:00
|
|
|
register: rgw_user_output
|
|
|
|
until: rgw_user_output.rc == 0
|
|
|
|
retries: 3
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-07-11 22:38:44 +08:00
|
|
|
|
|
|
|
- name: get the rgw access and secret keys
|
|
|
|
set_fact:
|
|
|
|
rgw_access_key: "{{ (rgw_user_output.stdout | from_json)['keys'][0]['access_key'] }}"
|
|
|
|
rgw_secret_key: "{{ (rgw_user_output.stdout | from_json)['keys'][0]['secret_key'] }}"
|
|
|
|
|
|
|
|
- name: set the rgw user
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-rgw-api-user-id {{ dashboard_rgw_api_user_id }}"
|
2019-07-11 22:38:44 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-07-11 22:38:44 +08:00
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: set the rgw access key
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-rgw-api-access-key {{ rgw_access_key }}"
|
2019-07-11 22:38:44 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-07-11 22:38:44 +08:00
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: set the rgw secret key
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-rgw-api-secret-key {{ rgw_secret_key }}"
|
2019-07-11 22:38:44 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-07-11 22:38:44 +08:00
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: set the rgw host
|
2019-10-03 02:15:45 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-rgw-api-host {{ hostvars[groups[rgw_group_name][0]]['rgw_instances'][0]['radosgw_address'] }}"
|
2019-07-11 22:38:44 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-07-11 22:38:44 +08:00
|
|
|
|
|
|
|
- name: set the rgw port
|
2019-10-03 02:15:45 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-rgw-api-port {{ hostvars[groups[rgw_group_name][0]]['rgw_instances'][0]['radosgw_frontend_port'] }}"
|
2019-07-11 22:38:44 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-07-11 22:38:44 +08:00
|
|
|
|
|
|
|
- name: set the rgw scheme
|
2019-10-03 02:15:45 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-rgw-api-scheme {{ 'https' if radosgw_frontend_ssl_certificate else 'http' }}"
|
2019-07-11 22:38:44 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-07-11 22:38:44 +08:00
|
|
|
|
|
|
|
- name: set the rgw admin resource
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-rgw-api-admin-resource {{ dashboard_rgw_api_admin_resource }}"
|
2019-07-11 22:38:44 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-10-10 03:39:04 +08:00
|
|
|
when: dashboard_rgw_api_admin_resource | length > 0
|
2019-07-11 22:38:44 +08:00
|
|
|
|
|
|
|
- name: disable ssl verification for rgw
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-rgw-api-ssl-verify False"
|
2019-07-11 22:38:44 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2019-10-03 02:15:45 +08:00
|
|
|
when:
|
|
|
|
- dashboard_rgw_api_no_ssl_verify | bool
|
|
|
|
- radosgw_frontend_ssl_certificate | length > 0
|
2018-12-06 02:59:47 +08:00
|
|
|
|
2019-10-22 03:45:19 +08:00
|
|
|
- name: dashboard iscsi management
|
|
|
|
when: groups.get(iscsi_gw_group_name, []) | length > 0
|
|
|
|
block:
|
|
|
|
- name: disable iscsi api ssl verification
|
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-iscsi-api-ssl-verification false"
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
|
|
|
when:
|
|
|
|
- api_secure | default(false) | bool
|
|
|
|
- generate_crt | default(false) | bool
|
|
|
|
|
2020-01-08 04:01:48 +08:00
|
|
|
- name: add iscsi gateways - ipv4
|
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard iscsi-gateway-add {{ 'https' if hostvars[item]['api_secure'] | default(false) | bool else 'http' }}://{{ hostvars[item]['api_user'] | default('admin') }}:{{ hostvars[item]['api_password'] | default('admin') }}@{{ hostvars[item]['ansible_all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | first }}:{{ hostvars[item]['api_port'] | default(5000) }}"
|
2019-10-22 03:45:19 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
with_items: "{{ groups[iscsi_gw_group_name] }}"
|
|
|
|
run_once: true
|
2020-01-08 04:01:48 +08:00
|
|
|
when: ip_version == 'ipv4'
|
|
|
|
|
|
|
|
- name: add iscsi gateways - ipv6
|
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard iscsi-gateway-add {{ 'https' if hostvars[item]['api_secure'] | default(false) | bool else 'http' }}://{{ hostvars[item]['api_user'] | default('admin') }}:{{ hostvars[item]['api_password'] | default('admin') }}@{{ hostvars[item]['ansible_all_ipv6_addresses'] | ips_in_ranges(public_network.split(',')) | last | ipwrap }}:{{ hostvars[item]['api_port'] | default(5000) }}"
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
with_items: "{{ groups[iscsi_gw_group_name] }}"
|
|
|
|
run_once: true
|
|
|
|
when: ip_version == 'ipv6'
|
2019-10-22 03:45:19 +08:00
|
|
|
|
dashboard: update layouts before the restart
If the mgr dashboard doesn't restart fast enough then the inject
dashboard task will fail with a HTTP error 400.
Error EINVAL: Traceback (most recent call last):
File "/usr/share/ceph/mgr/mgr_module.py", line 914, in _handle_command
return self.handle_command(inbuf, cmd)
File "/usr/share/ceph/mgr/dashboard/module.py", line 450, in handle_command
push_local_dashboards()
File "/usr/share/ceph/mgr/dashboard/grafana.py", line 132, in push_local_dashboards
retry()
File "/usr/share/ceph/mgr/dashboard/grafana.py", line 89, in call
result = self.func(*self.args, **self.kwargs)
File "/usr/share/ceph/mgr/dashboard/grafana.py", line 127, in push
grafana.push_dashboard(body)
File "/usr/share/ceph/mgr/dashboard/grafana.py", line 54, in push_dashboard
response.raise_for_status()
File "/usr/lib/python2.7/site-packages/requests/models.py", line 834, in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 400 Client Error: Bad Request
Instead we can trigger this task before the module restart.
Closes: #4565
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
2019-10-08 21:54:06 +08:00
|
|
|
- name: inject grafana dashboard layouts
|
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard grafana dashboards update"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: true
|
|
|
|
changed_when: false
|
|
|
|
when: containerized_deployment | bool
|
|
|
|
|
2018-12-06 02:59:47 +08:00
|
|
|
- name: disable mgr dashboard module (restart)
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} mgr module disable dashboard"
|
2018-12-06 02:59:47 +08:00
|
|
|
changed_when: false
|
2019-05-14 20:46:25 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|
2018-12-06 02:59:47 +08:00
|
|
|
|
|
|
|
- name: enable mgr dashboard module (restart)
|
2019-10-04 03:47:39 +08:00
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} mgr module enable dashboard"
|
2018-12-06 02:59:47 +08:00
|
|
|
changed_when: false
|
2019-05-14 20:46:25 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-08-02 22:58:11 +08:00
|
|
|
run_once: true
|