how to use regex in copy or other module

22 views
Skip to first unread message

郭大瞎

unread,
Oct 1, 2016, 9:24:06 PM10/1/16
to Ansible Project
I need to copy files from managed node to control machines.
A machine's tomcat path : /usr/local/tomcat-aux
B machine's tomcat path : /usr/local/tomcat-hk
actually there is not only these two instance. 
so I've tried below methods, but failed. 

 name: copy file to tomcat path
 copy: src=/deploy/a.conf  dest=/usr/local/tomcat*/

Thanks in advance~

Kai Stian Olstad

unread,
Oct 2, 2016, 3:12:51 AM10/2/16
to ansible...@googlegroups.com
copy module doesn't support regexp, only a handful modules do, and if
they do it's documented in the individual module documentation.

You example you can written like this:

- name: Find tomcat directories
find:
paths=/usr/local
patterns=tomcat*
file_type=directory
register: result

- name: copy file to tomcat path
copy:
src=/deploy/a.conf
dest={{ item.path }}
with_items: result.files

--
Kai Stian Olstad

郭大瞎

unread,
Oct 2, 2016, 11:14:44 PM10/2/16
to Ansible Project, ansible-pr...@olstad.com
Got it. thank you so much!

在 2016年10月2日星期日 UTC+8下午3:12:51,Kai Stian Olstad写道:
Reply all
Reply to author
Forward
0 new messages