Commit a5f9f4e6 authored by Jürgen Haas's avatar Jürgen Haas
parent cf56dba6
---
# file: roles/gcloud/tasks/config.yml
- name: "Copy Auth File"
- name: Copy Auth File
copy:
src='{{ inventory_dir }}/files/gcloud/{{ gcloud[item].authfile }}'
dest='/tmp/{{ gcloud[item].authfile }}'
- name: "Configure authenticatron"
- name: Configure authenticatron
command: gcloud auth activate-service-account --key-file=/tmp/{{ gcloud[item].authfile }}
- name: "Configure project"
- name: Configure project
command: gcloud config set core/project {{ gcloud[item].projectid }}
- name: "Configure account"
- name: Configure account
command: gcloud config set account {{ gcloud[item].account }}
---
# file: roles/gcloud/tasks/install.yml
- name: "Import the Google Cloud public key"
- 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"
- 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'
mode='644'
- name: "Update and install the Cloud SDK"
- name: Update and install the Cloud SDK
apt:
pkg='google-cloud-sdk'
update_cache=yes
......@@ -5,15 +5,17 @@
---
# file: roles/gcloud/tasks/main.yml
- name: "Google Cloud Role"
set_fact: role_gcloud_started=true
tags: 'always'
- name: Google Cloud Role
set_fact:
role_gcloud_started: yes
tags:
- always
- block:
- import_tasks: install.yml
- name: "Check available accounts"
- name: Check available accounts
command: gcloud auth list
register: gcloud_available_accounts
changed_when: false
......@@ -22,12 +24,12 @@
with_items: '{{ gcloud|default([]) }}'
when: gcloud[item].account not in gcloud_available_accounts.stdout
- name: "Ensure log directory"
- name: Ensure log directory
file:
path='/var/log/gcloud'
state='directory'
- name: "Copy Sync Scripts"
- name: Copy Sync Scripts
template:
src='{{ item }}'
dest='/usr/local/bin/{{ item }}'
......@@ -35,10 +37,10 @@
group='root'
mode='755'
with_items:
- 'gcloud-sync.sh'
- 'gcloud-sync-path.sh'
- gcloud-sync.sh
- gcloud-sync-path.sh
- name: "Crontabs for Google Cloud Sync"
- name: Crontabs for Google Cloud Sync
cron:
name='GCloud sync {{ item.source }}'
month={{ item.month|default(omit) }}
......@@ -49,9 +51,10 @@
job='/usr/local/bin/gcloud-sync.sh {{ gcloud[item.account]["account"] }} {{ gcloud[item.account]["projectid"] }} "{{ item.source }}" "{{ item.bucket }}" >>/var/log/gcloud/rsync.log 2>&1'
disabled='{{ item.disabled|default(false) }}'
with_items: '{{ gcloud_sync|default([]) }}'
tags: 'cron'
tags:
- cron
- name: "Crontabs for Google Cloud Sync Path"
- name: Crontabs for Google Cloud Sync Path
cron:
name='GCloud sync {{ item.source }}'
month={{ item.month|default(omit) }}
......@@ -61,15 +64,17 @@
minute={{ item.minute|default('0') }}
job='/usr/local/bin/gcloud-sync-path.sh {{ gcloud[item.account]["account"] }} {{ gcloud[item.account]["projectid"] }} "{{ item.source }}" "{{ item.bucket }}" >>/var/log/gcloud/rsync.log 2>&1'
with_items: '{{ gcloud_sync_path|default([]) }}'
tags: 'cron'
tags:
- cron
- name: "Install logrotate script"
- name: Install logrotate script
template:
src=etc-logrotate-gcloud
dest=/etc/logrotate.d/gcloud
owner=root
group=root
mode='644'
tags: 'logrotate'
tags:
- logrotate
when: 'gcloud_enabled and "gcloud" not in excluded_roles and gcloud_sync is defined'
when: gcloud_enabled and (not excluded_roles or "gcloud" not in excluded_roles) and gcloud_sync is defined
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