--- - name: Set prometheus container subuid ansible.builtin.set_fact: prometheus_subuid: "165533" # nobody - 65534 - name: Create prometheus directory ansible.builtin.file: path: "{{ node['home_path'] }}/containers/{{ item }}" state: "directory" owner: "{{ prometheus_subuid }}" group: "svadmins" mode: "0770" loop: - "prometheus" - "prometheus/etc" - "prometheus/data" - "prometheus/ssl" become: true - name: Deploy prometheus configuration file ansible.builtin.template: src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/infra/prometheus/etc/{{ item }}.j2" dest: "{{ node['home_path'] }}/containers/prometheus/etc/{{ item }}" owner: "{{ prometheus_subuid }}" group: "svadmins" mode: "0600" loop: - "prometheus.yaml" - "rules.yaml" - "web-config.yaml" become: true notify: "notification_restart_prometheus" no_log: true - name: Deploy prometheus certificate and key ansible.builtin.copy: content: | {{ item.value }} dest: "{{ node['home_path'] }}/containers/prometheus/ssl/{{ item.name }}" owner: "{{ prometheus_subuid }}" group: "svadmins" mode: "{{ item.mode }}" loop: - name: "ilnmors_root_ca.crt" value: "{{ hostvars['console']['ca']['root']['crt'] }}" mode: "0440" - name: "prometheus.crt" value: | {{ hostvars['console']['prometheus']['crt'] | trim }} {{ hostvars['console']['ca']['intermediate']['crt'] }} mode: "0440" - name: "prometheus.key" value: "{{ hostvars['console']['prometheus']['key'] }}" mode: "0400" become: true notify: "notification_restart_prometheus" no_log: true - name: Deploy container file ansible.builtin.template: src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/infra/prometheus/prometheus.container.j2" dest: "{{ node['home_path'] }}/.config/containers/systemd/prometheus.container" owner: "{{ ansible_user }}" group: "svadmins" mode: "0644" notify: "notification_restart_prometheus" - name: Enable prometheus ansible.builtin.systemd: name: "prometheus.service" state: "started" enabled: true daemon_reload: true scope: "user"