gcloud role w/tests

This commit is contained in:
ericsysmin 2020-05-01 19:16:48 -07:00
commit fa14b8c218
23 changed files with 643 additions and 0 deletions

View file

@ -0,0 +1,50 @@
---
- name: gcloud | Archive | Ensure temp path exists
file: path={{ gcloud_archive_path }} state=directory
- name: gcloud | Archive | Extract Cloud SDK archive
unarchive:
src: "{{ gcloud_archive_url }}"
dest: "{{ gcloud_archive_path }}"
remote_src: yes
creates: "{{ gcloud_library_path }}"
- name: gcloud | Archive | Link binaries to /usr/bin (like package install)
file:
src: "{{ gcloud_library_path }}/bin/{{ item }}"
dest: "/usr/bin/{{ item }}"
state: link
loop:
- bq
- docker-credential-gcloud
- gcloud
- git-credential-gcloud.sh
- gsutil
when: not gcloud_install_script
- name: gcloud | Archive | Add command completion
include_tasks: command_completion.yml
when: gcloud_command_completion
- name: gcloud | Archive | Install into Path
command: >-
{{ gcloud_archive_path }}/install.sh --quiet
--usage-reporting {{ gcloud_usage_reporting | lower }}
{% if gcloud_profile_path %}
--rc-path {{ gcloud_profile_path }}
{% endif %}
--command-completion {{ gcloud_command_completion | lower }}
--path-update {{ gcloud_update_path | lower }}
{% if gcloud_override_components | length > 0 %}--override-components
{% for component in gcloud_override_components %}{{ component }}
{% if loop.index < gcloud_override_components | length %}
{% endif %}
{% endfor %}
{% endif %}
{% if gcloud_additional_components | length > 0 %}--additional-components
{% for component in gcloud_additional_components %}{{ component }}
{% if loop.index < gcloud_additional_components | length %}
{% endif %}
{% endfor %}
{% endif %}
when: gcloud_install_script

View file

@ -0,0 +1,32 @@
---
# task file to configure bash completion for gcloud
- name: gcloud | Archive | Debian | Ensure bash completion is installed
apt: name=bash-completion
register: task_result
until: task_result is success
retries: 10
delay: 2
when: ansible_os_family == "Debian"
- name: gcloud | Archive | RedHat | Ensure bash completion is installed
yum:
name:
- bash-completion
register: task_result
until: task_result is success
retries: 10
delay: 2
when: ansible_os_family == "RedHat"
- name: gcloud | Archive | Ensure bash_completion.d directory exists
file:
path: /etc/bash_completion.d
owner: root
group: root
state: directory
- name: gcloud | Archive | Link binaries to /usr/bin (like package install)
file:
src: "{{ gcloud_library_path }}/completion.bash.inc"
dest: /etc/bash_completion.d/gcloud
state: link

View file

@ -0,0 +1,37 @@
---
# tasks to install gcloud via archive
- name: gcloud | Archive | Look for existing Google Cloud SDK installation
stat:
path: "{{ gcloud_archive_path }}/google-cloud-sdk/VERSION"
register: gcloud_status
- debug: var=gcloud_status
- name: gcloud | Archive | Set installed version if installation exists
block:
- name: gcloud | Archive | Importing contents of {{ gcloud_archive_path }}/google-cloud-sdk/VERSION
slurp:
src: "{{ gcloud_archive_path }}/google-cloud-sdk/VERSION"
register: gcloud_installed_version_data
- name: gcloud | Archive | Setting the gcloud_installed_version variable/fact
set_fact:
gcloud_installed_version: "{{ (gcloud_installed_version_data.content|b64decode|trim) }}"
- debug:
msg: "google-cloud-sdk: {{ gcloud_installed_version }} is installed"
- debug:
msg: >-
Skipping installation of google-cloud-sdk version {{ gcloud_version }} when
{{ gcloud_installed_version }} is already installed.
when: gcloud_version == gcloud_installed_version
when: gcloud_status.stat.exists
- name: gcloud | Archive | Start installation
include_tasks: archive_install.yml
when: gcloud_installed_version is undefined or
gcloud_version is version(gcloud_installed_version, '>')
- name: gcloud | Debian | Install the google-cloud-sdk additional components # noqa 301
command: gcloud components install {{ item }}
register: gcloud_install_comp_status
changed_when: "'All components are up to date.' not in gcloud_install_comp_status.stderr_lines"
loop: "{{ gcloud_additional_components }}"