blob: 9aa17994470a0b87f1b61ce13073e240dacf06f5 [file] [log] [blame]
mjedynski982f2472020-05-20 02:26:24 +02001{%- from "ceph/map.jinja" import common, mgr, setup with context %}
Ondrej Smola91c83162017-09-12 16:40:02 +02002
3{%- if mgr.get('enabled', False) %}
4
Mateusz Los45531fa2020-02-13 15:32:44 +01005{%- if common.version in ['nautilus'] %}
6enable_msgr2_protocol:
7 cmd.run:
8 - name: "ceph mon enable-msgr2"
9 - unless:
10 - pkg: mgr_packages
11
12{%- endif %}
13
Ondrej Smola91c83162017-09-12 16:40:02 +020014include:
15- ceph.common
16
Jiri Broulik42552052018-02-15 15:23:29 +010017mgr_packages:
Ondrej Smola91c83162017-09-12 16:40:02 +020018 pkg.installed:
19 - names: {{ mgr.pkgs }}
Michel Nederlof5f1ce812018-06-12 19:58:34 +020020 - require_in:
21 - file: common_config
Ondrej Smola91c83162017-09-12 16:40:02 +020022
Jiri Broulik42552052018-02-15 15:23:29 +010023/var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/:
Ondrej Smola91c83162017-09-12 16:40:02 +020024 file.directory:
25 - template: jinja
26 - user: ceph
27 - group: ceph
28 - require:
Jiri Broulik42552052018-02-15 15:23:29 +010029 - pkg: mgr_packages
Ondrej Smola91c83162017-09-12 16:40:02 +020030
Jiri Broulik0eafd762017-09-27 11:31:50 +020031reload_systemctl_daemon:
32 cmd.run:
33 - name: "systemctl daemon-reload"
Jiri Broulik42552052018-02-15 15:23:29 +010034 - unless: "test -f /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/keyring"
Jiri Broulik0eafd762017-09-27 11:31:50 +020035
Ondrej Smola91c83162017-09-12 16:40:02 +020036ceph_create_mgr_keyring_{{ grains.host }}:
37 cmd.run:
Jiri Broulik42552052018-02-15 15:23:29 +010038 - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf auth get-or-create mgr.{{ grains.host }} mon 'allow profile mgr' osd 'allow *' mds 'allow *' > /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/keyring"
39 - unless: "test -f /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/keyring"
Ondrej Smola91c83162017-09-12 16:40:02 +020040 - require:
Jiri Broulik42552052018-02-15 15:23:29 +010041 - file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/
Ondrej Smola91c83162017-09-12 16:40:02 +020042
Jiri Broulikc2be93b2017-10-03 14:20:00 +020043mgr_services:
44 service.running:
45 - enable: true
46 - names: [ceph-mgr@{{ grains.host }}]
47 - watch:
Michel Nederlof5f1ce812018-06-12 19:58:34 +020048 - file: common_config
Jiri Broulikc2be93b2017-10-03 14:20:00 +020049 - require:
Jiri Broulik42552052018-02-15 15:23:29 +010050 - pkg: mgr_packages
Jiri Broulikc2be93b2017-10-03 14:20:00 +020051 - cmd: ceph_create_mgr_keyring_{{ grains.host }}
52 {%- if grains.get('noservices') %}
53 - onlyif: /bin/false
54 {%- endif %}
55
Ivan Berezovskiy096b3ca2020-02-18 14:35:31 +040056ceph_mgr_wait_functional:
57 cmd.run:
58 - name: test "$(ceph mgr dump --connect-timeout 30 | jq .available)" = "true"
59 - retry:
60 attempts: 5
61 interval: 10
62 {%- if grains.get('noservices') %}
63 - onlyif: /bin/false
64 {%- endif %}
65 - require:
66 - service: mgr_services
67
Jiri Broulikeaf41472017-10-18 09:56:33 +020068{%- if common.version not in ['kraken', 'jewel'] %}
69
Ondrej Smola91c83162017-09-12 16:40:02 +020070{%- if mgr.get('dashboard', {}).get('enabled', False) %}
71
72ceph_dashboard_address:
73 cmd.run:
Jiri Broulik42552052018-02-15 15:23:29 +010074 - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf config-key put mgr/dashboard/{{ grains.host }}/server_addr {{ mgr.dashboard.get('host', '::') }}"
75 - unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf config-key get mgr/dashboard/{{ grains.host }}/server_addr | grep {{ mgr.dashboard.get('host', '::') }}"
Michel Nederlof5f1ce812018-06-12 19:58:34 +020076 - require:
77 - file: common_config
Ondrej Smola91c83162017-09-12 16:40:02 +020078
79ceph_dashboard_port:
80 cmd.run:
Jiri Broulik42552052018-02-15 15:23:29 +010081 - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf config-key put mgr/dashboard/{{ grains.host }}/server_port {{ mgr.dashboard.get('port', '7000') }}"
82 - unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf config-key get mgr/dashboard/{{ grains.host }}/server_port | grep {{ mgr.dashboard.get('port', '7000') }}"
Michel Nederlof5f1ce812018-06-12 19:58:34 +020083 - require:
84 - file: common_config
Ondrej Smola91c83162017-09-12 16:40:02 +020085
Ondrej Smola91c83162017-09-12 16:40:02 +020086ceph_restart_dashboard_plugin:
87 cmd.wait:
Jiri Broulik42552052018-02-15 15:23:29 +010088 - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module disable dashboard;ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module enable dashboard --force"
Ondrej Smola91c83162017-09-12 16:40:02 +020089 - watch:
Ivan Berezovskiy096b3ca2020-02-18 14:35:31 +040090 - cmd: ceph_mgr_wait_functional
Ondrej Smola91c83162017-09-12 16:40:02 +020091 - cmd: ceph_dashboard_address
92 - cmd: ceph_dashboard_port
Michel Nederlof5f1ce812018-06-12 19:58:34 +020093 - require:
94 - file: common_config
Ondrej Smola91c83162017-09-12 16:40:02 +020095
96enable_ceph_dashboard:
97 cmd.run:
Jiri Broulik42552052018-02-15 15:23:29 +010098 - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module enable dashboard"
Mateusz Losd8786a22019-01-08 12:55:39 +010099 - unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | python -c 'import sys, json; print json.load(sys.stdin)[\"enabled_modules\"] | grep dashboard"
Michel Nederlof5f1ce812018-06-12 19:58:34 +0200100 - require:
Ivan Berezovskiy096b3ca2020-02-18 14:35:31 +0400101 - cmd: ceph_mgr_wait_functional
Michel Nederlof5f1ce812018-06-12 19:58:34 +0200102 - file: common_config
Ondrej Smola91c83162017-09-12 16:40:02 +0200103
104{%- else %}
105
106disable_ceph_dashboard:
107 cmd.run:
Jiri Broulik42552052018-02-15 15:23:29 +0100108 - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module disable dashboard"
Mateusz Losd8786a22019-01-08 12:55:39 +0100109 - unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | python -c 'import sys, json; print json.load(sys.stdin)[\"disabled_modules\"] | grep dashboard"
Mateusz Loscae73e52018-12-14 16:09:00 +0100110 - require:
Ivan Berezovskiy096b3ca2020-02-18 14:35:31 +0400111 - cmd: ceph_mgr_wait_functional
Mateusz Loscae73e52018-12-14 16:09:00 +0100112 - file: common_config
113 - file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/
114
115{%- endif %}
116
117{%- if pillar.get('prometheus', {}).get('collector',{}).get("enabled", False) %}
118
119enable_prometheus_plugin:
120 cmd.run:
Ivan Berezovskiy096b3ca2020-02-18 14:35:31 +0400121 - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module enable prometheus"
Mateusz Losd8786a22019-01-08 12:55:39 +0100122 - unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | python -c 'import sys, json; print json.load(sys.stdin)[\"enabled_modules\"] | grep prometheus"
Ondrej Smola91c83162017-09-12 16:40:02 +0200123 - require:
Ivan Berezovskiy096b3ca2020-02-18 14:35:31 +0400124 - cmd: ceph_mgr_wait_functional
Michel Nederlof5f1ce812018-06-12 19:58:34 +0200125 - file: common_config
Jiri Broulik42552052018-02-15 15:23:29 +0100126 - file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/
Ondrej Smola91c83162017-09-12 16:40:02 +0200127
mjedynski982f2472020-05-20 02:26:24 +0200128{%- if common.version not in ['jewel','kraken','luminous'] and setup.pool is defined %}
129 {%- set rbd_pools=[] %}
130 {%- for pool_name, pool in setup.pool.iteritems() %}
131 {%- if pool.application == 'rbd' and pool.rbd_stats == true %}
132 {%- do rbd_pools.append(pool_name) %}
133 {%- endif %}
134 {%- endfor %}
mjedynskibcc27b12020-06-30 13:01:40 +0200135 {%- if rbd_pools %}
mjedynski982f2472020-05-20 02:26:24 +0200136enable_rbd_metrics:
137 cmd.run:
138 - name: "ceph config set mgr mgr/prometheus/rbd_stats_pools {{ rbd_pools|join(',') }}"
139 - unless: "diff <( tr ',' '\n' <<< `ceph config-key get config/mgr/mgr/prometheus/rbd_stats_pools` | sort) <(tr ',' '\n' <<< {{rbd_pools|join(',')}} | sort)"
140 - require:
141 - cmd: ceph_mgr_wait_functional
142 - file: common_config
143 - file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/
mjedynskibcc27b12020-06-30 13:01:40 +0200144 {%- endif %}
mjedynski982f2472020-05-20 02:26:24 +0200145{%- endif %}
146
Ondrej Smola91c83162017-09-12 16:40:02 +0200147{%- endif %}
148
Jiri Broulikeaf41472017-10-18 09:56:33 +0200149{%- endif %}
150
Mateusz Loscae73e52018-12-14 16:09:00 +0100151{%- endif %}