Re: [ansible-project] Unable to read variable in a loop using include_vars.

2020-03-03 Thread Shifa Shaikh
The reason for grabbing the ls output across servers is for audit purpose. 
The output of ls is send as reports and audit team uses the ls output 
reports to do random checks on the server.

On Tuesday, March 3, 2020 at 3:29:01 PM UTC+5:30, Stefan Hornburg (Racke) 
wrote:
>
> On 3/3/20 10:53 AM, Shifa Shaikh wrote: 
> > I need to get the output of ls command from list of remote ips and under 
> each ip there is are different directories. The 
> > output of ls command needs to be saved in a file and the name of the 
> file should be the value of ccode variable under 
> > the variable. 
> > 
> > Thus my variable file has ip listed. Under each ip is the list of 
> directories with name and path variables and finally 
> > the entire output of all the ls commands on all the directories for that 
> ip is stored in a file with ccode variable. 
> > 
> > Hope the requirement is clear now. 
>
> It is still unclear what you are going to do with the ls output. Also I 
> would recommend to use the find module instead 
> of ls on the target. 
>
> Regards 
>Racke 
>
> > 
> > On Tue, 3 Mar, 2020, 2:55 pm Dick Visser,   > wrote: 
> > 
> > I meant HIGH level. 
> > You are using ansible to achieve something - what is that? 
> > 
> > On Tue, 3 Mar 2020 at 09:20, Shifa Shaikh   > wrote: 
> > > 
> > > Under an ip I want a variable ccode which will be global variable 
> for that ip. 
> > > 
> > > I also want variable name & path which will have multiple entries. 
> > > 
> > > How can I read both single global and multiple variables name and 
> path under a given IP ? 
> > > 
> > > On Tue, 3 Mar, 2020, 1:26 pm Dick Visser,   > wrote: 
> > >> 
> > >> Can you tell what is the big picture? What task is this intended 
> for? 
> > >> 
> > >> On Tue, 3 Mar 2020 at 05:43, Shifa Shaikh   > wrote: 
> > >>> 
> > >>> Below is my playbook which loads variables and passes it to ls 
> command on remote hosts. 
> > >>> 
> > >>>- name: Load repository 
> > >>>  include_vars: 
> > >>>file="{{ playbook_dir }}/vars/listing.yml" 
> > >>>name=user1 
> > >>> 
> > >>> 
> > >>>- set_fact: 
> > >>>allinonecmd: "{{ allinonecmd | default('') + 'ls -ltr ' + 
> item.path + ' '}}" 
> > >>>  loop: "{{ user1[inventory_hostname] }}" 
> > >>> 
> > >>>- name: Get stat 
> > >>>  shell: "ssh {{ USER }}@{{ inventory_hostname }} '{{ 
> allinonecmd }}' >/web/htdocs/{{ item.ccode }}{{ 
> > item.ipseg }}.html" 
> > >>>  delegate_to: localhost 
> > >>>  loop: "{{ user1[inventory_hostname] }}" 
> > >>> 
> > >>> 
> > >>> below is my listing.yml 
> > >>> 10.0.0.15 : 
> > >>>   - name: SCRIPT 
> > >>> path: /tmp/scripts 
> > >>> ccode: GRM-APP- 
> > >>> ipseg: "0.15" 
> > >>>   - name: MOC 
> > >>> path: /tmp/moc 
> > >>>   - name: EXE 
> > >>> path: /tmp/exe 
> > >>>   - name: MTR 
> > >>> path: /tmp/mtr 
> > >>> 
> > >>> 
> > >>> This worked fine without ccode and ipseg entries in the 
> listing.yml. I have multiple entries for path which i 
> > loop over and construct the allinonecmd string but the ccode is just 
> needed once. 
> > >>> 
> > >>> I get this error with a single entry of ccode in listing.yml 
> > >>> 
> > >>> fatal: [10.0.0.15]: FAILED! => { 
> > >>> "msg": "The task includes an option with an undefined 
> variable. The error was: 'dict object' has no 
> > attribute 'ccode' 
> > >>> 
> > >>> 
> > >>> For my existing playbook to work i have to specify ccode and 
> ipseg under each entry like below which works but 
> > looks ugly. It should be specified just one time and the playbook 
> should work. 
> > >>> 
> > >>> 10.0.0.15 : 
> > >>>   - name: SCRIPT 
> > >>> path: /tmp/scripts 
> > >>> ccode: GRM-APP- 
> > >>> ipseg: "0.15" 
> > >>>   - name: MOC 
> > >>> path: /tmp/moc 
> > >>> ccode: GRM-APP- 
> > >>> ipseg: "0.15" 
> > >>>   - name: EXE 
> > >>> path: /tmp/exe 
> > >>> ccode: GRM-APP- 
> > >>> ipseg: "0.15" 
> > >>>   - name: MTR 
> > >>> path: /tmp/mtr 
> > >>> ccode: GRM-APP- 
> > >>> ipseg: "0.15" 
> > >>> 
> > >>> 
> > >>> Can you please suggest a clean way to get this to work  ? 
> > >>> 
> > >>> -- 
> > >>> 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...@googlegroups.com   ansible-project%2bunsubscr...@googlegroups.com >. 
> > >>> To view this discussion 

Re: [ansible-project] Unable to read variable in a loop using include_vars.

2020-03-03 Thread Shifa Shaikh
The reason for grabbing the ls output across servers is for audit purpose.
The audit team randomly checks for this output with the server.



On Tue, 3 Mar, 2020, 3:29 pm Stefan Hornburg (Racke), 
wrote:

> On 3/3/20 10:53 AM, Shifa Shaikh wrote:
> > I need to get the output of ls command from list of remote ips and under
> each ip there is are different directories. The
> > output of ls command needs to be saved in a file and the name of the
> file should be the value of ccode variable under
> > the variable.
> >
> > Thus my variable file has ip listed. Under each ip is the list of
> directories with name and path variables and finally
> > the entire output of all the ls commands on all the directories for that
> ip is stored in a file with ccode variable.
> >
> > Hope the requirement is clear now.
>
> It is still unclear what you are going to do with the ls output. Also I
> would recommend to use the find module instead
> of ls on the target.
>
> Regards
>Racke
>
> >
> > On Tue, 3 Mar, 2020, 2:55 pm Dick Visser,  > wrote:
> >
> > I meant HIGH level.
> > You are using ansible to achieve something - what is that?
> >
> > On Tue, 3 Mar 2020 at 09:20, Shifa Shaikh  > wrote:
> > >
> > > Under an ip I want a variable ccode which will be global variable
> for that ip.
> > >
> > > I also want variable name & path which will have multiple entries.
> > >
> > > How can I read both single global and multiple variables name and
> path under a given IP ?
> > >
> > > On Tue, 3 Mar, 2020, 1:26 pm Dick Visser,  > wrote:
> > >>
> > >> Can you tell what is the big picture? What task is this intended
> for?
> > >>
> > >> On Tue, 3 Mar 2020 at 05:43, Shifa Shaikh  > wrote:
> > >>>
> > >>> Below is my playbook which loads variables and passes it to ls
> command on remote hosts.
> > >>>
> > >>>- name: Load repository
> > >>>  include_vars:
> > >>>file="{{ playbook_dir }}/vars/listing.yml"
> > >>>name=user1
> > >>>
> > >>>
> > >>>- set_fact:
> > >>>allinonecmd: "{{ allinonecmd | default('') + 'ls -ltr ' +
> item.path + ' '}}"
> > >>>  loop: "{{ user1[inventory_hostname] }}"
> > >>>
> > >>>- name: Get stat
> > >>>  shell: "ssh {{ USER }}@{{ inventory_hostname }} '{{
> allinonecmd }}' >/web/htdocs/{{ item.ccode }}{{
> > item.ipseg }}.html"
> > >>>  delegate_to: localhost
> > >>>  loop: "{{ user1[inventory_hostname] }}"
> > >>>
> > >>>
> > >>> below is my listing.yml
> > >>> 10.0.0.15 :
> > >>>   - name: SCRIPT
> > >>> path: /tmp/scripts
> > >>> ccode: GRM-APP-
> > >>> ipseg: "0.15"
> > >>>   - name: MOC
> > >>> path: /tmp/moc
> > >>>   - name: EXE
> > >>> path: /tmp/exe
> > >>>   - name: MTR
> > >>> path: /tmp/mtr
> > >>>
> > >>>
> > >>> This worked fine without ccode and ipseg entries in the
> listing.yml. I have multiple entries for path which i
> > loop over and construct the allinonecmd string but the ccode is just
> needed once.
> > >>>
> > >>> I get this error with a single entry of ccode in listing.yml
> > >>>
> > >>> fatal: [10.0.0.15]: FAILED! => {
> > >>> "msg": "The task includes an option with an undefined
> variable. The error was: 'dict object' has no
> > attribute 'ccode'
> > >>>
> > >>>
> > >>> For my existing playbook to work i have to specify ccode and
> ipseg under each entry like below which works but
> > looks ugly. It should be specified just one time and the playbook
> should work.
> > >>>
> > >>> 10.0.0.15 :
> > >>>   - name: SCRIPT
> > >>> path: /tmp/scripts
> > >>> ccode: GRM-APP-
> > >>> ipseg: "0.15"
> > >>>   - name: MOC
> > >>> path: /tmp/moc
> > >>> ccode: GRM-APP-
> > >>> ipseg: "0.15"
> > >>>   - name: EXE
> > >>> path: /tmp/exe
> > >>> ccode: GRM-APP-
> > >>> ipseg: "0.15"
> > >>>   - name: MTR
> > >>> path: /tmp/mtr
> > >>> ccode: GRM-APP-
> > >>> ipseg: "0.15"
> > >>>
> > >>>
> > >>> Can you please suggest a clean way to get this to work  ?
> > >>>
> > >>> --
> > >>> 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  ansible-project%2bunsubscr...@googlegroups.com>.
> > >>> To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/2d8d2651-2ffc-4f36-b565-0df941508cbb%40googlegroups.com
> .
> > >>
> > >> --
> > >> Sent 

Re: [ansible-project] Unable to read variable in a loop using include_vars.

2020-03-03 Thread Stefan Hornburg (Racke)
On 3/3/20 10:53 AM, Shifa Shaikh wrote:
> I need to get the output of ls command from list of remote ips and under each 
> ip there is are different directories. The
> output of ls command needs to be saved in a file and the name of the file 
> should be the value of ccode variable under
> the variable.
> 
> Thus my variable file has ip listed. Under each ip is the list of directories 
> with name and path variables and finally
> the entire output of all the ls commands on all the directories for that ip 
> is stored in a file with ccode variable.
> 
> Hope the requirement is clear now.

It is still unclear what you are going to do with the ls output. Also I would 
recommend to use the find module instead
of ls on the target.

Regards
   Racke

> 
> On Tue, 3 Mar, 2020, 2:55 pm Dick Visser,  > wrote:
> 
> I meant HIGH level.
> You are using ansible to achieve something - what is that?
> 
> On Tue, 3 Mar 2020 at 09:20, Shifa Shaikh  > wrote:
> >
> > Under an ip I want a variable ccode which will be global variable for 
> that ip.
> >
> > I also want variable name & path which will have multiple entries.
> >
> > How can I read both single global and multiple variables name and path 
> under a given IP ?
> >
> > On Tue, 3 Mar, 2020, 1:26 pm Dick Visser,  > wrote:
> >>
> >> Can you tell what is the big picture? What task is this intended for?
> >>
> >> On Tue, 3 Mar 2020 at 05:43, Shifa Shaikh  > wrote:
> >>>
> >>> Below is my playbook which loads variables and passes it to ls 
> command on remote hosts.
> >>>
> >>>    - name: Load repository
> >>>      include_vars:
> >>>        file="{{ playbook_dir }}/vars/listing.yml"
> >>>        name=user1
> >>>
> >>>
> >>>    - set_fact:
> >>>        allinonecmd: "{{ allinonecmd | default('') + 'ls -ltr ' + 
> item.path + ' '}}"
> >>>      loop: "{{ user1[inventory_hostname] }}"
> >>>
> >>>    - name: Get stat
> >>>      shell: "ssh {{ USER }}@{{ inventory_hostname }} '{{ allinonecmd 
> }}' >/web/htdocs/{{ item.ccode }}{{
> item.ipseg }}.html"
> >>>      delegate_to: localhost
> >>>      loop: "{{ user1[inventory_hostname] }}"
> >>>
> >>>
> >>> below is my listing.yml
> >>> 10.0.0.15 :
> >>>   - name: SCRIPT
> >>>     path: /tmp/scripts
> >>>     ccode: GRM-APP-
> >>>     ipseg: "0.15"
> >>>   - name: MOC
> >>>     path: /tmp/moc
> >>>   - name: EXE
> >>>     path: /tmp/exe
> >>>   - name: MTR
> >>>     path: /tmp/mtr
> >>>
> >>>
> >>> This worked fine without ccode and ipseg entries in the listing.yml. 
> I have multiple entries for path which i
> loop over and construct the allinonecmd string but the ccode is just 
> needed once.
> >>>
> >>> I get this error with a single entry of ccode in listing.yml
> >>>
> >>> fatal: [10.0.0.15]: FAILED! => {
> >>>     "msg": "The task includes an option with an undefined variable. 
> The error was: 'dict object' has no
> attribute 'ccode'
> >>>
> >>>
> >>> For my existing playbook to work i have to specify ccode and ipseg 
> under each entry like below which works but
> looks ugly. It should be specified just one time and the playbook should 
> work.
> >>>
> >>> 10.0.0.15 :
> >>>   - name: SCRIPT
> >>>     path: /tmp/scripts
> >>>     ccode: GRM-APP-
> >>>     ipseg: "0.15"
> >>>   - name: MOC
> >>>     path: /tmp/moc
> >>>     ccode: GRM-APP-
> >>>     ipseg: "0.15"
> >>>   - name: EXE
> >>>     path: /tmp/exe
> >>>     ccode: GRM-APP-
> >>>     ipseg: "0.15"
> >>>   - name: MTR
> >>>     path: /tmp/mtr
> >>>     ccode: GRM-APP-
> >>>     ipseg: "0.15"
> >>>
> >>>
> >>> Can you please suggest a clean way to get this to work  ?
> >>>
> >>> --
> >>> 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 view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/ansible-project/2d8d2651-2ffc-4f36-b565-0df941508cbb%40googlegroups.com.
> >>
> >> --
> >> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
> >>
> >> --
> >> 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 
> 

Re: [ansible-project] Unable to read variable in a loop using include_vars.

2020-03-03 Thread Shifa Shaikh
I need to get the output of ls command from list of remote ips and under
each ip there is are different directories. The output of ls command needs
to be saved in a file and the name of the file should be the value of ccode
variable under the variable.

Thus my variable file has ip listed. Under each ip is the list of
directories with name and path variables and finally the entire output of
all the ls commands on all the directories for that ip is stored in a file
with ccode variable.

Hope the requirement is clear now.

On Tue, 3 Mar, 2020, 2:55 pm Dick Visser,  wrote:

> I meant HIGH level.
> You are using ansible to achieve something - what is that?
>
> On Tue, 3 Mar 2020 at 09:20, Shifa Shaikh  wrote:
> >
> > Under an ip I want a variable ccode which will be global variable for
> that ip.
> >
> > I also want variable name & path which will have multiple entries.
> >
> > How can I read both single global and multiple variables name and path
> under a given IP ?
> >
> > On Tue, 3 Mar, 2020, 1:26 pm Dick Visser,  wrote:
> >>
> >> Can you tell what is the big picture? What task is this intended for?
> >>
> >> On Tue, 3 Mar 2020 at 05:43, Shifa Shaikh  wrote:
> >>>
> >>> Below is my playbook which loads variables and passes it to ls command
> on remote hosts.
> >>>
> >>>- name: Load repository
> >>>  include_vars:
> >>>file="{{ playbook_dir }}/vars/listing.yml"
> >>>name=user1
> >>>
> >>>
> >>>- set_fact:
> >>>allinonecmd: "{{ allinonecmd | default('') + 'ls -ltr ' +
> item.path + ' '}}"
> >>>  loop: "{{ user1[inventory_hostname] }}"
> >>>
> >>>- name: Get stat
> >>>  shell: "ssh {{ USER }}@{{ inventory_hostname }} '{{ allinonecmd
> }}' >/web/htdocs/{{ item.ccode }}{{ item.ipseg }}.html"
> >>>  delegate_to: localhost
> >>>  loop: "{{ user1[inventory_hostname] }}"
> >>>
> >>>
> >>> below is my listing.yml
> >>> 10.0.0.15:
> >>>   - name: SCRIPT
> >>> path: /tmp/scripts
> >>> ccode: GRM-APP-
> >>> ipseg: "0.15"
> >>>   - name: MOC
> >>> path: /tmp/moc
> >>>   - name: EXE
> >>> path: /tmp/exe
> >>>   - name: MTR
> >>> path: /tmp/mtr
> >>>
> >>>
> >>> This worked fine without ccode and ipseg entries in the listing.yml. I
> have multiple entries for path which i loop over and construct the
> allinonecmd string but the ccode is just needed once.
> >>>
> >>> I get this error with a single entry of ccode in listing.yml
> >>>
> >>> fatal: [10.0.0.15]: FAILED! => {
> >>> "msg": "The task includes an option with an undefined variable.
> The error was: 'dict object' has no attribute 'ccode'
> >>>
> >>>
> >>> For my existing playbook to work i have to specify ccode and ipseg
> under each entry like below which works but looks ugly. It should be
> specified just one time and the playbook should work.
> >>>
> >>> 10.0.0.15:
> >>>   - name: SCRIPT
> >>> path: /tmp/scripts
> >>> ccode: GRM-APP-
> >>> ipseg: "0.15"
> >>>   - name: MOC
> >>> path: /tmp/moc
> >>> ccode: GRM-APP-
> >>> ipseg: "0.15"
> >>>   - name: EXE
> >>> path: /tmp/exe
> >>> ccode: GRM-APP-
> >>> ipseg: "0.15"
> >>>   - name: MTR
> >>> path: /tmp/mtr
> >>> ccode: GRM-APP-
> >>> ipseg: "0.15"
> >>>
> >>>
> >>> Can you please suggest a clean way to get this to work  ?
> >>>
> >>> --
> >>> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2d8d2651-2ffc-4f36-b565-0df941508cbb%40googlegroups.com
> .
> >>
> >> --
> >> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
> >>
> >> --
> >> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwPTUGXsFP0HV6pUvUJB_ssvOq_-V-8P9JALJ3urWMq46g%40mail.gmail.com
> .
> >
> > --
> > 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAJtox0kJy%3D1Cow5XFC10CSUwvF6Jfdn34Xm5sAnnNjDLh%2B5mgw%40mail.gmail.com
> .
>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> 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.
> 

Re: [ansible-project] Unable to read variable in a loop using include_vars.

2020-03-03 Thread Dick Visser
I meant HIGH level.
You are using ansible to achieve something - what is that?

On Tue, 3 Mar 2020 at 09:20, Shifa Shaikh  wrote:
>
> Under an ip I want a variable ccode which will be global variable for that ip.
>
> I also want variable name & path which will have multiple entries.
>
> How can I read both single global and multiple variables name and path under 
> a given IP ?
>
> On Tue, 3 Mar, 2020, 1:26 pm Dick Visser,  wrote:
>>
>> Can you tell what is the big picture? What task is this intended for?
>>
>> On Tue, 3 Mar 2020 at 05:43, Shifa Shaikh  wrote:
>>>
>>> Below is my playbook which loads variables and passes it to ls command on 
>>> remote hosts.
>>>
>>>- name: Load repository
>>>  include_vars:
>>>file="{{ playbook_dir }}/vars/listing.yml"
>>>name=user1
>>>
>>>
>>>- set_fact:
>>>allinonecmd: "{{ allinonecmd | default('') + 'ls -ltr ' + item.path 
>>> + ' '}}"
>>>  loop: "{{ user1[inventory_hostname] }}"
>>>
>>>- name: Get stat
>>>  shell: "ssh {{ USER }}@{{ inventory_hostname }} '{{ allinonecmd }}' 
>>> >/web/htdocs/{{ item.ccode }}{{ item.ipseg }}.html"
>>>  delegate_to: localhost
>>>  loop: "{{ user1[inventory_hostname] }}"
>>>
>>>
>>> below is my listing.yml
>>> 10.0.0.15:
>>>   - name: SCRIPT
>>> path: /tmp/scripts
>>> ccode: GRM-APP-
>>> ipseg: "0.15"
>>>   - name: MOC
>>> path: /tmp/moc
>>>   - name: EXE
>>> path: /tmp/exe
>>>   - name: MTR
>>> path: /tmp/mtr
>>>
>>>
>>> This worked fine without ccode and ipseg entries in the listing.yml. I have 
>>> multiple entries for path which i loop over and construct the allinonecmd 
>>> string but the ccode is just needed once.
>>>
>>> I get this error with a single entry of ccode in listing.yml
>>>
>>> fatal: [10.0.0.15]: FAILED! => {
>>> "msg": "The task includes an option with an undefined variable. The 
>>> error was: 'dict object' has no attribute 'ccode'
>>>
>>>
>>> For my existing playbook to work i have to specify ccode and ipseg under 
>>> each entry like below which works but looks ugly. It should be specified 
>>> just one time and the playbook should work.
>>>
>>> 10.0.0.15:
>>>   - name: SCRIPT
>>> path: /tmp/scripts
>>> ccode: GRM-APP-
>>> ipseg: "0.15"
>>>   - name: MOC
>>> path: /tmp/moc
>>> ccode: GRM-APP-
>>> ipseg: "0.15"
>>>   - name: EXE
>>> path: /tmp/exe
>>> ccode: GRM-APP-
>>> ipseg: "0.15"
>>>   - name: MTR
>>> path: /tmp/mtr
>>> ccode: GRM-APP-
>>> ipseg: "0.15"
>>>
>>>
>>> Can you please suggest a clean way to get this to work  ?
>>>
>>> --
>>> 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 view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/2d8d2651-2ffc-4f36-b565-0df941508cbb%40googlegroups.com.
>>
>> --
>> Sent from a mobile device - please excuse the brevity, spelling and 
>> punctuation.
>>
>> --
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwPTUGXsFP0HV6pUvUJB_ssvOq_-V-8P9JALJ3urWMq46g%40mail.gmail.com.
>
> --
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/CAJtox0kJy%3D1Cow5XFC10CSUwvF6Jfdn34Xm5sAnnNjDLh%2B5mgw%40mail.gmail.com.



-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwPnLi8kmR7ki0iSkYouQ3HQ_29PyCxbJmH1tRmEMsiojA%40mail.gmail.com.


Re: [ansible-project] Unable to read variable in a loop using include_vars.

2020-03-03 Thread Shifa Shaikh
Under an ip I want a variable ccode which will be global variable for that
ip.

I also want variable name & path which will have multiple entries.

How can I read both single global and multiple variables name and path
under a given IP ?

On Tue, 3 Mar, 2020, 1:26 pm Dick Visser,  wrote:

> Can you tell what is the big picture? What task is this intended for?
>
> On Tue, 3 Mar 2020 at 05:43, Shifa Shaikh  wrote:
>
>> Below is my playbook which loads variables and passes it to ls command on
>> remote hosts.
>>
>>- name: Load repository
>>  include_vars:
>>file="{{ playbook_dir }}/vars/listing.yml"
>>name=user1
>>
>>
>>- set_fact:
>>allinonecmd: "{{ allinonecmd | default('') + 'ls -ltr ' +
>> item.path + ' '}}"
>>  loop: "{{ user1[inventory_hostname] }}"
>>
>>- name: Get stat
>>  shell: "ssh {{ USER }}@{{ inventory_hostname }} '{{ allinonecmd }}'
>> >/web/htdocs/{{ item.ccode }}{{ item.ipseg }}.html"
>>  delegate_to: localhost
>>  loop: "{{ user1[inventory_hostname] }}"
>>
>>
>> below is my listing.yml
>> 10.0.0.15:
>>   - name: SCRIPT
>> path: /tmp/scripts
>> ccode: GRM-APP-
>> ipseg: "0.15"
>>   - name: MOC
>> path: /tmp/moc
>>   - name: EXE
>> path: /tmp/exe
>>   - name: MTR
>> path: /tmp/mtr
>>
>>
>> This worked fine without ccode and ipseg entries in the listing.yml. I
>> have multiple entries for path which i loop over and construct the
>> allinonecmd string but the ccode is just needed once.
>>
>> I get this error with a single entry of ccode in listing.yml
>>
>> fatal: [10.0.0.15]: FAILED! => {
>> "msg": "The task includes an option with an undefined variable. The
>> error was: 'dict object' has no attribute 'ccode'
>>
>>
>> For my existing playbook to work i have to specify ccode and ipseg under
>> each entry like below which works but looks ugly. It should be specified
>> just one time and the playbook should work.
>>
>> 10.0.0.15:
>>   - name: SCRIPT
>> path: /tmp/scripts
>> ccode: GRM-APP-
>> ipseg: "0.15"
>>   - name: MOC
>> path: /tmp/moc
>> ccode: GRM-APP-
>> ipseg: "0.15"
>>   - name: EXE
>> path: /tmp/exe
>> ccode: GRM-APP-
>> ipseg: "0.15"
>>   - name: MTR
>> path: /tmp/mtr
>> ccode: GRM-APP-
>> ipseg: "0.15"
>>
>>
>> Can you please suggest a clean way to get this to work  ?
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/2d8d2651-2ffc-4f36-b565-0df941508cbb%40googlegroups.com
>> 
>> .
>>
> --
> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwPTUGXsFP0HV6pUvUJB_ssvOq_-V-8P9JALJ3urWMq46g%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJtox0kJy%3D1Cow5XFC10CSUwvF6Jfdn34Xm5sAnnNjDLh%2B5mgw%40mail.gmail.com.


Re: [ansible-project] Unable to read variable in a loop using include_vars.

2020-03-02 Thread Dick Visser
Can you tell what is the big picture? What task is this intended for?

On Tue, 3 Mar 2020 at 05:43, Shifa Shaikh  wrote:

> Below is my playbook which loads variables and passes it to ls command on
> remote hosts.
>
>- name: Load repository
>  include_vars:
>file="{{ playbook_dir }}/vars/listing.yml"
>name=user1
>
>
>- set_fact:
>allinonecmd: "{{ allinonecmd | default('') + 'ls -ltr ' +
> item.path + ' '}}"
>  loop: "{{ user1[inventory_hostname] }}"
>
>- name: Get stat
>  shell: "ssh {{ USER }}@{{ inventory_hostname }} '{{ allinonecmd }}'
> >/web/htdocs/{{ item.ccode }}{{ item.ipseg }}.html"
>  delegate_to: localhost
>  loop: "{{ user1[inventory_hostname] }}"
>
>
> below is my listing.yml
> 10.0.0.15:
>   - name: SCRIPT
> path: /tmp/scripts
> ccode: GRM-APP-
> ipseg: "0.15"
>   - name: MOC
> path: /tmp/moc
>   - name: EXE
> path: /tmp/exe
>   - name: MTR
> path: /tmp/mtr
>
>
> This worked fine without ccode and ipseg entries in the listing.yml. I
> have multiple entries for path which i loop over and construct the
> allinonecmd string but the ccode is just needed once.
>
> I get this error with a single entry of ccode in listing.yml
>
> fatal: [10.0.0.15]: FAILED! => {
> "msg": "The task includes an option with an undefined variable. The
> error was: 'dict object' has no attribute 'ccode'
>
>
> For my existing playbook to work i have to specify ccode and ipseg under
> each entry like below which works but looks ugly. It should be specified
> just one time and the playbook should work.
>
> 10.0.0.15:
>   - name: SCRIPT
> path: /tmp/scripts
> ccode: GRM-APP-
> ipseg: "0.15"
>   - name: MOC
> path: /tmp/moc
> ccode: GRM-APP-
> ipseg: "0.15"
>   - name: EXE
> path: /tmp/exe
> ccode: GRM-APP-
> ipseg: "0.15"
>   - name: MTR
> path: /tmp/mtr
> ccode: GRM-APP-
> ipseg: "0.15"
>
>
> Can you please suggest a clean way to get this to work  ?
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2d8d2651-2ffc-4f36-b565-0df941508cbb%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwPTUGXsFP0HV6pUvUJB_ssvOq_-V-8P9JALJ3urWMq46g%40mail.gmail.com.


[ansible-project] Unable to read variable in a loop using include_vars.

2020-03-02 Thread Shifa Shaikh
Below is my playbook which loads variables and passes it to ls command on 
remote hosts.

   - name: Load repository 
 include_vars:
   file="{{ playbook_dir }}/vars/listing.yml"
   name=user1


   - set_fact:
   allinonecmd: "{{ allinonecmd | default('') + 'ls -ltr ' + item.path 
+ ' '}}"   
 loop: "{{ user1[inventory_hostname] }}"  

   - name: Get stat
 shell: "ssh {{ USER }}@{{ inventory_hostname }} '{{ allinonecmd }}' 
>/web/htdocs/{{ item.ccode }}{{ item.ipseg }}.html"
 delegate_to: localhost
 loop: "{{ user1[inventory_hostname] }}"

 
below is my listing.yml
10.0.0.15:
  - name: SCRIPT
path: /tmp/scripts
ccode: GRM-APP-
ipseg: "0.15"
  - name: MOC
path: /tmp/moc
  - name: EXE
path: /tmp/exe
  - name: MTR
path: /tmp/mtr


This worked fine without ccode and ipseg entries in the listing.yml. I have 
multiple entries for path which i loop over and construct the allinonecmd 
string but the ccode is just needed once.

I get this error with a single entry of ccode in listing.yml 

fatal: [10.0.0.15]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The 
error was: 'dict object' has no attribute 'ccode'


For my existing playbook to work i have to specify ccode and ipseg under 
each entry like below which works but looks ugly. It should be specified 
just one time and the playbook should work.

10.0.0.15:
  - name: SCRIPT
path: /tmp/scripts
ccode: GRM-APP-
ipseg: "0.15"
  - name: MOC
path: /tmp/moc
ccode: GRM-APP-
ipseg: "0.15"
  - name: EXE
path: /tmp/exe
ccode: GRM-APP-
ipseg: "0.15"
  - name: MTR
path: /tmp/mtr
ccode: GRM-APP-
ipseg: "0.15"


Can you please suggest a clean way to get this to work  ?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2d8d2651-2ffc-4f36-b565-0df941508cbb%40googlegroups.com.