- name: Load the variables
include_vars:
file: /home/devuser/internproj/inventories/NP/voblist.yml
register: dits_list
- 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?
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
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/82f6779b-c698-44f0-81b5-37de10960a4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The shell command is for a tool.
But the logic I'm trying to execute is very simple.
List all the files such that the files' names contains the words present in dits list which I'm sending via the include_vars file.
I'm seriously not understanding whats going wrong here.
I get dits is not defined error like below.
task path: /home/devuser/ansible_test/ansible_dev/clearcase/playbooks/simple.yml:15
fatal: [aaa.com]: FAILED! => {
"failed": true,
"msg": "'dits' is undefined"
}
to retry, use: --limit @/home/devuser/ansible_test/ansible_dev/clearcase/playbooks/simple.retry
PLAY RECAP ****************************************************************************************************************************************************************************************************
aaa.com : ok=1 changed=0 unreachable=0 failed=1
---
- hosts: sol
become: yes
become_method: su
become_user: vobadmin
gather_facts: no
tasks:
- name: Load the variables
include_vars:
file: /home/devuser/ansible_test/ansible_dev/clearcase/inventories/NP/voblist.yml
name: localvar
- name: List id
shell: ls -ltr | grep -i {{ item }}
register: shell_op
with_items: "{{ dits }}"
- debug:
msg: "{{ localvar.dits }}"
cat /home/devuser/internproj/inventories/NP/voblist.yml
dits:
- aaa
- bbb
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/39cebb74-d52a-4690-a0ca-febe264fe248%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The location in playbook and the actual file is same.
Since dits is a list I had to use like below.
With_items: "{{ dits | list }}"