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
)
This commit is contained in:
parent
9e88ecab5c
commit
e3b18493d5
|
@ -208,7 +208,7 @@ class CephDaemonSpec(object):
|
||||||
# append the spec if provided
|
# append the spec if provided
|
||||||
if len(self.spec.keys()) > 0:
|
if len(self.spec.keys()) > 0:
|
||||||
if self.validate_keys(self.spec.keys(), ALLOWED_SPEC_KEYS):
|
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:
|
else:
|
||||||
raise Exception("Fatal: the spec should be composed by only allowed keywords")
|
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}
|
spec_template = {**spec_template, **ntw, **self.extra, **pl, **sp}
|
||||||
return spec_template
|
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):
|
def filter_spec(self, spec):
|
||||||
return {k: v for k, v in spec.items() if v}
|
return {k: v for k, v in spec.items() if v}
|
||||||
|
|
||||||
|
|
|
@ -63,20 +63,22 @@
|
||||||
- name: Create the monitoring stack Daemon spec definition
|
- name: Create the monitoring stack Daemon spec definition
|
||||||
become: true
|
become: true
|
||||||
ceph_mkspec:
|
ceph_mkspec:
|
||||||
service_type: "{{ item }}"
|
service_type: "{{ item.daemon }}"
|
||||||
service_id: "{{ item }}"
|
service_id: "{{ item.daemon }}"
|
||||||
service_name: "{{ item }}"
|
service_name: "{{ item.daemon }}"
|
||||||
apply: true
|
apply: true
|
||||||
hosts: "{{ _hosts | unique }}"
|
hosts: "{{ _hosts | unique }}"
|
||||||
render_path: "{{ tripleo_cephadm_spec_home }}"
|
render_path: "{{ tripleo_cephadm_spec_home }}"
|
||||||
networks: "{{ tripleo_cephadm_monitoring_address_block }}"
|
networks: "{{ tripleo_cephadm_monitoring_address_block }}"
|
||||||
|
spec:
|
||||||
|
port: "{{ item.port }}"
|
||||||
environment:
|
environment:
|
||||||
CEPH_CONTAINER_IMAGE: "{{ tripleo_cephadm_container_ns + '/' + tripleo_cephadm_container_image + ':' + tripleo_cephadm_container_tag }}"
|
CEPH_CONTAINER_IMAGE: "{{ tripleo_cephadm_container_ns + '/' + tripleo_cephadm_container_image + ':' + tripleo_cephadm_container_tag }}"
|
||||||
CEPH_CONTAINER_BINARY: "{{ tripleo_cephadm_container_cli }}"
|
CEPH_CONTAINER_BINARY: "{{ tripleo_cephadm_container_cli }}"
|
||||||
with_items:
|
with_items:
|
||||||
- "alertmanager"
|
- {"daemon": "grafana", "port": "{{ tripleo_cephadm_grafana_port | default(3100) }}"}
|
||||||
- "prometheus"
|
- {"daemon": "prometheus", "port": "{{ tripleo_cephadm_prometheus_port | default(9092) }}"}
|
||||||
- "grafana"
|
- {"daemon": "alertmanager", "port": "{{ tripleo_cephadm_alertmanager_port | default(9094) }}"}
|
||||||
when: tripleo_cephadm_dashboard_enabled | bool
|
when: tripleo_cephadm_dashboard_enabled | bool
|
||||||
|
|
||||||
- include_tasks: dashboard/dashboard.yaml
|
- include_tasks: dashboard/dashboard.yaml
|
||||||
|
|
Loading…
Reference in New Issue