On 30. nov. 2016 03:29, stewart.p...@gmail.com wrote:
I've created a small demo below which demonstrates my problem.
I can't seem to invoke the with_items and call {{item}} later on. What am I
doing wrong? I've tried searching obviously but I can't find the direct
answer, sorry for the newbie question.

My playbook invokes a role, and below is my role:
  - name: Mytest to register a variable
    find: paths="/tmp/demo/" patterns="*.txt"
    register: r

  - name: mytest to show my results
    debug: msg="{{item}}"
    with_items: r

The above doesn't give the desired result. When i change my task mytest
  - name: mytest
    debug: msg={{r.files.0.path}}
then i do get the first .txt file found, I can't seem to make it

- name: mytest to show my results
  debug: msg="{{ item.path }}"
  with_items: r.files

Ultimately I'm trying to create a loop true a directory, and based on the
file extension I want to invoke a certain action. For example, if the file
extension is .sh, then invoke shell. If it's .sql, then invoke sqlplus, and
more extensions. If the extension is not listed then copy the file. Perhaps
my whole approach is wrong in the first place, I'm trying to take it step
by step of course, which might lead me in a wrong direction?

It sounds like a wrong approach, but that doesn't mean that is wrong.
But there may be better ways reach your objective.

You could try explaining what you are trying to achieve and maybe someone on the list could help you toward a more correct direction.

Kai Stian Olstad

You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to