Unable to restart auditd service on centos7

Hi all,

Anisble Version: ansible 2.7.7

I’m configuring auditd on centos7 but the auditd service is failing to restart.

Handler:

  • name: centos7 restart auditd
    become: yes
    command: service auditd restart

Error:

FAILED! => {“changed”: false, “msg”: “Unable to restart service auditd: Failed to restart auditd.service: Operation refused, unit auditd.service may be requested by dependency only (it is configured to refuse manual start/stop).\nSee system logs and ‘systemctl status auditd.service’ for details.\n”}

I can restart the service via commandline on the host using “service auditd restart”

I’m running playbook as root user

Could someone help me please?

Hi all,

Anisble Version: ansible 2.7.7

I'm configuring auditd on centos7 but the auditd service is failing to restart.

Handler:

- name: centos7 restart auditd
become: yes
command: service auditd restart

Error:

FAILED! => {"changed": false, "msg": "Unable to restart service auditd: Failed to restart auditd.service: Operation
refused, unit auditd.service may be requested by dependency only (it is configured to refuse manual start/stop).\nSee
system logs and 'systemctl status auditd.service' for details.\n"}

I can restart the service via commandline on the host using "service auditd restart"

I'm running playbook as root user

Could someone help me please?

It might not solve your problem, but you should certainly use the "service" module instead of "command". If it still
fails, please provide corresponding log messages as instructed in the error message.

Regards
        Racke

Could you use the service module instead of command.

Handler:

  • name: centos7 restart auditd
    service:
    name: audits
    state: restarted
    become: yes

Also wanted to know how do you run your playbook because you defined as handler.

Service module is also failing with the same error.

fatal: [192.168.69.33]: FAILED! => {“changed”: false, “msg”: “Unable to restart service auditd: Failed to restart auditd.service: Operation refused, unit auditd.service may be requested by dependency only (it is configured to refuse manual start/stop).\nSee system logs and ‘systemctl status auditd.service’ for details.\n”}

Then you should follow the advice given, i.e:

See system logs and 'systemctl status auditd.service' for details.

Hi

For the handler you have to explicitly state to use the “service” instead of “systemctl” command. For me it worked with a notify and a handler definition like so:

  • name: restart auditd
    systemd:
    name: auditd
    state: restarted
    use: service

With that handler you can use “notify: restart auditd” in your task and that should work. I’m working with RHEL 7 but that should not be different from centOS 7 in that regard.

Best,
Cyril

Hello: