Discussion:
[ansible-project] How to propagate changes to previously-applied tasks (e.g removing files, changing crons, etc)
Andrew Martin
2015-07-15 18:00:06 UTC
Permalink
Hello,

I have really enjoyed using Ansible to be able to completely template new
servers that I set up, but one thing I have not yet figured out how to do
in my workflow is deal with changes that occur after a playbook has been
run on a server. For example, let's say that I have a cron task that
- name: create my cron
cron: name="My Cron version 1.0" job=/usr/local/bin/cron.sh minute=1
I run the playbook on my servers and this cron is added to the crontab,
good. However, later I decide to change the name, the job, or some other
attribute. If I do that, Ansible will add a new entry to the crontab but
leave this old one around. One solution would be to add a state=absent
task, but that involves duplicating or adding some legacy code to my
- name: create my cron (old)
cron: name="My Cron version 1.0" job=/usr/local/bin/cron.sh minute=1
state=absent
- name: create my cron
cron: name="My Cron version 1.1" job=/usr/local/bin/cron.sh minute=1
The best way to handle this that I can think of is:
1. review changes made to playbook, determine if they change any
pre-existing files, crons, etc
2. if changes to pre-existing files are made, duplicate corresponding tasks
and add a state=absent entry with the old names, run playbook to remove old
data
3. remove duplicate tasks, commit changes to playbooks repository

Is there a better way for ansible to handle removing old data from a
previous version of a playbook?

Thanks,

Andrew
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c012bf3e-f4e8-48af-b804-c38aac142508%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Brian Coca
2015-07-15 18:34:57 UTC
Permalink
not really, since you could have 10 diff plays for adding cron,
ansible won't know about the other 9 when running 1, it is up to you
too keep track. I just normally create 1 off plays and put them in a
cleanup/ dir that i can rerun in case i suspect something was missed
or someone reran an old version.
--
Brian Coca
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8%3DvVsi_QjOE6GOF1uJD-9BYRZM%3DDRvHGV_eChT5AMHVdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Andrew Martin
2015-07-21 03:51:27 UTC
Permalink
Brian,

Thanks for the clarification.

Andrew
Post by Brian Coca
not really, since you could have 10 diff plays for adding cron,
ansible won't know about the other 9 when running 1, it is up to you
too keep track. I just normally create 1 off plays and put them in a
cleanup/ dir that i can rerun in case i suspect something was missed
or someone reran an old version.
--
Brian Coca
--
You received this message because you are subscribed to a topic in the
Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/ansible-project/O1xL2CZXSNc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAJ5XC8%3DvVsi_QjOE6GOF1uJD-9BYRZM%3DDRvHGV_eChT5AMHVdQ%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAE%2B0DR46by%3DgsJ3%2BXfMKHUzB1m%3DKKpBXhW9CFGubACFkhOx9Kw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...