--- - name: Deploy Promtail to all nodes hosts: all become: yes vars: promtail_config_path: /etc/promtail/promtail.yml promtail_data_path: /opt/promtail/data tasks: - name: Install promtail apt: name: promtail state: present update_cache: yes ignore_errors: yes - name: Create promtail user and group user: name: promtail system: yes shell: /bin/false home: /opt/promtail create_home: yes - name: Create promtail data directory file: path: "{{ promtail_data_path }}" state: directory owner: promtail group: promtail mode: '0755' - name: Copy promtail configuration template: src: promtail-config.yaml dest: "{{ promtail_config_path }}" owner: promtail group: promtail mode: '0644' notify: restart promtail - name: Add promtail user to adm group (for syslog access) user: name: promtail groups: adm append: yes - name: Enable and start promtail service systemd: name: promtail enabled: yes state: started daemon_reload: yes handlers: - name: restart promtail systemd: name: promtail state: restarted