Skip to content

Tags not working #189

@tungduong1809

Description

@tungduong1809

Tag doesn't work when i run playbook

  • Playbook
    main.yml
- name: Install and configure pdns
  hosts: pdns_cluster
  become: true
  gather_facts: false
  any_errors_fatal: true
  roles:
    - role: pdns-ansible

When a matching tag is passed in, the role is run, but when running to the task containing the install tag or any other tag in the role, it is skipped

ansible-playbook -i inventories/production/hosts main.yml -t install

PLAY [Install and configure pdns] ****************************************************************************************************************************

TASK [pdns-ansible : Include OS-specific variables] **********************************************************************************************************
ok: [pdns-01] => (item=/home/idg/tungnt/roles/pdns-ansible/vars/Debian.yml)
ok: [pdns-02] => (item=/home/idg/tungnt/roles/pdns-ansible/vars/Debian.yml)

TASK [pdns-ansible : include_tasks] **************************************************************************************************************************
skipping: [pdns-01]
skipping: [pdns-02]

TASK [pdns-ansible : include_tasks] **************************************************************************************************************************
included: /home/idg/tungnt/roles/pdns-ansible/tasks/install.yml for pdns-01, pdns-02

PLAY RECAP ***************************************************************************************************************************************************
pdns-01                    : ok=5    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
pdns-02                    : ok=5    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

I researched and learned that the tag in include_tasks will not be executed if the tag is not placed both outside and in include_tasks
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_tags.html#selectively-running-tagged-tasks-in-re-usable-files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions