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