| {%- from "ceph/map.jinja" import common, mgr, setup with context %} |
| |
| {%- if mgr.get('enabled', False) %} |
| |
| {%- if common.version in ['nautilus'] %} |
| enable_msgr2_protocol: |
| cmd.run: |
| - name: "ceph mon enable-msgr2" |
| - unless: |
| - pkg: mgr_packages |
| |
| {%- endif %} |
| |
| include: |
| - ceph.common |
| |
| mgr_packages: |
| pkg.installed: |
| - names: {{ mgr.pkgs }} |
| - require_in: |
| - file: common_config |
| |
| /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/: |
| file.directory: |
| - template: jinja |
| - user: ceph |
| - group: ceph |
| - require: |
| - pkg: mgr_packages |
| |
| reload_systemctl_daemon: |
| cmd.run: |
| - name: "systemctl daemon-reload" |
| - unless: "test -f /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/keyring" |
| |
| ceph_create_mgr_keyring_{{ grains.host }}: |
| cmd.run: |
| - 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" |
| - unless: "test -f /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/keyring" |
| - require: |
| - file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/ |
| |
| mgr_services: |
| service.running: |
| - enable: true |
| - names: [ceph-mgr@{{ grains.host }}] |
| - watch: |
| - file: common_config |
| - require: |
| - pkg: mgr_packages |
| - cmd: ceph_create_mgr_keyring_{{ grains.host }} |
| {%- if grains.get('noservices') %} |
| - onlyif: /bin/false |
| {%- endif %} |
| |
| ceph_mgr_wait_functional: |
| cmd.run: |
| - name: test "$(ceph mgr dump --connect-timeout 30 | jq .available)" = "true" |
| - retry: |
| attempts: 5 |
| interval: 10 |
| {%- if grains.get('noservices') %} |
| - onlyif: /bin/false |
| {%- endif %} |
| - require: |
| - service: mgr_services |
| |
| {%- if common.version not in ['kraken', 'jewel'] %} |
| |
| {%- if mgr.get('dashboard', {}).get('enabled', False) %} |
| |
| ceph_dashboard_address: |
| cmd.run: |
| - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf config-key put mgr/dashboard/{{ grains.host }}/server_addr {{ mgr.dashboard.get('host', '::') }}" |
| - 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', '::') }}" |
| - require: |
| - file: common_config |
| |
| ceph_dashboard_port: |
| cmd.run: |
| - 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') }}" |
| - 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') }}" |
| - require: |
| - file: common_config |
| |
| ceph_restart_dashboard_plugin: |
| cmd.wait: |
| - 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" |
| - watch: |
| - cmd: ceph_mgr_wait_functional |
| - cmd: ceph_dashboard_address |
| - cmd: ceph_dashboard_port |
| - require: |
| - file: common_config |
| |
| enable_ceph_dashboard: |
| cmd.run: |
| - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module enable dashboard" |
| - 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" |
| - require: |
| - cmd: ceph_mgr_wait_functional |
| - file: common_config |
| |
| {%- else %} |
| |
| disable_ceph_dashboard: |
| cmd.run: |
| - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module disable dashboard" |
| - 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" |
| - require: |
| - cmd: ceph_mgr_wait_functional |
| - file: common_config |
| - file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/ |
| |
| {%- endif %} |
| |
| {%- if pillar.get('prometheus', {}).get('collector',{}).get("enabled", False) %} |
| |
| enable_prometheus_plugin: |
| cmd.run: |
| - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module enable prometheus" |
| - 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" |
| - require: |
| - cmd: ceph_mgr_wait_functional |
| - file: common_config |
| - file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/ |
| |
| {%- if common.version not in ['jewel','kraken','luminous'] and setup.pool is defined %} |
| {%- set rbd_pools=[] %} |
| {%- for pool_name, pool in setup.pool.iteritems() %} |
| {%- if pool.application == 'rbd' and pool.rbd_stats == true %} |
| {%- do rbd_pools.append(pool_name) %} |
| {%- endif %} |
| {%- endfor %} |
| {%- if rbd_pools %} |
| enable_rbd_metrics: |
| cmd.run: |
| - name: "ceph config set mgr mgr/prometheus/rbd_stats_pools {{ rbd_pools|join(',') }}" |
| - unless: "diff <( tr ',' '\n' <<< `ceph config-key get config/mgr/mgr/prometheus/rbd_stats_pools` | sort) <(tr ',' '\n' <<< {{rbd_pools|join(',')}} | sort)" |
| - require: |
| - cmd: ceph_mgr_wait_functional |
| - file: common_config |
| - file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/ |
| {%- endif %} |
| {%- endif %} |
| |
| {%- endif %} |
| |
| {%- endif %} |
| |
| {%- endif %} |