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

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'.

| improve this answer | |
  • I’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. – dcrearer Dec 1 '18 at 5:06
  • @dcrearer: I can see why that would alarm you then. I have experienced that both green and yellow responses are successful. – Peschke Dec 1 '18 at 5:07
  • Awesome thanks again for the quick response. I’m now getting success after login out and back into the vm’s – dcrearer Dec 1 '18 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.