1

I am trying to set up a system with multiple roles (e.g., webserver, database-server, mailserver etc.)

Each of the roles requires the installation of some software packages defined as their own task in the main.yml for each role.

Does ansible have a way to detect (or explicitly state it in a task) that in a certain play there will be multiple package installs and allow batching them together and skipping the later install steps?

bentek
  • 2,235
  • 1
  • 15
  • 23
John Nemo
  • 17
  • 3

1 Answers1

1

An option would be to tag the installation tasks and install the packages as a 1st step:

ansible-playbook webserver.yml -t install_packages
ansible-playbook dbserver.yml -t install_packages
ansible-playbook mailserver.yml -t install_packages

Then run the plays:

ansible-playbook webserver.yml
ansible-playbook dbserver.yml
ansible-playbook mailserver.yml

If you want to speed-up the plays and conditionally skip the installations you might want to create and set a variable for this purpose (when: skip_install).

ansible-playbook -e skip_install=True ...
Vladimir Botka
  • 5,138
  • 8
  • 20
  • Since it is not a direct capability and as @Michael Hampton points out is probably not desirable, I'll acceppt this approximation as an answer – John Nemo Jul 22 '18 at 12:30