Commit b25749da authored by Jürgen Haas's avatar Jürgen Haas

Develop installation, update, configuration and crontabs for Google Cloud sync

parent 616fa127
---
# file: roles/gcloud/tasks/install.yml
- name: "Check availability"
stat:
path='~/.config/gcloud/credentials'
register: gcloud_stat
- name: "Import the Google Cloud public key"
apt_key:
url='https://packages.cloud.google.com/apt/doc/apt-key.gpg'
state=present
- name: "Add the Cloud SDK distribution URI as a package source"
apt_repository:
repo='deb http://packages.cloud.google.com/apt cloud-sdk-{{ ansible_distribution_release }} main'
state='present'
- name: "Update and install the Cloud SDK"
apt:
pkg='google-cloud-sdk'
update_cache=yes
- block:
- name: "Copy Auth File"
copy:
src='{{ inventory_dir }}/files/gcloud/{{ gcloud.authfile }}'
dest='/tmp/{{ gcloud.authfile }}'
- name: "Configure authenticatron"
command: gcloud auth activate-service-account --key-file=/tmp/{{ gcloud.authfile }}
- name: "Configure project"
command: gcloud config set core/project {{ gcloud.projectid }}
when: not gcloud_stat.stat.exists
##
# Ansible file to install Google Cloud Tools
#
---
# file: roles/gcloud/tasks/main.yml
- name: "Google Cloud Role"
set_fact: role_gcloud_started=true
tags: always
- block:
- include: install.yml
- name: "Crontabs for Google Cloud Sync"
cron:
name='GCloud sync {{ item.source }}'
month={{ item.month|default(omit) }}
day={{ item.day|default(omit) }}
weekday={{ item.weekday|default(omit) }}
hour={{ item.hour|default('1') }}
minute={{ item.minute|default('0') }}
job='gsutil -m rsync -e -r {{ item.source }} gs://{{ item.bucket }}/ >>/var/log/gcloud.log'
with_items: '{{ gcloud_sync|default([]) }}'
tags: 'cron'
when: '"gcloud" not in excluded_roles'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment