Good day,
I have a list that I loop over to copy files. I want to restart a service only if that file has been changed on the remote system. What is the best method to restart a service on only on a system if the file was copied to the system.
For instance:
defaults/main.yml
copy_files:
- name: macsec
all_systems_copy_src: "files/etc/modprobe.d/macsec.conf"
all_systems_copy_dest: "/etc/modprobe.d/macsec.conf"
all_systems_copy_owner: "0"
all_systems_copy_group: "0"
all_systems_copy_mode: "0644"
- name: rsyslog
all_systems_copy_src: "files/etc/rsyslog/syslog.conf"
all_systems_copy_dest: "/etc/rsyslog.d/syslog.conf"
all_systems_copy_owner: "0"
all_systems_copy_group: "0"
all_systems_copy_mode: "0644"
tasks/copy_files/main.yml
- name: "Copy files"
copy:
src: "{{ item.all_systems_copy_src }}"
dest: "{{ item.all_systems_copy_dest }}"
owner: "{{ item.all_systems_copy_owner }}"
group: "{{ item.all_systems_copy_group }}"
mode: "{{ item.all_systems_copy_mode }}"
with_items:
- "{{ copy_files }}"
If the system copies a new syslog file restart syslog.
I know there are handlers and notify, but I only want to restart on a specific system if it gets updated.
Chris