--- - name: create group group: name: "{{ prometheus_group }}" system: true state: "{{ prometheus_group_state | default('present') }}" - name: create user user: name: "{{ prometheus_user }}" system: true shell: "{{ prometheus_user_shell }}" group: "{{ prometheus_group }}" createhome: false home: "{{ prometheus_var_path }}" state: "{{ prometheus_user_state | default('present') }}" - name: create etc path file: path: "{{ prometheus_etc_path }}" state: directory owner: "{{ prometheus_etc_owner }}" group: "{{ prometheus_etc_group }}" mode: "{{ prometheus_etc_mode }}" - name: create file_sd_config.d path file: path: "{{ prometheus_etc_path }}/file_sd_config.d" state: directory owner: "{{ prometheus_etc_owner }}" group: "{{ prometheus_etc_group }}" mode: "{{ prometheus_etc_mode }}" - name: create var path file: path: "{{ prometheus_var_path }}" state: directory owner: "{{ prometheus_var_owner }}" group: "{{ prometheus_var_group }}" mode: "{{ prometheus_var_mode }}" - name: configure copy: dest: "{{ prometheus_etc_path }}/prometheus.yaml" content: "{{ (prometheus_config | default({})) | to_yaml }}" owner: root group: root mode: 0444 notify: restart prometheus - name: configure rules copy: dest: "{{ prometheus_etc_path }}/rules.yaml" content: "{{ (prometheus_rules_config | default({})) | to_yaml }}" owner: root group: root mode: 0444 notify: reload prometheus - name: configure file_sd_config.d copy: dest: "{{ prometheus_etc_path }}/file_sd_config.d/{{ item.name }}" content: "{{ (item.targets | default([])) | to_json }}" owner: root group: root mode: 0444 loop: "{{ prometheus_file_sd_config_d_files | default([]) }}" - name: configure systemd template template: src: prometheus.service.j2 dest: /etc/systemd/system/prometheus.service owner: root group: root mode: 0444 notify: restart prometheus - name: manage service service: name: "{{ prometheus_service_name }}" enabled: "{{ prometheus_service_enabled }}" state: "{{ prometheus_service_state }}"