--- - name: Install Grafana prerequisites ansible.builtin.apt: name: - apt-transport-https - software-properties-common - wget state: present update_cache: true become: true - name: Create Grafana keyring directory ansible.builtin.file: path: /etc/apt/keyrings state: directory mode: '0755' become: true - name: Download Grafana GPG key ansible.builtin.shell: cmd: wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor -o /etc/apt/keyrings/grafana.gpg creates: /etc/apt/keyrings/grafana.gpg become: true - name: Set Grafana GPG key permissions ansible.builtin.file: path: /etc/apt/keyrings/grafana.gpg mode: '0644' become: true - name: Add Grafana apt repository ansible.builtin.copy: content: "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main\n" dest: /etc/apt/sources.list.d/grafana.list mode: '0644' become: true - name: Install Grafana ansible.builtin.apt: name: "{{ grafana_package }}" state: present update_cache: true become: true - name: Enable and start Grafana service ansible.builtin.systemd: name: grafana-server enabled: "{{ grafana_service_enabled }}" state: "{{ grafana_service_state }}" become: true