debops / debops/debops

Nginx: Tag 'role::nginx:servers' no more applied?

Open
#2,469 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jinja
Stars
1.4k
Forks
379
Avg merge
4d 18h
Merged PRs (30d)
8

Description

Running a playbook with -t role::nginx:servers won't run the tasks included by include_tasks (by example nginx_servers.yml):

ansible-playbook playbooks/web.yml --diff -l glpi-test01 -t role::nginx:servers
#...
TASK [debops.debops.nginx : Generate nginx conf.d/ files] ****************************************************
included: /home/mathieu/.../debops/debops/roles/nginx/tasks/nginx_configs.yml for glpi-test01

TASK [debops.debops.nginx : Generate nginx server configuration] ****************************************************
included: /home/mathieu/.../debops/debops/roles/nginx/tasks/nginx_servers.yml for glpi-test01

PLAY RECAP ****************************************************
glpi-test01                : ok=5    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Adding apply parameter to tasks seems to fixes the problem:

 - name: Generate nginx server configuration
-  ansible.builtin.include_tasks: 'nginx_servers.yml'
+  ansible.builtin.include_tasks:
+    file: 'nginx_servers.yml'
+    apply:
+      tags: [ 'role::nginx:servers' ]
   tags: [ 'role::nginx:servers' ]
   when: (nginx__deploy_state in ['present', 'config'])

The tasks now get included and played correctly.

It seems that this has changed since Debops moved from include to ansible.builtin.include_tasks, maybe?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ansible/roles/nginx/tasks/main.yml at the include_tasks entries for nginx_configs.yml and nginx_servers.yml, then review the included task files. Reproduce the reported playbook command with the role::nginx:servers tag and verify that the nginx server configuration tasks are executed; done means the tag works as described without unrelated tasks running.

Written by the indexing model from the issue text.

Assessment

Tech stack
ansible
Domain
devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.