--- - name: "Create prometheus group" become: true ansible.builtin.group: name: "prometheus" system: true - name: "Create prometheus user" become: true ansible.builtin.user: name: "prometheus" group: "prometheus" system: true shell: "/usr/sbin/nologin" create_home: false - name: "Create prometheus directories" become: true ansible.builtin.file: path: "{{ item }}" state: "directory" owner: "prometheus" group: "prometheus" mode: "0755" with_items: - "/etc/prometheus" - "/var/lib/prometheus" - name: "Install prometheus packages" become: true ansible.builtin.package: name: - "prometheus" - "prometheus-node-exporter" state: "present" - name: "Create prometheus configuration" become: true ansible.builtin.template: src: "prometheus.yml.j2" dest: "/etc/prometheus/prometheus.yml" owner: "prometheus" group: "prometheus" mode: "0644" notify: "Restart prometheus" - name: "Start and enable prometheus services" become: true ansible.builtin.systemd_service: name: "prometheus" state: "started" enabled: true with_items: - "prometheus" - "prometheus-node-exporter"