Hi James,
here you are the gist https://gist.github.com/Pablohn26/88b7770d0bc6e5d7da06
I have added the output of ntty after and before getting tty. It is weird
that the value is a Hello World after the "getting tty" (also the results):
TASK: [debug var=ntty]
********************************************************
ok: [s04.lab] => {"item": "", "msg": "Hello world!"}
TASK: [debug var=ntty.results]
************************************************
ok: [s04.lab] => {"item": "", "msg": "Hello world!"}
There it might be the problem.
Then, when I run the command it run:
echo 'sed -i '' 's/10.199.3.82/v/g' /cf/conf/config.xml' > */dev/pts/n*
echo 'sed -i '' 's/10.199.3.82/v/g' /cf/conf/config.xml' >* /dev/pts/t*
echo 'sed -i '' 's/10.199.3.82/v/g' /cf/conf/config.xml' > */dev/pts/t*
echo 'sed -i '' 's/10.199.3.82/v/g' /cf/conf/config.xml' > */dev/pts/y*
echo 'sed -i '' 's/10.199.3.82/v/g' /cf/conf/config.xml' > */dev/pts/.*
echo 'sed -i '' 's/10.199.3.82/v/g' /cf/conf/config.xml' > */dev/pts/r*
.....
The main question is: how to mix registers, nested variables and
with_together loops?
Cheers
El martes, 17 de diciembre de 2013 17:03:40 UTC, James Tanner escribió:
>
> Could you copy your vars and the playbook to a gist(gist.github.com) ?
> The formatting is a bit hard to read in this email.
>
> It would also be nice to see the output of -debug: var=ntty after the
> "getting tty" task so that we understand what the datastructure looks like.
>
> On 12/17/2013 11:48 AM, Pablo Hinojosa Nava wrote:
>
> Hi all,
>
> I am trying to set a loop on with_together way but I am using nested
> variables with lists, and I do not have clear how the is code .
>
> My first variable is the next:
> - vmStorage: { vcpu: 1,
> ram: 1024,
> storage: 10,
> vms: [{name: storage1-dev02,ip: 10.199.3.87},
> {name: storage2-dev02,ip: 10.199.3.88},
> {name: storage3-dev02,ip: 10.199.3.89}]
> }
> My second variable is a register created on this way:
> - name: getting tty
> shell: virsh dumpxml {{ item.name }} | grep "tty=" | cut -d= -f3 | cut
> -d/ -f4 | cut -d\' -f1
> with_items: vmHash.vms
> register: ntty
>
> Then I am using ntty variable as this without problem:
>
>> - name: entering on the shell inside each tty
>> shell: "echo '6' > /dev/pts/{{ item.stdout }}"
>> with_items: ntty.results
>
> and also vmHash.vms variables, for example with:
>
>> - name: Do not worry about the previous error, checking if the vms are up
>> wait_for: host={{ item.ip }}
>> port=22
>> timeout=200
>> delegate_to: localhost
>> with_items: vmHash.vms
>
>
> *but the problem is when I want to use the with_together loop with these
> variables. *
>
> The command is the next:
>
>> shell: "echo 'sed -i '' 's/{{ goldenip }}/{{ first list variables }}/g'
>> /cf/conf/config.xml' > /dev/pts/{{ second list variables }}"
>
>
> I have tried a lot of ways without success, for example:
>
>> - name: send stuff2 to all ttys
>> shell: "echo 'sed -i '' 's/{{ goldenip }}/{{ item.0.ip }}/g'
>> /cf/conf/config.xml' > /dev/pts/{{ item.1.stdout }}"
>> with_together:
>> - vmHash.vms
>> - ntty.results
>> with the next error TASK: [send stuff2 to all ttys]
>> ***********************************************
>> fatal: [x.x] => One or more undefined variables: 'str object' has no
>> attribute 'ip'
>
>
> or
>
>> - name: send stuff2 to all ttys
>> shell: "echo 'sed -i '' 's/{{ goldenip }}/{{ item.0 }}/g'
>> /cf/conf/config.xml' > /dev/pts/{{ item.1 }}"
>> with_together:
>> - vmHash.vms.ip
>> - ntty.results.ip
>
> with the next error:
>
>> TASK: [send stuff2 to all ttys]
>> ***********************************************
>> failed: [s04.lab] => (item=['v', 'n']) => {"changed": true, "cmd": "echo
>> 'sed -i '' 's/10.199.3.82/v/g' /cf/conf/config.xml' > /dev/pts/n ",
>> "delta": "0:00:00.005936", "end": "2013-12-17 16:04:15.616932", "item":
>> ["v", "n"], "rc": 1, "start": "2013-12-17 16:04:15.610996"}
>> stderr: /bin/sh: /dev/pts/n: Permission denied
>> failed: [s04.lab] => (item=['m', 't']) => {"changed": true, "cmd": "echo
>> 'sed -i '' 's/10.199.3.82/m/g' /cf/conf/config.xml' > /dev/pts/t ",
>> "delta": "0:00:00.005735", "end": "2013-12-17 16:04:17.796956", "item":
>> ["m", "t"], "rc": 1, "start": "2013-12-17 16:04:17.791221"}
>> stderr: /bin/sh: /dev/pts/t: Permission denied
>
> (It is getting the name of the variable)
>
> How could I run the command using the ip and the number of tty?
>
> Cheers,
>
> Pablo Hinojosa
>
> --
> 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] <javascript:>.
> To post to this group, send email to [email protected]<javascript:>
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
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].
For more options, visit https://groups.google.com/groups/opt_out.