Hi
I am trying to add a line in a file on the control node after performing the yum update on the managed nodes. I have created the below playbook. Adding new lines to the file in control node is getting skipped for some random servers.
- name: Mail function
hosts: SSS
vars:
date: "{{ lookup('pipe', 'date +%Y%m%d') }}"
tasks:
- name: Send Command to users logged in
command: wall -n "System will go down for 2 hours maintenance at 13:00 PM"
- name: Add new Line
lineinfile:
state: present
dest: /ansible/update{{date}}
line: 'System {{ inventory_hostname }} has been successfully provisioned at {{ date }} "'
insertafter: EOF
regexp: '^HELLO'
delegate_to: dockermgr1
and the hosts SSS has the below servers in the inventory
dockermgr1
dockermgr2
dockermgr3
File /ansible/update is updated as below in first run
We have patched the dockermgr1 successfully at 20210826
We have patched the dockermgr3 successfully at 20210826
File /ansible/update is updated as below in second run
We have patched the dockermgr1 successfully at 20210826
We have patched the dockermgr2 successfully at 20210826
We have patched the dockermgr3 successfully at 20210826
File /ansible/update is updated as below in third run
We have patched the dockermgr2 successfully at 20210826
Can you help?
I am trying to add a line in a file on the control node after performing the yum update on the managed nodes. I have created the below playbook. Adding new lines to the file in control node is getting skipped for some random servers.
- name: Mail function
hosts: SSS
vars:
date: "{{ lookup('pipe', 'date +%Y%m%d') }}"
tasks:
- name: Send Command to users logged in
command: wall -n "System will go down for 2 hours maintenance at 13:00 PM"
- name: Add new Line
lineinfile:
state: present
dest: /ansible/update{{date}}
line: 'System {{ inventory_hostname }} has been successfully provisioned at {{ date }} "'
insertafter: EOF
regexp: '^HELLO'
delegate_to: dockermgr1
and the hosts SSS has the below servers in the inventory
dockermgr1
dockermgr2
dockermgr3
File /ansible/update is updated as below in first run
We have patched the dockermgr1 successfully at 20210826
We have patched the dockermgr3 successfully at 20210826
File /ansible/update is updated as below in second run
We have patched the dockermgr1 successfully at 20210826
We have patched the dockermgr2 successfully at 20210826
We have patched the dockermgr3 successfully at 20210826
File /ansible/update is updated as below in third run
We have patched the dockermgr2 successfully at 20210826
Can you help?