--- - name: Install apt-transport-https apt: name: apt-transport-https state: present - name: Add gpg keys for prometheus repo ansible.builtin.apt_key: url: "{{ item.url }}" keyring: "{{ item.keyring }}" loop: "{{ postgres_exporter_apt_key }}" when: - postgres_exporter_apt_key is defined - postgres_exporter_install_official_repo - name: Add prometheus repository ansible.builtin.apt_repository: repo: "{{ item.repo }}" state: present filename: "{{ item.filename }}" update_cache: no loop: "{{ postgres_exporter_apt_repository }}" when: postgres_exporter_install_official_repo - name: Ensure {{ postgres_exporter_package }} version {{ postgres_exporter_version }} installed apt: name: "{{ postgres_exporter_package }}" state: present - name: Enable and start {{ postgres_exporter_unit_name }} systemd: name: "{{ postgres_exporter_unit_name }}" state: started enabled: yes masked: no daemon_reload: yes