have one src file to many dest in single file copy block?

18 views
Skip to first unread message

daddyocruzer

unread,
Sep 14, 2017, 3:56:51 PM9/14/17
to Ansible Project
I have this for copying the same (new) banner file to each locations - is there a way for 'dest' to expand to include each location in a single line so I can have just one 'copy' block?


tasks: - copy: src : ~/new-banner-2017.txt <----- same file dest: /etc/motd owner: root group: root mode: 0644 - copy: src: ~/new-banner-2017.txt <----- same file dest: /etc/issue owner: root group: root mode: 0644



Is there a way to have 'dest' cover both destinations, like an array or list of some sort? ( dest: "/etc/issue , /etc/motd" ) ?

Kai Stian Olstad

unread,
Sep 14, 2017, 5:03:41 PM9/14/17
to ansible...@googlegroups.com
On 14. sep. 2017 21:56, daddyocruzer wrote:
> I have this for copying the same (new) banner file to each locations - is
> there a way for 'dest' to expand to include each location in a single line
> so I can have just one 'copy' block?

No, but you can use with_items, you will only have one copy in your code
but it will expand to as many tasks as you have in with_items.


--
Kai Stian Olstad

daddyocruzer

unread,
Sep 14, 2017, 6:26:53 PM9/14/17
to Ansible Project
OK, this ended up being how I did it:

- copy
....
dest: "{{ item }}"
....
with_items:
   - '/etc/motd'
   - '/etc/issue'
Reply all
Reply to author
Forward
0 new messages