Learning Ansible
Besides serial
, you can use thottle
to limit the number of nodes that are targeted at the same time for a task or block.
- name: Do something on the webservers hosts
hosts: all
tasks:
- name: Say something
debug:
msg: "Hello world!"
- name: Simulate an intensive job
ansible.builtin.pause:
seconds: 3
throttle: 1
- name: Say something else
debug:
msg: "Hello world again!"
This can be used when a job consumes resources which could break some central component. Examples could be:
Write a playbook that has a couple of tasks:
find
module to find all files on the managed nodes in the /opt
directory. This is a filesystem-intensive task. Using throttle
helps to prevent disk io saturation.This assignment is a little more open/difficult. Have a quick look here for a possible solution.