learn-ansible

Learning Ansible

View the Project on GitHub robertdebock/learn-ansible

Throttle

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:

Assignment

Write a playbook that has a couple of tasks:

  1. Print “Hello World!”.
  2. Use the 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.

Solution

This assignment is a little more open/difficult. Have a quick look here for a possible solution.