From: Oleg Broytman Date: Wed, 23 Mar 2022 02:02:54 +0000 (+0300) Subject: Feat(playbooks/fetch-push): Fetch/push a file X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=31f44ba329b3dc6b0c04453aa411e1038521350c;p=ansible.git Feat(playbooks/fetch-push): Fetch/push a file Backup a remote file. Update it back. --- diff --git a/playbooks/fetch-push/fetch b/playbooks/fetch-push/fetch new file mode 100755 index 0000000..1a15823 --- /dev/null +++ b/playbooks/fetch-push/fetch @@ -0,0 +1,5 @@ +#! /bin/sh + +start_dir="`pwd`" && +fetch_push_dir="`dirname \"$0\"`" && +exec "$HOME"/.virtualenvs/ansible/bin/ansible-playbook -v "$fetch_push_dir"/fetch.yml -e start_dir="$start_dir" "$@" diff --git a/playbooks/fetch-push/fetch.yml b/playbooks/fetch-push/fetch.yml new file mode 100644 index 0000000..37510a4 --- /dev/null +++ b/playbooks/fetch-push/fetch.yml @@ -0,0 +1,9 @@ +- name: "Fetch {{ file }}" + hosts: "{{ hosts | default('all') }}" + gather_facts: false + tasks: + - name: Fetch files + fetch: + src: "{{ file }}" + dest: "{{ start_dir }}/{{ inventory_hostname }}/" + flat: yes diff --git a/playbooks/fetch-push/push b/playbooks/fetch-push/push new file mode 100755 index 0000000..624c755 --- /dev/null +++ b/playbooks/fetch-push/push @@ -0,0 +1,5 @@ +#! /bin/sh + +start_dir="`pwd`" && +fetch_push_dir="`dirname \"$0\"`" && +exec "$HOME"/.virtualenvs/ansible/bin/ansible-playbook -v "$fetch_push_dir"/push.yml -e start_dir="$start_dir" "$@" diff --git a/playbooks/fetch-push/push.yml b/playbooks/fetch-push/push.yml new file mode 100644 index 0000000..247ac74 --- /dev/null +++ b/playbooks/fetch-push/push.yml @@ -0,0 +1,12 @@ +- name: "Push {{ file }}" + hosts: "{{ hosts | default('all') }}" + become: yes + gather_facts: false + tasks: + - name: Copy files + copy: + src: "{{ start_dir }}/{{ inventory_hostname }}/{{ file }}" + dest: "{{ dest_dir }}" + owner: "{{ owner | default('root') }}" + group: "{{ group | default('root') }}" + mode: "{{ mode | default('0644') }}"