From cae5ecdfd214db8aba9e9493a02a11487894c9f3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 2 Dec 2022 00:22:49 -0500 Subject: [PATCH] Add google cloud sdk role. --- ansible/playbook.yaml | 1 + ansible/roles/blank/tasks/linux.yaml | 19 ++++++++++-- ansible/roles/google_cloud_sdk/meta/main.yaml | 2 ++ .../roles/google_cloud_sdk/tasks/common.yaml | 14 +++++++++ .../roles/google_cloud_sdk/tasks/freebsd.yaml | 6 ++++ .../roles/google_cloud_sdk/tasks/linux.yaml | 21 ++++++++++++++ .../roles/google_cloud_sdk/tasks/main.yaml | 1 + .../roles/google_cloud_sdk/tasks/peruser.yaml | 29 +++++++++++++++++++ .../tasks/peruser_freebsd.yaml | 0 .../google_cloud_sdk/tasks/peruser_linux.yaml | 0 10 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 ansible/roles/google_cloud_sdk/meta/main.yaml create mode 100644 ansible/roles/google_cloud_sdk/tasks/common.yaml create mode 100644 ansible/roles/google_cloud_sdk/tasks/freebsd.yaml create mode 100644 ansible/roles/google_cloud_sdk/tasks/linux.yaml create mode 100644 ansible/roles/google_cloud_sdk/tasks/main.yaml create mode 100644 ansible/roles/google_cloud_sdk/tasks/peruser.yaml create mode 100644 ansible/roles/google_cloud_sdk/tasks/peruser_freebsd.yaml create mode 100644 ansible/roles/google_cloud_sdk/tasks/peruser_linux.yaml diff --git a/ansible/playbook.yaml b/ansible/playbook.yaml index 148ef8f..7757bb4 100644 --- a/ansible/playbook.yaml +++ b/ansible/playbook.yaml @@ -30,3 +30,4 @@ - bhyve - media - kubernetes + - google_cloud_sdk diff --git a/ansible/roles/blank/tasks/linux.yaml b/ansible/roles/blank/tasks/linux.yaml index e1835f0..429ad91 100644 --- a/ansible/roles/blank/tasks/linux.yaml +++ b/ansible/roles/blank/tasks/linux.yaml @@ -1,6 +1,21 @@ -# - name: Install packages +# - name: Build aur packages +# register: buildaur +# become_user: "{{ build_user.name }}" +# command: "aurutils-sync --no-view {{ item }}" +# args: +# creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*" +# loop: +# - foo + +# - name: Update cache +# when: buildaur.changed # pacman: +# name: [] +# state: present +# update_cache: true + +# - name: Install packages +# package: # name: # - foo # state: present -# update_cache: true diff --git a/ansible/roles/google_cloud_sdk/meta/main.yaml b/ansible/roles/google_cloud_sdk/meta/main.yaml new file mode 100644 index 0000000..1674b55 --- /dev/null +++ b/ansible/roles/google_cloud_sdk/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - build diff --git a/ansible/roles/google_cloud_sdk/tasks/common.yaml b/ansible/roles/google_cloud_sdk/tasks/common.yaml new file mode 100644 index 0000000..d7c1735 --- /dev/null +++ b/ansible/roles/google_cloud_sdk/tasks/common.yaml @@ -0,0 +1,14 @@ +- import_tasks: tasks/freebsd.yaml + when: 'os_flavor == "freebsd"' + +- import_tasks: tasks/linux.yaml + when: 'os_flavor == "linux"' + +- include_tasks: + file: tasks/peruser.yaml + apply: + become: yes + become_user: "{{ initialize_user }}" + loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}" + loop_control: + loop_var: initialize_user diff --git a/ansible/roles/google_cloud_sdk/tasks/freebsd.yaml b/ansible/roles/google_cloud_sdk/tasks/freebsd.yaml new file mode 100644 index 0000000..975b990 --- /dev/null +++ b/ansible/roles/google_cloud_sdk/tasks/freebsd.yaml @@ -0,0 +1,6 @@ +- name: Install packages + package: + name: + - google-cloud-sdk + state: present + diff --git a/ansible/roles/google_cloud_sdk/tasks/linux.yaml b/ansible/roles/google_cloud_sdk/tasks/linux.yaml new file mode 100644 index 0000000..5277cde --- /dev/null +++ b/ansible/roles/google_cloud_sdk/tasks/linux.yaml @@ -0,0 +1,21 @@ +- name: Build aur packages + register: buildaur + become_user: "{{ build_user.name }}" + command: "aurutils-sync --no-view {{ item }}" + args: + creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*" + loop: + - google-cloud-sdk + +- name: Update cache + when: buildaur.changed + pacman: + name: [] + state: present + update_cache: true + +- name: Install packages + package: + name: + - google-cloud-sdk + state: present diff --git a/ansible/roles/google_cloud_sdk/tasks/main.yaml b/ansible/roles/google_cloud_sdk/tasks/main.yaml new file mode 100644 index 0000000..5c1df6c --- /dev/null +++ b/ansible/roles/google_cloud_sdk/tasks/main.yaml @@ -0,0 +1 @@ +- import_tasks: tasks/common.yaml diff --git a/ansible/roles/google_cloud_sdk/tasks/peruser.yaml b/ansible/roles/google_cloud_sdk/tasks/peruser.yaml new file mode 100644 index 0000000..111e886 --- /dev/null +++ b/ansible/roles/google_cloud_sdk/tasks/peruser.yaml @@ -0,0 +1,29 @@ +- include_role: + name: per_user + +# - name: Create directories +# file: +# name: "{{ account_homedir.stdout }}/{{ item }}" +# state: directory +# mode: 0700 +# owner: "{{ account_name.stdout }}" +# group: "{{ group_name.stdout }}" +# loop: +# - ".config/foo" + +# - name: Copy files +# copy: +# src: "files/{{ item.src }}" +# dest: "{{ account_homedir.stdout }}/{{ item.dest }}" +# mode: 0600 +# owner: "{{ account_name.stdout }}" +# group: "{{ group_name.stdout }}" +# loop: +# - src: foo.conf +# dest: .config/foo/foo.conf + +- import_tasks: tasks/peruser_freebsd.yaml + when: 'os_flavor == "freebsd"' + +- import_tasks: tasks/peruser_linux.yaml + when: 'os_flavor == "linux"' diff --git a/ansible/roles/google_cloud_sdk/tasks/peruser_freebsd.yaml b/ansible/roles/google_cloud_sdk/tasks/peruser_freebsd.yaml new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/google_cloud_sdk/tasks/peruser_linux.yaml b/ansible/roles/google_cloud_sdk/tasks/peruser_linux.yaml new file mode 100644 index 0000000..e69de29