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?
If you want to run multiple tasks in a playbook concurrently, use async with poll set to 0. When you set poll: 0 , Ansible starts the task and immediately moves on to the next task without waiting for a result. Each async task runs until it either completes, fails or times out (runs longer than its async value).
The default strategy Ansible uses, is called linear , and it works great a majority of the time, but what if you're automating a task that need to be done in a specific order or way. Strategies can be used to define how a playbook should be executed.
Playbook execution. A playbook runs in order from top to bottom. Within each play, tasks also run in order from top to bottom.
Ansible completes the play on the specified number or percentage of hosts before starting the next batch of hosts. You can restrict the number of workers allotted to a block or task with throttle . You can control how Ansible selects the next host in a group to execute against with order .
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With