I have a need to execute things in Ansible 2.9 task based on a fact if service is started or not.
This is the code I use
- name: 'Check status of phpfpm-www56 service'
command: 'systemctl is-active --quiet php5.6-fpm'
register: cmd_fpm56_status
- name: 'Some task'
command: 'somescript'
when: cmd_fpm56_status.rc == 0
When I run ansible lint on this I get following error message:
command-instead-of-module: systemctl used in place of systemd module
no-changed-when: Commands should not change things if nothing needs doing
Is there a way to use systemd
module to just “ask” state of the service?