ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
14k stars 3.42k forks source link

job tags not working with tags in roles/tasks #10228

Open dat1041988 opened 3 years ago

dat1041988 commented 3 years ago
ISSUE TYPE
SUMMARY

I create a template to run an ansible playbook with job tags. When I run it, ansible-playbook run all tasks in roles, not specific tasks with tags. Job tags is working with tasks in main playbook file, but not working with tasks in roles.

ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS

Job run ansible-playbook with specific tasks in roles.

ACTUAL RESULTS

Job run ansible-playbook with all tasks in roles.

ADDITIONAL INFORMATION
wenottingham commented 3 years ago

Check https://docs.ansible.com/ansible/latest/user_guide/playbooks_tags.html#adding-tags-to-roles, I'd expect you're adding the tags to the role import, which applies it to all tasks in the role.

dat1041988 commented 3 years ago

@wenottingham Thanks for reply! I don't add tags to role import. Our playbook:

bash-4.4# cat vcd.yml

And in vappvm role tasks, I add "create-master" tag to individual tasks. Already try include_role in playbook but result is the same.

ghost commented 3 years ago

I'm having a similar issue with AWX 15.1 not respecting tags in the roles: section of my playbook. My understanding is that tags applied to roles in the roles: section are inherited to all role's tasks, and in fact results in expected behavior when running ansible-playbook from cli (--skip-tags=ipxe_sync,image_sync skips the entire roles in the following code snippit)

---
- hosts: all
  gather_facts: yes
  roles:
    - role: facts
      tags: custom_facts
    - role: ipxe
      tags: ipxe_sync
    - role: automaticupdates
    - role: win10image
      tags: image_sync

When I run a job template from AWX using the same tags in the Skip Tags field, these tags show up and are displayed on the details of the job, but then the output still shows each role running instead of being skipped.