I am trying to restart the vsftpd service using a handler, based on changes to the config file. I have the following code in tasks/main.yaml:
- name: copy vsftpd.conf
template: src=vsftpd.conf.j2 dest={{vsftpd_config_file}} backup=yes
become: yes
notify: restart vsftpd
tags: [ 'configuration', 'package', 'vsftpd' ]
and this in handlers/main.yaml:
---
- name: restart vsftpd
service: name={{ vsftpd_service_name }} state=restarted
the variables are defined as such, in defaults/main.yaml:
vsftpd_config_file: '/etc/vsftpd/vsftpd.conf'
vsftpd_service_name: 'vsftpd'
The handler gets called when I run the playbook:
...
TASK [linux-vsftpd : copy vsftpd.conf] **********************************************************************************************************************
changed: [ftp_host]
...
RUNNING HANDLER [linux-vsftpd : restart vsftpd] *************************************************************************************************************
changed: [ftp_host]
but the service doesn't get restarted:
[elliott.barrere@ftp_host ~]$ ps aux | grep vsftpd
248003150 10437 0.0 0.0 103304 896 pts/0 S+ 14:23 0:00 grep vsftpd
root 51182 0.0 0.0 52120 852 ? Ss 12:25 0:01 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
I can restart the service manually using the service script and the timestamp updates like I would expect:
[elliott.barrere@ftp_host ~]$ sudo service vsftpd restart
[sudo] password for elliott.barrere:
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]
[elliott.barrere@ftp_host ~]$ ps aux | grep vsftpd
root 38995 0.0 0.0 52120 852 ? Ss 14:23 0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
248003150 46878 0.0 0.0 103300 884 pts/0 S+ 14:23 0:00 grep vsftpd
[elliott.barrere@ftp_host ~]$
Any ideas why Ansible isn't restarting the service, or worse, why it isn't reporting a failure?