I have a large role, which I will break down into separate roles eventually.
For the moment, I am trying to use tags to selectively run bits of it, tagged e.g. “server”, “portal” etc.
The role is called from this playbook:
I have a large role, which I will break down into separate roles eventually.
For the moment, I am trying to use tags to selectively run bits of it, tagged e.g. “server”, “portal” etc.
The role is called from this playbook:
Possibly bad form to reply to one’s own query, but I think I worked it out.
Rather than tag every task inside the role, I split the big role up into four. I removed ALL the tagging from inside the roles, and set up this little playbook:
Possibly bad form to reply to one's own query, but I think I worked it out.
It's not, it's encouraged when you have an answer.
People don't waste time answering and other might have the same question also get an answer, so it's a win win.
Rather than tag every task inside the role, I split the big role up into
four. I removed ALL the tagging from inside the roles, and set up this
little playbook:---
- hosts: localhost
connection: local
gather_facts: falsepre_tasks:
- include_vars: blah_envs/{{env}}.yaml
tags: always
- include_vars: blah_envs/common.yaml
tags: alwaysroles:
- { role: blah_server, tags: [ server ] }
- { role: blah_portal, tags: [ portal ] }
- { role: blah_alb, tags: [ alb ] }
- { role: blah_asg, tags: [ asg ] }... and now it all works as desired. The real breakthrough was figuring out
that include_vars is a task
You can use vars_files insted for include_vars, then you don't need to tag them since they are always read.
- hosts: localhost
connection: local
gather_facts: false
vars_files:
- blah_envs/{{env}}.yaml
- blah_envs/common.yaml