From: Jakub Czajka Date: Wed, 27 Sep 2023 20:33:39 +0000 (+0200) Subject: Add main automation script. X-Git-Url: https://git.ekhem.eu.org/?a=commitdiff_plain;h=c615d8bc03db87bd8f2fb0af5dcea29ab8dd2167;p=turnup.git Add main automation script. --- diff --git a/README b/README index 2f1a292..8405adf 100644 --- a/README +++ b/README @@ -2,3 +2,11 @@ turnup ====== Automation scripts for turning up system configuration. + +Instructions +------------ + +``` +ansible-playbook turnup.yaml --extra-vars @.yaml \ + --extra-vars key_file= --ask-vault-password +``` diff --git a/turnup.yaml b/turnup.yaml new file mode 100644 index 0000000..2942283 --- /dev/null +++ b/turnup.yaml @@ -0,0 +1,26 @@ +# Copyright (c) 2023 Jakub Czajka +# License: GPL-3.0 or later. + +- hosts: servers + vars_files: + - sources.yaml + tasks: + - stat: + path: "{{ item.dest }}/{{ item.name }}" + with_items: "{{ files }}" + register: files_stats + - name: Finish if nothing is missing + meta: end_play + when: "files_stats.results | selectattr('stat.exists', 'equalto', False) \ + | length == 0" + - name: Obtain an access token for Google Drive + include_tasks: gdrive_auth.yaml + vars: + redirect_uri: "urn:ietf:wg:oauth:2.0:oob" + scope: "https://www.googleapis.com/auth/drive.readonly" + - name: Download from Google Drive if missing + include_tasks: download.yaml + vars: + key: "{{ lookup('file', '{{ key_file }}') }}" + with_items: "{{ files }}" + when: "(item.dest + '/' + item.name) is not exists"