debops-tools icon indicating copy to clipboard operation
debops-tools copied to clipboard

Use {{ ansible_managed }} instead of 'This file is managed by Ansible, all changes will be lost'?

Open ypid opened this issue 10 years ago • 6 comments

What do you think?

Currently it is only used in a few places.

Is your debops.plan related to this?

ypid avatar Jul 27 '15 14:07 ypid

We used {{ ansible_managed }} in the past and changed it to a static string because {{ ansible_managed }} was creating idempotency issues.

nickjj avatar Jul 27 '15 14:07 nickjj

Fair enough. With a static variable defined in ansible.cfg, there should not be any issue. I also remember that the modification time used to be included in the default ansible_managed but those times are gone: https://github.com/ansible/ansible/blob/devel/examples/ansible.cfg#L93

ansible_managed = This file is managed by Ansible, all changes will be lost.

ypid avatar Jul 27 '15 14:07 ypid

Right, we made the change to a static string well before it was tweakable in ansible.cfg. @drybjed, what do you think about making this change?

nickjj avatar Jul 27 '15 15:07 nickjj

I'm all for using {{ ansible_managed }} again, I've been doing it for some time now. No rush though - when I modify a file that has a static string, I update it to dynamic.

Nice to hear that ansible.cfg dropped the date in default value.

Yes, debops.plan is my own quasi-todo list for the project for 2015. I try to follow it, but sometimes work obligations take precedence (ie. I need to setup something else ASAP).

drybjed avatar Jul 27 '15 16:07 drybjed

I think this is relatively easy doable with a short shell script. Try greping over all repos for 'This file is managed by Ansible, all changes will be lost'. Something like:

git submodule foreach git ls-files -z | xargs --null -I '{}' find '{}' -type f -print0 | xargs --null sed --in-place --regexp-extended 's/(This file is managed remotely, all changes will be lost|This file is managed remotely, some changes might be overwritten|This file is managed by Ansible, all changes will be lost)/{{ ansible_managed }}/g'

ypid avatar Jul 27 '15 16:07 ypid

Note that the {{ ansible_managed }} string is now static by default—see https://github.com/ansible/ansible/pull/18094/files.

geerlingguy avatar Feb 20 '17 04:02 geerlingguy