- name: Install dstat become: yes package: name: dstat state: present - name: Install dstat unit become: yes copy: dest: /etc/systemd/system/dstatlogger.service owner: root group: root mode: 0644 content: | [Unit] Description=Dstat logging service [Service] User=root ExecStart=/usr/bin/dstat -tcmndrylpg --tcp --swap --output /var/log/dstat-csv.log KillMode=process TimeoutStopSec=300 StandardOutput=null [Install] WantedBy=multi-user.target - name: Reload systemd become: yes command: systemctl daemon-reload - name: Start dstat unit become: yes command: systemctl start dstatlogger