# Unable to restart auditd service on centos7

**URL:** <https://forum.ansible.com/t/unable-to-restart-auditd-service-on-centos7/32251>\
**Category:** Ansible Project\
**Created:** [February 17, 2020, 1:36pm UTC](https://forum.ansible.com/t/unable-to-restart-auditd-service-on-centos7/32251 "2020-02-17T13:36:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bala\_Mutyam](https://avatars.discourse-cdn.com/v4/letter/b/65b543/32.png) [@Bala\_Mutyam](https://forum.ansible.com/u/Bala_Mutyam)\
**Post date:** [February 17, 2020, 1:36pm UTC](https://forum.ansible.com/t/unable-to-restart-auditd-service-on-centos7/32251/1 "2020-02-17T13:36:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [February 17, 2020, 1:42pm UTC](https://forum.ansible.com/t/unable-to-restart-auditd-service-on-centos7/32251/2 "2020-02-17T13:42:08Z")

</div>

> 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  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Bariou\_Alarou](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Bariou\_Alarou](https://forum.ansible.com/u/Bariou_Alarou)\
**Post date:** [February 17, 2020, 1:43pm UTC](https://forum.ansible.com/t/unable-to-restart-auditd-service-on-centos7/32251/3 "2020-02-17T13:43:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bala\_Mutyam](https://avatars.discourse-cdn.com/v4/letter/b/65b543/32.png) [@Bala\_Mutyam](https://forum.ansible.com/u/Bala_Mutyam)\
**Post date:** [February 17, 2020, 2:54pm UTC](https://forum.ansible.com/t/unable-to-restart-auditd-service-on-centos7/32251/4 "2020-02-17T14:54:00Z")

</div>

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”}

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 17, 2020, 3:12pm UTC](https://forum.ansible.com/t/unable-to-restart-auditd-service-on-centos7/32251/5 "2020-02-17T15:12:47Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![cyril.stoll](https://avatars.discourse-cdn.com/v4/letter/c/b4bc9f/32.png) [@cyril.stoll](https://forum.ansible.com/u/cyril.stoll)\
**Post date:** [February 17, 2020, 5:53pm UTC](https://forum.ansible.com/t/unable-to-restart-auditd-service-on-centos7/32251/6 "2020-02-17T17:53:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Angel\_Rengifo\_Cancin](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Angel\_Rengifo\_Cancin](https://forum.ansible.com/u/Angel_Rengifo_Cancin)\
**Post date:** [February 18, 2020, 1:47am UTC](https://forum.ansible.com/t/unable-to-restart-auditd-service-on-centos7/32251/7 "2020-02-18T01:47:53Z")

</div>

Hello:
