Commit 1118cdd5 authored by Jürgen Haas's avatar Jürgen Haas

Make the Google Cloud working with multiple accounts

parent a95feb2a
---
# file: roles/gcloud/tasks/config.yml
- name: "Copy Auth File"
copy:
src='{{ inventory_dir }}/files/gcloud/{{ item.authfile }}'
dest='/tmp/{{ item.authfile }}'
- name: "Configure authenticatron"
command: gcloud auth activate-service-account --key-file=/tmp/{{ item.authfile }}
- name: "Configure project"
command: gcloud config set core/project {{ item.projectid }}
- name: "Configure account"
command: gcloud config set account {{ item.account }}
---
# 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'
......@@ -21,17 +16,3 @@
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
......@@ -13,11 +13,20 @@
- include: install.yml
- name: "Check available accounts"
command: gcloud auth list
register: gcloud_available_accounts
- include: config.yml
with_items: '{{ gcloud }}'
when: item.account is not in gcloud_available_accounts.stdout
- name: "Ensure log directory"
file:
path='/var/log/gcloud'
state='directory'
# TODO: The sync items need to define the gcloud account and we have to switch the account before calling rsync
- name: "Crontabs for Google Cloud Sync"
cron:
name='GCloud sync {{ item.source }}'
......
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