This is a question of good practise:
I do have logic “Lines” on a way from my LB to Backend
[LineA]
proxyA app_type=proxy
frontendA app_type=frontend
middlewareA app_type=middleware
[LineB]
proxyB app_type=proxy
…
Since the apps are more complex than simple apache start stop. i did write custom modules with required logic to controll them:
proxysrv: with actions [suspend, activate]
restart: with actions [start, stop, restart], and app_type arguments [frontend, middleware]
The tasks have to be played in certain order (suspend proxy, restart frontends and middleware, activate proxy)
Now I can have a play like:
- hosts: LineA
- tasks:
- name:
proxysrv: action=suspend, when app_type ==‘proxy’- name:
restart: action=restart, app_type=frontend, when app_type ==‘frontend’- name:
restart: action=restart, app_type=middleware, when app_type ==‘middleware’- name:
proxysrv: action=activate, when app_type ==‘proxy’
I don’t like the “skipped” message during the run of a playbook, and the numbers in the final play statistics, that count the skipped hosts (as not changed).
This is a question of good practise:
How would You create dependencies, that would apply specialized tasks on a subset of Your hosts group.
I guess that better way to solve the problem would be the use of delegate_to (probably with “with_items” or “tags”).
I could register the ‘proxy_hosts’, ‘frontend_hosts’, ‘middleware_hosts’ variables during an execution of the play and run tasks against them.
I do not see yet use of tags here, the example would be nice.
Any better idea?
What about roles. I would like to have a roles (proxy, restart role) and run them against subset of a hosts.