[ansible-project] ansible conditions

2018-02-01 Thread Sudhir Kumar
Hi,

Below snippet sometimes working and sometimes failing. So, i am executing 
it with jenkins and idea is that if parameter is defined then script should 
run otherwise it should not run. 

Can anyone please enlighten me what's wrong ?

#
  - name: Executing lvm script 
shell: /tmp/lvm-script.sh sdb {{ vg_name }} {{ mtpt_size }} 
args:
  chdir: /tmp/
when: vg_name is defined
##

-- 
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 
https://groups.google.com/d/msgid/ansible-project/252e2cfd-3f8e-436b-a31b-918ea4c6728a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible conditions and logics

2014-04-04 Thread Maxim Odinintsev
Yes, this is valid syntax and this conditions working as AND. And it 
working for me ;)
You can create simple playbook for verifying it.

I've never seen this syntax used with when:

 - name: Moving on
   debug: msg=doing something with {{ item.item }}
   when:
 - item.stat.exists == true
 - item.stat.islnk != true
   with_items: st.results

 Is that a valid conditional? Is it equivalent to 'and' ?

 On Wednesday, April 2, 2014 5:53:52 AM UTC-5, Maxim Odinintsev wrote:

 Hello,

 I'm tried make it over ansible, but in final, i think much easiest way is 
 using script module.

 If someone interesting, when i tried it, i'm used this construction for 
 getting files attributes and states:

 - name: Getting files stats
   stat: path={{ item }}
   register: st
   with_items:
- /etc/asterisk
- /etc/bind
- /etc/GeoIP.conf
- /etc/iptables
- /etc/jabber
- /etc/monit
- /etc/mysql
- /etc/nginx
- /etc/postfix
- /etc/ppp
- /etc/snmp
- /etc/sphinx
- /etc/xl2tpd

 - name: Moving on
   debug: msg=doing something with {{ item.item }}
   when:
 - item.stat.exists == true
 - item.stat.islnk != true
   with_items: st.results


 Thank you


 Hello,

 Yes, you understand correctly. How can I synchronize files on remote 
 node (not from local host to remote) ?

 Thank you.

 If I understand correctly, you're copying the contents of several 
 directories to a central location, removing the old path, and then 
 creating 
 a symlink to the new location? To do that with ansible you'd just need to 
 call the synchronize module to copy the files (or use command/shell to do 
 the rsync), and then use the file module to create the symlink.


 On Mon, Mar 31, 2014 at 6:56 AM, Maxim Odinintsev gwyn...@gmail.comwrote:

 Hello,

 I'm trying migrate out my infrastructure under ansible control, but 
 stopped on simple things realization with ansible.

 I would be very grateful if some one can explain, best way for moving 
 on this simple shell script under ansible. 
 May be simplest way is running external shell, and not try to push it 
 all under ansible logic ?

 pushd /
 for i in \
   /etc/ipsec* \
   /home \
   /root \
   do
   [[ -r $i ]] || continue
   [[ -L $i ]]  continue
   dst_dir=$(readlink -m /protected$(dirname $i))
   dst_name=${dst_dir}/$(basename $i)
   mkdir -p $dst_dir
   rsync -a $i $dst_dir  rm -rf $i  ln -s $dst_name $i
   ls -ld $i
 done
 popd

 Thank you
  
 -- 
 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-proje...@googlegroups.com.
 To post to this group, send email to ansible...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.comhttps://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.




-- 
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 
https://groups.google.com/d/msgid/ansible-project/2c6b7061-c9c5-4712-8088-13e6943ae4a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible conditions and logics

2014-04-04 Thread Michael DeHaan
Correct.




On Fri, Apr 4, 2014 at 8:58 AM, Maxim Odinintsev gwynn@gmail.comwrote:

 Yes, this is valid syntax and this conditions working as AND. And it
 working for me ;)
 You can create simple playbook for verifying it.


 I've never seen this syntax used with when:

 - name: Moving on
   debug: msg=doing something with {{ item.item }}
   when:
 - item.stat.exists == true
 - item.stat.islnk != true
   with_items: st.results

 Is that a valid conditional? Is it equivalent to 'and' ?

 On Wednesday, April 2, 2014 5:53:52 AM UTC-5, Maxim Odinintsev wrote:

 Hello,

 I'm tried make it over ansible, but in final, i think much easiest way
 is using script module.

 If someone interesting, when i tried it, i'm used this construction for
 getting files attributes and states:

 - name: Getting files stats
   stat: path={{ item }}
   register: st
   with_items:
- /etc/asterisk
- /etc/bind
- /etc/GeoIP.conf
- /etc/iptables
- /etc/jabber
- /etc/monit
- /etc/mysql
- /etc/nginx
- /etc/postfix
- /etc/ppp
- /etc/snmp
- /etc/sphinx
- /etc/xl2tpd

 - name: Moving on
   debug: msg=doing something with {{ item.item }}
   when:
 - item.stat.exists == true
 - item.stat.islnk != true
   with_items: st.results


 Thank you


 Hello,

 Yes, you understand correctly. How can I synchronize files on remote
 node (not from local host to remote) ?

 Thank you.

 If I understand correctly, you're copying the contents of several
 directories to a central location, removing the old path, and then 
 creating
 a symlink to the new location? To do that with ansible you'd just need to
 call the synchronize module to copy the files (or use command/shell to do
 the rsync), and then use the file module to create the symlink.


 On Mon, Mar 31, 2014 at 6:56 AM, Maxim Odinintsev 
 gwyn...@gmail.comwrote:

 Hello,

 I'm trying migrate out my infrastructure under ansible control, but
 stopped on simple things realization with ansible.

 I would be very grateful if some one can explain, best way for moving
 on this simple shell script under ansible.
 May be simplest way is running external shell, and not try to push it
 all under ansible logic ?

 pushd /
 for i in \
   /etc/ipsec* \
   /home \
   /root \
   do
   [[ -r $i ]] || continue
   [[ -L $i ]]  continue
   dst_dir=$(readlink -m /protected$(dirname $i))
   dst_name=${dst_dir}/$(basename $i)
   mkdir -p $dst_dir
   rsync -a $i $dst_dir  rm -rf $i  ln -s $dst_name $i
   ls -ld $i
 done
 popd

 Thank you

 --
 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-proje...@googlegroups.com.
 To post to this group, send email to ansible...@googlegroups.com.
 To view this discussion on the web visit https://groups.google.com/d/
 msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-
 a4a891e443c6%40googlegroups.comhttps://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.


  --
 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
 https://groups.google.com/d/msgid/ansible-project/2c6b7061-c9c5-4712-8088-13e6943ae4a9%40googlegroups.comhttps://groups.google.com/d/msgid/ansible-project/2c6b7061-c9c5-4712-8088-13e6943ae4a9%40googlegroups.com?utm_medium=emailutm_source=footer
 .

 For more options, visit https://groups.google.com/d/optout.


-- 
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 
https://groups.google.com/d/msgid/ansible-project/CAEVJ8QMNH8gUEF95qMOUpf28EtFZO8jLjWzWHTzvqfj32QMjYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible conditions and logics

2014-04-03 Thread Brian Green
I've never seen this syntax used with when:

- name: Moving on
  debug: msg=doing something with {{ item.item }}
  when:
- item.stat.exists == true
- item.stat.islnk != true
  with_items: st.results

Is that a valid conditional? Is it equivalent to 'and' ?

On Wednesday, April 2, 2014 5:53:52 AM UTC-5, Maxim Odinintsev wrote:

 Hello,

 I'm tried make it over ansible, but in final, i think much easiest way is 
 using script module.

 If someone interesting, when i tried it, i'm used this construction for 
 getting files attributes and states:

 - name: Getting files stats
   stat: path={{ item }}
   register: st
   with_items:
- /etc/asterisk
- /etc/bind
- /etc/GeoIP.conf
- /etc/iptables
- /etc/jabber
- /etc/monit
- /etc/mysql
- /etc/nginx
- /etc/postfix
- /etc/ppp
- /etc/snmp
- /etc/sphinx
- /etc/xl2tpd

 - name: Moving on
   debug: msg=doing something with {{ item.item }}
   when:
 - item.stat.exists == true
 - item.stat.islnk != true
   with_items: st.results


 Thank you


 Hello,

 Yes, you understand correctly. How can I synchronize files on remote node 
 (not from local host to remote) ?

 Thank you.

 If I understand correctly, you're copying the contents of several 
 directories to a central location, removing the old path, and then creating 
 a symlink to the new location? To do that with ansible you'd just need to 
 call the synchronize module to copy the files (or use command/shell to do 
 the rsync), and then use the file module to create the symlink.


 On Mon, Mar 31, 2014 at 6:56 AM, Maxim Odinintsev gwyn...@gmail.comwrote:

 Hello,

 I'm trying migrate out my infrastructure under ansible control, but 
 stopped on simple things realization with ansible.

 I would be very grateful if some one can explain, best way for moving 
 on this simple shell script under ansible. 
 May be simplest way is running external shell, and not try to push it 
 all under ansible logic ?

 pushd /
 for i in \
   /etc/ipsec* \
   /home \
   /root \
   do
   [[ -r $i ]] || continue
   [[ -L $i ]]  continue
   dst_dir=$(readlink -m /protected$(dirname $i))
   dst_name=${dst_dir}/$(basename $i)
   mkdir -p $dst_dir
   rsync -a $i $dst_dir  rm -rf $i  ln -s $dst_name $i
   ls -ld $i
 done
 popd

 Thank you
  
 -- 
 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-proje...@googlegroups.com.
 To post to this group, send email to ansible...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.comhttps://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.




-- 
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 
https://groups.google.com/d/msgid/ansible-project/bbf07a56-63bb-41d5-9c4a-d5185b123603%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible conditions and logics

2014-04-02 Thread Maxim Odinintsev


Hello,

Yes, you understand correctly. How can I synchronize files on remote node 
(not from local host to remote) ?

Thank you.

If I understand correctly, you're copying the contents of several 
 directories to a central location, removing the old path, and then creating 
 a symlink to the new location? To do that with ansible you'd just need to 
 call the synchronize module to copy the files (or use command/shell to do 
 the rsync), and then use the file module to create the symlink.


 On Mon, Mar 31, 2014 at 6:56 AM, Maxim Odinintsev 
 gwyn...@gmail.comjavascript:
  wrote:

 Hello,

 I'm trying migrate out my infrastructure under ansible control, but 
 stopped on simple things realization with ansible.

 I would be very grateful if some one can explain, best way for moving on 
 this simple shell script under ansible. 
 May be simplest way is running external shell, and not try to push it all 
 under ansible logic ?

 pushd /
 for i in \
   /etc/ipsec* \
   /home \
   /root \
   do
   [[ -r $i ]] || continue
   [[ -L $i ]]  continue
   dst_dir=$(readlink -m /protected$(dirname $i))
   dst_name=${dst_dir}/$(basename $i)
   mkdir -p $dst_dir
   rsync -a $i $dst_dir  rm -rf $i  ln -s $dst_name $i
   ls -ld $i
 done
 popd

 Thank you
  
 -- 
 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-proje...@googlegroups.com javascript:.
 To post to this group, send email to ansible...@googlegroups.comjavascript:
 .
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.comhttps://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.




-- 
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 
https://groups.google.com/d/msgid/ansible-project/fee40af9-5f06-49d2-bfc0-bb2aa287a936%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible conditions and logics

2014-04-02 Thread Maxim Odinintsev
Hello,

I'm tried make it over ansible, but in final, i think much easiest way is 
using script module.

If someone interesting, when i tried it, i'm used this construction for 
getting files attributes and states:

- name: Getting files stats
  stat: path={{ item }}
  register: st
  with_items:
   - /etc/asterisk
   - /etc/bind
   - /etc/GeoIP.conf
   - /etc/iptables
   - /etc/jabber
   - /etc/monit
   - /etc/mysql
   - /etc/nginx
   - /etc/postfix
   - /etc/ppp
   - /etc/snmp
   - /etc/sphinx
   - /etc/xl2tpd

- name: Moving on
  debug: msg=doing something with {{ item.item }}
  when:
- item.stat.exists == true
- item.stat.islnk != true
  with_items: st.results


Thank you


 Hello,

 Yes, you understand correctly. How can I synchronize files on remote node 
 (not from local host to remote) ?

 Thank you.

 If I understand correctly, you're copying the contents of several 
 directories to a central location, removing the old path, and then creating 
 a symlink to the new location? To do that with ansible you'd just need to 
 call the synchronize module to copy the files (or use command/shell to do 
 the rsync), and then use the file module to create the symlink.


 On Mon, Mar 31, 2014 at 6:56 AM, Maxim Odinintsev gwyn...@gmail.comwrote:

 Hello,

 I'm trying migrate out my infrastructure under ansible control, but 
 stopped on simple things realization with ansible.

 I would be very grateful if some one can explain, best way for moving on 
 this simple shell script under ansible. 
 May be simplest way is running external shell, and not try to push it 
 all under ansible logic ?

 pushd /
 for i in \
   /etc/ipsec* \
   /home \
   /root \
   do
   [[ -r $i ]] || continue
   [[ -L $i ]]  continue
   dst_dir=$(readlink -m /protected$(dirname $i))
   dst_name=${dst_dir}/$(basename $i)
   mkdir -p $dst_dir
   rsync -a $i $dst_dir  rm -rf $i  ln -s $dst_name $i
   ls -ld $i
 done
 popd

 Thank you
  
 -- 
 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-proje...@googlegroups.com.
 To post to this group, send email to ansible...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.comhttps://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.




-- 
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 
https://groups.google.com/d/msgid/ansible-project/4789e472-3e67-495d-b0d0-9a0e3999f113%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible conditions and logics

2014-03-31 Thread Maxim Odinintsev
Hello,

I'm trying migrate out my infrastructure under ansible control, but stopped 
on simple things realization with ansible.

I would be very grateful if some one can explain, best way for moving on 
this simple shell script under ansible. 
May be simplest way is running external shell, and not try to push it all 
under ansible logic ?

pushd /
for i in \
  /etc/ipsec* \
  /home \
  /root \
  do
  [[ -r $i ]] || continue
  [[ -L $i ]]  continue
  dst_dir=$(readlink -m /protected$(dirname $i))
  dst_name=${dst_dir}/$(basename $i)
  mkdir -p $dst_dir
  rsync -a $i $dst_dir  rm -rf $i  ln -s $dst_name $i
  ls -ld $i
done
popd

Thank you

-- 
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 
https://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible conditions and logics

2014-03-31 Thread James Cammarata
If I understand correctly, you're copying the contents of several
directories to a central location, removing the old path, and then creating
a symlink to the new location? To do that with ansible you'd just need to
call the synchronize module to copy the files (or use command/shell to do
the rsync), and then use the file module to create the symlink.


On Mon, Mar 31, 2014 at 6:56 AM, Maxim Odinintsev gwynn@gmail.comwrote:

 Hello,

 I'm trying migrate out my infrastructure under ansible control, but
 stopped on simple things realization with ansible.

 I would be very grateful if some one can explain, best way for moving on
 this simple shell script under ansible.
 May be simplest way is running external shell, and not try to push it all
 under ansible logic ?

 pushd /
 for i in \
   /etc/ipsec* \
   /home \
   /root \
   do
   [[ -r $i ]] || continue
   [[ -L $i ]]  continue
   dst_dir=$(readlink -m /protected$(dirname $i))
   dst_name=${dst_dir}/$(basename $i)
   mkdir -p $dst_dir
   rsync -a $i $dst_dir  rm -rf $i  ln -s $dst_name $i
   ls -ld $i
 done
 popd

 Thank you

 --
 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
 https://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.comhttps://groups.google.com/d/msgid/ansible-project/a29d1d41-ffd3-40e9-8cc4-a4a891e443c6%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.


-- 
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 
https://groups.google.com/d/msgid/ansible-project/CAFg%2Bn8T_92zNsUvWZzqKTQV_E1mz6iVxg%3D9aSyt%3DW7n6opbG4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.