Hello! Our company is moving to Ansible from SaltStack and iβve been tearing my hair out over this one thing that i cannot really seem to figure out how to do!
Basically this is the code:
- name: Template example pipeline input
ansible.builtin.template:
src: "{{ item }}"
dest: "/opt/docker/fluent-bit/{{ logging_fluent_bit_role }}/pipelines/{{ item.path | basename }}"
owner: ubuntu
group: ubuntu
mode: "0655"
with_fileglob:
- "templates/pipelines/example/*"
notify: Restart Fluent Bit container
We are using roles so this is the basic filestructure:
llt -D -L2
.
βββ defaults
βββ files
β βββ agent
β βββ aggregator
βββ handlers
βββ tasks
βββ templates
βββ config
βββ pipelines
βββ example
β βββ input
βββ not_this_one
βββ input
So what i want to achieve is for ansible.builtin.template to find all directories under βtemplates/pipelines/example/β, render the template and send it to itβs dest
on the target.
However the list of directories in βtemplates/pipelines/exampleβ is always empty. Iβve been googling around on how to loop through directories in ansible but most of the answers are related to finding files.
TASK [../roles/logging_fluent_bit : Template example pipeline input] *************************************************************************************
task path: /home/vinylen/work/ansible/ansible-environment/roles/logging_fluent_bit/tasks/main.yml:66
looking for "templates/pipelines/example" at "/home/vinylen/work/ansible/ansible-environment/roles/logging_fluent_bit/files/templates/pipelines/example"
looking for "templates/pipelines/example" at "/home/vinylen/work/ansible/ansible-environment/roles/logging_fluent_bit/templates/pipelines/example"
skipping: [example-server.example.com] => {
"changed": false,
"skipped_reason": "No items in the list"
}
I would greatly appreciate any help.
Thanks