2
votes

I'm using Ansible 2.1. Let's say my hosts are already grouped in inventory. Then I run a playbook like this:

- hosts: foo
  roles:
    - bar

- hosts: baz
  roles:
    - eek

...more...

Ansible seems to apply the roles one by one, no matter how many forks I have set. Is there a better way to structure my playbooks to gain more execution parallelism without spamming the console with useless task-skipped messages?

In other words, so role bar applies to all the hosts in foo at the same time as eek applies to all the baz hosts. It seems to kind of work if I apply roles conditional on group membership, however all the skipping makes the output really hard to read.

1

1 Answers

1
votes

If it is just the skipped tasks in the output that bothers you, you could set display_skipped_hosts=False in your ansible.cfg.

If set to False, ansible will not display any status for a task that is skipped. The default behavior is to display skipped tasks.

The problem with this might be, that this removes all skipped task output. In some cases the user might rely on skipped tasks and it's required to understand what's going on. There might be an option to solve this programatically. Create a custom callback plugin. The output generated by Ansible actually is a callback plugin. You can change this default callback plugin by changing stdout_callback = your_plugin in your ansible.cfg. In your plugin you then can decide under which conditions you want to show output or not.

Changing the strategy or even creating a custom strategy plugin might also be interesting for you. Though as far as I understand it, strategies are applied per play, so there is no way to make two plays execute in parallel and I'm pretty sure the 2nd play will only start when all hosts of the first play have finished. (but really, that's only my understanding, I have not yet played with strategy plugins)