mjedynski | 982f247 | 2020-05-20 02:26:24 +0200 | [diff] [blame] | 1 | {%- from "ceph/map.jinja" import common, mgr, setup with context %} |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 2 | |
| 3 | {%- if mgr.get('enabled', False) %} |
| 4 | |
Mateusz Los | 45531fa | 2020-02-13 15:32:44 +0100 | [diff] [blame] | 5 | {%- if common.version in ['nautilus'] %} |
| 6 | enable_msgr2_protocol: |
| 7 | cmd.run: |
| 8 | - name: "ceph mon enable-msgr2" |
| 9 | - unless: |
| 10 | - pkg: mgr_packages |
| 11 | |
| 12 | {%- endif %} |
| 13 | |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 14 | include: |
| 15 | - ceph.common |
| 16 | |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 17 | mgr_packages: |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 18 | pkg.installed: |
| 19 | - names: {{ mgr.pkgs }} |
Michel Nederlof | 5f1ce81 | 2018-06-12 19:58:34 +0200 | [diff] [blame] | 20 | - require_in: |
| 21 | - file: common_config |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 22 | |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 23 | /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/: |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 24 | file.directory: |
| 25 | - template: jinja |
| 26 | - user: ceph |
| 27 | - group: ceph |
| 28 | - require: |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 29 | - pkg: mgr_packages |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 30 | |
Jiri Broulik | 0eafd76 | 2017-09-27 11:31:50 +0200 | [diff] [blame] | 31 | reload_systemctl_daemon: |
| 32 | cmd.run: |
| 33 | - name: "systemctl daemon-reload" |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 34 | - unless: "test -f /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/keyring" |
Jiri Broulik | 0eafd76 | 2017-09-27 11:31:50 +0200 | [diff] [blame] | 35 | |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 36 | ceph_create_mgr_keyring_{{ grains.host }}: |
| 37 | cmd.run: |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 38 | - 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 Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 40 | - require: |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 41 | - file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/ |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 42 | |
Jiri Broulik | c2be93b | 2017-10-03 14:20:00 +0200 | [diff] [blame] | 43 | mgr_services: |
| 44 | service.running: |
| 45 | - enable: true |
| 46 | - names: [ceph-mgr@{{ grains.host }}] |
| 47 | - watch: |
Michel Nederlof | 5f1ce81 | 2018-06-12 19:58:34 +0200 | [diff] [blame] | 48 | - file: common_config |
Jiri Broulik | c2be93b | 2017-10-03 14:20:00 +0200 | [diff] [blame] | 49 | - require: |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 50 | - pkg: mgr_packages |
Jiri Broulik | c2be93b | 2017-10-03 14:20:00 +0200 | [diff] [blame] | 51 | - cmd: ceph_create_mgr_keyring_{{ grains.host }} |
| 52 | {%- if grains.get('noservices') %} |
| 53 | - onlyif: /bin/false |
| 54 | {%- endif %} |
| 55 | |
Ivan Berezovskiy | 096b3ca | 2020-02-18 14:35:31 +0400 | [diff] [blame] | 56 | ceph_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 Broulik | eaf4147 | 2017-10-18 09:56:33 +0200 | [diff] [blame] | 68 | {%- if common.version not in ['kraken', 'jewel'] %} |
| 69 | |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 70 | {%- if mgr.get('dashboard', {}).get('enabled', False) %} |
| 71 | |
| 72 | ceph_dashboard_address: |
| 73 | cmd.run: |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 74 | - 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 Nederlof | 5f1ce81 | 2018-06-12 19:58:34 +0200 | [diff] [blame] | 76 | - require: |
| 77 | - file: common_config |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 78 | |
| 79 | ceph_dashboard_port: |
| 80 | cmd.run: |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 81 | - 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 Nederlof | 5f1ce81 | 2018-06-12 19:58:34 +0200 | [diff] [blame] | 83 | - require: |
| 84 | - file: common_config |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 85 | |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 86 | ceph_restart_dashboard_plugin: |
| 87 | cmd.wait: |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 88 | - 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 Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 89 | - watch: |
Ivan Berezovskiy | 096b3ca | 2020-02-18 14:35:31 +0400 | [diff] [blame] | 90 | - cmd: ceph_mgr_wait_functional |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 91 | - cmd: ceph_dashboard_address |
| 92 | - cmd: ceph_dashboard_port |
Michel Nederlof | 5f1ce81 | 2018-06-12 19:58:34 +0200 | [diff] [blame] | 93 | - require: |
| 94 | - file: common_config |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 95 | |
| 96 | enable_ceph_dashboard: |
| 97 | cmd.run: |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 98 | - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module enable dashboard" |
Mateusz Los | d8786a2 | 2019-01-08 12:55:39 +0100 | [diff] [blame] | 99 | - 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 Nederlof | 5f1ce81 | 2018-06-12 19:58:34 +0200 | [diff] [blame] | 100 | - require: |
Ivan Berezovskiy | 096b3ca | 2020-02-18 14:35:31 +0400 | [diff] [blame] | 101 | - cmd: ceph_mgr_wait_functional |
Michel Nederlof | 5f1ce81 | 2018-06-12 19:58:34 +0200 | [diff] [blame] | 102 | - file: common_config |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 103 | |
| 104 | {%- else %} |
| 105 | |
| 106 | disable_ceph_dashboard: |
| 107 | cmd.run: |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 108 | - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module disable dashboard" |
Mateusz Los | d8786a2 | 2019-01-08 12:55:39 +0100 | [diff] [blame] | 109 | - 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 Los | cae73e5 | 2018-12-14 16:09:00 +0100 | [diff] [blame] | 110 | - require: |
Ivan Berezovskiy | 096b3ca | 2020-02-18 14:35:31 +0400 | [diff] [blame] | 111 | - cmd: ceph_mgr_wait_functional |
Mateusz Los | cae73e5 | 2018-12-14 16:09:00 +0100 | [diff] [blame] | 112 | - 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 | |
| 119 | enable_prometheus_plugin: |
| 120 | cmd.run: |
Ivan Berezovskiy | 096b3ca | 2020-02-18 14:35:31 +0400 | [diff] [blame] | 121 | - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module enable prometheus" |
Mateusz Los | d8786a2 | 2019-01-08 12:55:39 +0100 | [diff] [blame] | 122 | - 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 Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 123 | - require: |
Ivan Berezovskiy | 096b3ca | 2020-02-18 14:35:31 +0400 | [diff] [blame] | 124 | - cmd: ceph_mgr_wait_functional |
Michel Nederlof | 5f1ce81 | 2018-06-12 19:58:34 +0200 | [diff] [blame] | 125 | - file: common_config |
Jiri Broulik | 4255205 | 2018-02-15 15:23:29 +0100 | [diff] [blame] | 126 | - file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/ |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 127 | |
mjedynski | 982f247 | 2020-05-20 02:26:24 +0200 | [diff] [blame] | 128 | {%- 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 %} |
mjedynski | bcc27b1 | 2020-06-30 13:01:40 +0200 | [diff] [blame] | 135 | {%- if rbd_pools %} |
mjedynski | 982f247 | 2020-05-20 02:26:24 +0200 | [diff] [blame] | 136 | enable_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 }}/ |
mjedynski | bcc27b1 | 2020-06-30 13:01:40 +0200 | [diff] [blame] | 144 | {%- endif %} |
mjedynski | 982f247 | 2020-05-20 02:26:24 +0200 | [diff] [blame] | 145 | {%- endif %} |
| 146 | |
Ondrej Smola | 91c8316 | 2017-09-12 16:40:02 +0200 | [diff] [blame] | 147 | {%- endif %} |
| 148 | |
Jiri Broulik | eaf4147 | 2017-10-18 09:56:33 +0200 | [diff] [blame] | 149 | {%- endif %} |
| 150 | |
Mateusz Los | cae73e5 | 2018-12-14 16:09:00 +0100 | [diff] [blame] | 151 | {%- endif %} |