--- - hosts: all tasks: - name: "Ensure group \"prometheus\" exists with correct gid" group: name: prometheus state: present gid: 2998 - name: "Add the user prometheus" user: name: prometheus groups: prometheus state: present uid: 2998 - name: "Ensure group \"node_exporter\" exists with correct gid" group: name: node_exporter state: present gid: 2997 - name: "Add the user node_exporter" user: name: node_exporter groups: node_exporter state: present uid: 2997 - name: Creating /opt/src shell: | mkdir -p /opt/src - name: "Syncing dir to servers" synchronize: src: node_exportoer/node_exporter-1.7.0.linux-amd64.tar.gz dest: /opt/src/node_exporter-1.7.0.linux-amd64.tar.gz when: - name: "Extracting node_exporter-1.4.0" shell: | tar xvf /opt/src/node_exporter-1.7.0.linux-amd64.tar.gz -C /opt/src/ cd /opt/src/node_exporter-*.linux-amd64 && cp -fv node_exporter /usr/local/bin/ - name: "Syncing service file to servers" synchronize: src: node_exporter/node-exporter.service dest: /etc/systemd/system/node-exporter.service - name: "Restart and enable the service node-exporter" systemd: state: restarted daemon_reload: yes name: node-exporter enabled: yes