shell module variables

Im trying to read a file line by line and pass it to a shell module
Is this completely wrong or i just have to find a way to make the wildcard and string to match .

  • name: remove older files
    shell: ls “{{item}}.jar
    with_lines: cat file11/branches.txt

Im trying to read a file line by line and pass it to a shell module
Is this completely wrong or i just have to find a way to make the wildcard and string to match .

- name: remove older files
shell: ls "*{{item}}.jar*"
with_lines: cat file11/branches.txt

Why don't you remove the files immediately with the file module?

Shell module shall be last resort.

Regards
        Racke

I couldnt search using matching string . in the below case it runs fine without the wildcards * , but with wildcards it fails . tried few other approaches .cdnt find a proper solution

  • name: Find /var/log files equal or greater than 10 megabytes ending with .old or .log.gz
    find:
    paths: /home/tagit/test
    patterns: ‘“{{item}}”
    with_lines: cat file11/branches.txt

I couldnt search using matching string . in the below case it runs fine without the wildcards * , but with wildcards
it fails . tried few other approaches .cdnt find a proper solution

- name: Find /var/log files equal or greater than 10 megabytes ending with .old or .log.gz
find:
paths: /home/tagit/test
patterns: '*"{{item}}"*'
with_lines: cat file11/branches.txt

Drop the " as they will be literally passed to the module. Jinja variables work the same in ' as in ".

Regards
         Racke

Alternate solutions aside, your issue is with shell globbing, you are
quoting the *

shell: ls "*{{item}}.jar*"

vs

shell: ls *{{item}}.jar*