From 31f44ba329b3dc6b0c04453aa411e1038521350c Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 23 Mar 2022 05:02:54 +0300 Subject: [PATCH] Feat(playbooks/fetch-push): Fetch/push a file Backup a remote file. Update it back. --- playbooks/fetch-push/fetch | 5 +++++ playbooks/fetch-push/fetch.yml | 9 +++++++++ playbooks/fetch-push/push | 5 +++++ playbooks/fetch-push/push.yml | 12 ++++++++++++ 4 files changed, 31 insertions(+) create mode 100755 playbooks/fetch-push/fetch create mode 100644 playbooks/fetch-push/fetch.yml create mode 100755 playbooks/fetch-push/push create mode 100644 playbooks/fetch-push/push.yml 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') }}" -- 2.39.2