Role dependencies are not run when running playbook with --tags that specify tagged tasks within role #20119

Open
msanabria opened this Issue Jan 11, 2017 · 0 comments

Projects

None yet

3 participants

@msanabria

ISSUE TYPE

  • Bug Report

ANSIBLE VERSION

ansible 2.2.0.0
  config file = /home/msanabria/repos/ansible-workstation/ansible.cfg
  configured module search path = Default w/o overrides

CONFIGURATION

ansible.cfg:

[defaults]
ansible_managed = This file is managed by Ansible. All changes will be overwritten.
inventory = hosts.yml
retry_files_enabled = false

[privilege_escalation]
become_ask_pass = True

OS / ENVIRONMENT

  • Control node:
    Fedora release 25 (Twenty Five)
  • Managed node:
    Fedora release 25 (Twenty Five)

SUMMARY

When running a playbook with --tags options that specifies a tag of a task or tasks within a role, any dependencies of that role are not executed.

STEPS TO REPRODUCE

tree:

.
├── ansible.cfg
├── hosts.yml
├── roles
│   ├── apps
│   │   ├── meta
│   │   │   └── main.yml
│   │   └── tasks
│   │       ├── chrome.yml
│   │       └── main.yml
│   └── common
│       ├── meta
│       │   └── main.yml
│       └── tasks
│           └── main.yml
└── workstation_setup.yml

hosts.yml

[workstation]
localhost ansible_connection=local

roles/apps/meta/main.yml

---
dependencies:
  - { role: common }

roles/apps/tasks/chrome.yml

---
- name: Install Google Chrome
  dnf:
    ...

roles/apps/tasks/main.yml

---
- name: Include chrome.yml
  include: chrome.yml
  tags:
    - chrome

roles/common/meta/main.yml

---
allow_duplicates: yes

roles/common/tasks/main.yml

---
- name: Install common packages
  dnf:
    ...

workstation_setup.yml

---
- name: Playbook to configure a Fedora workstation
  hosts: workstation
  become: yes

  roles:
    - { role: common }
    - { role: apps }
EXPECTED RESULTS

Expected Ansible to execute the dependency of the role with the tagged task(s).

$ ansible-playbook workstation_setup.yml --tags chrome --list-tasks 

playbook: workstation_setup.yml

  play #1 (workstation): Playbook to configure a Fedora workstation	TAGS: []
    tasks:
      common : Install common packages	TAGS: []
      apps : Install Google Chrome	TAGS: [chrome]
ACTUAL RESULTS

Ansible only executes the tagged task(s) and not any dependencies.

$ ansible-playbook workstation_setup.yml --tags chrome --list-tasks

playbook: workstation_setup.yml

  play #1 (workstation): Playbook to configure a Fedora workstation	TAGS: []
    tasks:
      apps : Install Google Chrome	TAGS: [chrome]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment