I run my playbook a.yaml, and in a.yaml I want to include one or more tasks from b.yaml.
First, I tried put following on a.yaml:
import_playbook: b.yaml --tags "tag1"
But this errors out saying the --tags doesn't apply to import_playbook.
Based on latest Ansible include_tasks documentation, I tried with following:
a.yaml:
- include_tasks:
file: b.yaml
apply:
tags: tag1
b.yaml:
- shell: echo $HOSTNAME
register: hostname
tags: tag1
- debug:
msg: "task2"
tags: tag2
But both tasks in b.yaml got invoked though I only expected the first as tag indicated.
Questions:
- How to have tags passed from
a.yamltob.yamland get recognized? I don't mind to use something else if include_tasks is not the solution. - How to pass the result (the hostname, or any result) from
b.yamlback to callera.yaml?