From: Oleg Broytman Date: Wed, 23 Mar 2022 02:04:46 +0000 (+0300) Subject: Feat(playbooks/fetch-push): Fetch/push a list of files X-Git-Url: https://git.phdru.name/?p=ansible.git;a=commitdiff_plain;h=2a99a85faee3243c5abb1710383867c2b5ba2d4d Feat(playbooks/fetch-push): Fetch/push a list of files File names are separated by a comma, no space. --- diff --git a/playbooks/fetch-push/fetch.yml b/playbooks/fetch-push/fetch.yml index 37510a4..b2f20c8 100644 --- a/playbooks/fetch-push/fetch.yml +++ b/playbooks/fetch-push/fetch.yml @@ -1,9 +1,10 @@ -- name: "Fetch {{ file }}" +- name: "Fetch files" hosts: "{{ hosts | default('all') }}" gather_facts: false tasks: - name: Fetch files fetch: - src: "{{ file }}" + src: "{{ item }}" dest: "{{ start_dir }}/{{ inventory_hostname }}/" flat: yes + loop: "{{ files.split(',') }}" diff --git a/playbooks/fetch-push/push.yml b/playbooks/fetch-push/push.yml index 247ac74..1965adc 100644 --- a/playbooks/fetch-push/push.yml +++ b/playbooks/fetch-push/push.yml @@ -1,12 +1,13 @@ -- name: "Push {{ file }}" +- name: "Push files" hosts: "{{ hosts | default('all') }}" become: yes gather_facts: false tasks: - name: Copy files copy: - src: "{{ start_dir }}/{{ inventory_hostname }}/{{ file }}" + src: "{{ start_dir }}/{{ inventory_hostname }}/{{ item }}" dest: "{{ dest_dir }}" owner: "{{ owner | default('root') }}" group: "{{ group | default('root') }}" mode: "{{ mode | default('0644') }}" + loop: "{{ files.split(',') }}"