Ansible command returns change instead of success
6,356
In Ansible, a play with the status of 'CHANGED' is a successful response. If it wasn't successful, it would have reported back that the play 'FAILED'.
In an Ansible playbook, you can suppress the 'CHANGED' status by adding changed_when: false
to a play. If the play is successful, the status would then be 'OK'.
Related videos on Youtube
Author by
dcrearer
Updated on September 18, 2022Comments
-
dcrearer over 1 year
I'm learning ansible and encountered a situation which is not clear. Running the following module command the result is a 'Changed'.
ansible agent.example.com -i inventory -m copy -a 'content="Node Managed by Ansible\n" dest=/etc/motd'
Why am I not getting a successful response. I have confirmed that the motd file is actually being modified.
Here is the out put of the task.
agent.example.com | CHANGED => { "changed": true, "checksum": "3eb89f442d0bec80f2c59d6d66d621cc4ced7272", "dest": "/etc/motd", "gid": 0, "group": "root", "md5sum": "2e92a9663d317113e1c4bafb2610f3d5", "mode": "0644", "owner": "root", "secontext": "system_u:object_r:etc_t:s0", "size": 24, "src": "/home/admin/.ansible/tmp/ansible-tmp-1543639577.88-189984200437408/source", "state": "file", "uid": 0 }
-
dcrearer over 5 yearsI’m following a live lesson and the instructors out yielded successful -all green- so I was alarmed to not have the same status. Thanks for the feedback.
-
Surabhi over 5 years@dcrearer: I can see why that would alarm you then. I have experienced that both green and yellow responses are successful.
-
dcrearer over 5 yearsAwesome thanks again for the quick response. I’m now getting success after login out and back into the vm’s