ansible / ansible

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
https://www.ansible.com/
GNU General Public License v3.0
62.3k stars 23.8k forks source link

if ansible.builtin.fileglob plugin is used in ansible.builtin.template, it searches under files/ #83421

Open msoltyspl opened 3 months ago

msoltyspl commented 3 months ago

Summary

If ansible.builtin.fileglob plugin is used in ansible.builtin.template - whether it's via loop+query() or via with_fileglob:, it searches under files/ instead of templates/ when used inside a role.

It also requires at least ./ prepended to search at all.

Issue Type

Bug Report

Component Name

ansible.builtin.fileglob, ansible.builtin.template

Ansible Version

ansible [core 2.17.0]
  config file = /home/nozo/iliad/nussknacker-ansible/ansible.cfg
  configured module search path = ['/home/nozo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/nozo/iliad/nussknacker-ansible/ans/lib/python3.12/site-packages/ansible
  ansible collection location = /home/nozo/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/nozo/iliad/nussknacker-ansible/ans/bin/ansible
  python version = 3.12.3 (main, Apr 23 2024, 09:16:07) [GCC 13.2.1 20240417] (/home/nozo/iliad/nussknacker-ansible/ans/bin/python)
  jinja version = 3.1.4
  libyaml = True

Configuration

ANSIBLE_NOCOWS(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = True
CONFIG_FILE() = /home/nozo/iliad/nussknacker-ansible/ansible.cfg
DEFAULT_PRIVATE_ROLE_VARS(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = True
DEFAULT_VAULT_PASSWORD_FILE(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = /home/nozo/iliad/nussknacker-ansible/.vault_password
DISPLAY_SKIPPED_HOSTS(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = True
EDITOR(env: EDITOR) = vim
HOST_KEY_CHECKING(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = False

CALLBACK:
========

default:
_______
display_skipped_hosts(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = True

CONNECTION:
==========

paramiko_ssh:
____________
host_key_checking(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = False
ssh_args(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = -C -o ControlMaster=auto -o ControlPersist=3600s -o ServerAliveInterval=60

ssh:
___
host_key_checking(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = False
pipelining(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = True
ssh_args(/home/nozo/iliad/nussknacker-ansible/ansible.cfg) = -C -o ControlMaster=auto -o ControlPersist=3600s -o ServerAliveInterval=60

OS / Environment

Archlinux

Steps to Reproduce

- name: Prepare .bashrc.d files
  ansible.builtin.template:
    src: "{{ item }}"
    dest: "/home/{{ nu_user }}/.bashrc.d/"
    owner: "{{ nu_user }}"
    group: "{{ nu_group }}"
    mode: '0644'
  loop: "{{ query('ansible.builtin.fileglob', './[0-9][0-9]-bashrc*.sh') }}"

Expected Results

Fileglob plugin while called in context of template should search under templates. Prepending ./ to the glob probably shouldn't be necessary either.

Actual Results

TASK [common : Prepare .bashrc.d files] ***********************************************************************************************************************************************
task path: /home/nozo/iliad/nussknacker-ansible/roles/common/tasks/main.yml:35
looking for "." at "/home/nozo/iliad/nussknacker-ansible/roles/common/files/."
looking for "." at "/home/nozo/iliad/nussknacker-ansible/roles/common/."
skipping: [nuans5] => {
    "changed": false,
    "skipped_reason": "No items in the list"
}

Code of Conduct

ansibot commented 3 months ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the component bot command.