We would like to reset server installation.
We already have Ansible script to setup our server, so we want to execute it. However Ansible checks, that e.g. some files are existing and then skip steps where those files are prepared, but we would like to overwrite all.
Are there any convenient options to do that?
updated based on comments
In that case (certs on server that need to be regenerated) i have a nuke
flag in my playbook that is always set to false
and a task that does the cleanup
- file:
path: '{{ item }}'
state: absent
when: nuke
with_items:
- /path/to/file1
- /path/to/file2
When i need to recreate stuff, i use ansible with
ansible-playbook pb.yml -e nuke=true
Its not the most elegant solution, but it gets the job done.
old obsolete answer
There isn't any standard way of doing this. But I dont think that there is any point in that.
Ansible guarantees that the final form of the thing (i.e. file) you are provisioning is matching what ever you told it to be.
For example, if you deploy a template like this
- template:
src: ./foo
dest: /etc/foo
owner: root
and you execute it, the file is guaranteed to have the right contents and owned by user root.
There are lots of configs you can add to ensure that (checksums for get_url
, etc).