Browse Source

Make the monitoring stack ports configurable for each daemon

According to [1] the monitoring stack daemons are able to bind on the
specified {ip}:{port}.
This change turns the previously defined monitoring items into a dict
where the name of the daemon and the port can be specified (the ports
are supposed to come from the tht parameters).
In addition, we need to make sure that the port parameter is evaluated
as an int, otherwise cephadm fails when the spec is applied. For this
reason a new 'normalize_spec' function is introduced, with the purpose
of analyzing the provided payload and make sure the port parameters
are expressed as int. This is required due to the fact that the ansible
option 'ANSIBLE_JINJA2_NATIVE=True' [2], which is supposed to enable
this feature at tripleo-ansible level is missing, but it's a constraint
we wouldn't like to introduce.

[1] https://github.com/ceph/ceph/pull/41444
[2] https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_JINJA2_NATIVE

Change-Id: I3f1d0205f2228d59c5e8bc6b33084c64974c2a2b
(cherry picked from commit ccdecf061e)
changes/47/795147/1
Francesco Pantano 2 weeks ago
parent
commit
e3b18493d5
2 changed files with 20 additions and 7 deletions
  1. +12
    -1
      tripleo_ansible/ansible_plugins/module_utils/ceph_spec.py
  2. +8
    -6
      tripleo_ansible/roles/tripleo_cephadm/tasks/monitoring.yaml

+ 12
- 1
tripleo_ansible/ansible_plugins/module_utils/ceph_spec.py View File

@ -208,7 +208,7 @@ class CephDaemonSpec(object):
# append the spec if provided
if len(self.spec.keys()) > 0:
if self.validate_keys(self.spec.keys(), ALLOWED_SPEC_KEYS):
sp = {'spec': self.filter_spec(self.spec)}
sp = {'spec': self.normalize_spec(self.filter_spec(self.spec))}
else:
raise Exception("Fatal: the spec should be composed by only allowed keywords")
@ -216,6 +216,17 @@ class CephDaemonSpec(object):
spec_template = {**spec_template, **ntw, **self.extra, **pl, **sp}
return spec_template
def normalize_spec(self, spec):
'''
For each spec key we need to make sure
that ports are evaluated as int, otherwise
cephadm fails when the spec is applied.
'''
for k, v in spec.items():
if 'port' in k:
spec[k] = int(v)
return spec
def filter_spec(self, spec):
return {k: v for k, v in spec.items() if v}


+ 8
- 6
tripleo_ansible/roles/tripleo_cephadm/tasks/monitoring.yaml View File

@ -63,20 +63,22 @@
- name: Create the monitoring stack Daemon spec definition
become: true
ceph_mkspec:
service_type: "{{ item }}"
service_id: "{{ item }}"
service_name: "{{ item }}"
service_type: "{{ item.daemon }}"
service_id: "{{ item.daemon }}"
service_name: "{{ item.daemon }}"
apply: true
hosts: "{{ _hosts | unique }}"
render_path: "{{ tripleo_cephadm_spec_home }}"
networks: "{{ tripleo_cephadm_monitoring_address_block }}"
spec:
port: "{{ item.port }}"
environment:
CEPH_CONTAINER_IMAGE: "{{ tripleo_cephadm_container_ns + '/' + tripleo_cephadm_container_image + ':' + tripleo_cephadm_container_tag }}"
CEPH_CONTAINER_BINARY: "{{ tripleo_cephadm_container_cli }}"
with_items:
- "alertmanager"
- "prometheus"
- "grafana"
- {"daemon": "grafana", "port": "{{ tripleo_cephadm_grafana_port | default(3100) }}"}
- {"daemon": "prometheus", "port": "{{ tripleo_cephadm_prometheus_port | default(9092) }}"}
- {"daemon": "alertmanager", "port": "{{ tripleo_cephadm_alertmanager_port | default(9094) }}"}
when: tripleo_cephadm_dashboard_enabled | bool
- include_tasks: dashboard/dashboard.yaml


Loading…
Cancel
Save