On 10.05.2018 16:42, Saranya N wrote:
I want to replicate a shell script that loops through the contents of
a text.file
For i in `cat text.file`

I tried below and got an error.
 I'm not getting which logic to use. Kindly advise.

- name: Load the variables

    include_vars:

     file: /home/devuser/internproj/inventories/NP/voblist.yml

    register: dits_list

include_vars read the variable inside the file and make them available for Ansible so no need for the register.


  - debug:

     msg: "{{ dits_list.ansible_facts }}"



  - name: run the tool commands

shell: /usr/atria/bin/sertool -load -host aaa {{ items }} {{ items }}

    args:

     chdir: "/home/vobadmin"

     with_items: "{{ vob_list.dits }}" #How to achieve this part?

  - name: run the tool commands
    shell: /usr/atria/bin/sertool -load -host aaa {{ item }} {{ item }}
    args:
      chdir: "/home/vobadmin"
    with_items: "{{ dits }}"



I want to pass the contents of the voblist to the shell module to
excute the above shell command.

Basically I want to replicate the below shell script

For i in `cat /home/devuser/internproj/inventories/NP/voblist.yml`

Do

/usr/atria/bin/sertool -load -host aaa $i $i

Done

if



===========================================================================================================

cat /home/devuser/internproj/inventories/NP/voblist.yml

---

dits:



- /project/vob_solaris_test.vbs

- /project/vob_solaris_test2.vbs

That for loop doesn't make sense with that file.
On fist loop it would contain "---", and the second it would contain "dist:" and third "- /project/vob_solaris_test.vbs".

--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/04043f06f3bd49a4e34358cca5ad3078%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to