- name: Install packages package: name: - prometheus - name: Create directory for prometheus configs file: path: /etc/prometheus/conf.d state: directory - name: Configure prometheus retention time when: retention is defined lineinfile: path: /etc/conf.d/prometheus regexp: "^prometheus_retention_time=" line: "prometheus_retention_time={{ retention }}" notify: restart prometheus - name: Configure prometheus copy: dest: /etc/prometheus/ src: prometheus.yml notify: reload prometheus - name: Enable prometheus service service: name: prometheus enabled: true state: started