ansible.install-gcloud

Install gcloud

==============

This guide shows you how to install the Google Cloud SDK, including the Kubernetes command-line tool, kubectl. If you're working with Kubernetes, this setup is for you, as it automates the installation process on your computers.

Step 1: Find the Right Archive to Install


Before you can run the installation, you need to know which file (archive) to use. Unfortunately, there’s no automatic way to find this out. You cannot use regular package managers to install the SDK. Instead, visit the SDK website and choose the archive that matches your system. Once you have the archive name, you can use it in your setup.

Step 2: Installing the Archive


This setup can either download the archive directly to your computer or you can manually download it and provide the path where it is stored.

  • To let the setup download the archive, provide the variable gcloud_archive_name.
  • If you already have the archive, use gcloud_archive_path to specify its location for installation.

Where are Components Installed?


The Google Cloud installer does not place executable files in common directories like /usr/local/bin. Instead, they will be located in {{ gcloud_install_path }}/bin. If you want them in a different location, you need to add extra tasks to your setup after the installation.

The installer will also update a login script to add {{ gcloud_install_path }}/bin to your system's PATH. If you want this, keep gcloud_update_path set to true. You can specify a particular login script by setting gcloud_profile_path.

Available Components


You can control which components to install using the gcloud_additional_components and gcloud_override_components variables.

Component Name Component ID Size
Cloud Datastore Emulator cloud-datastore-emulator 15.9 MiB
Cloud Datastore Emulator (Legacy) gcd-emulator 38.1 MiB
Cloud Pub/Sub Emulator pubsub-emulator 10.8 MiB
gcloud Alpha Commands alpha < 1 MiB
gcloud Beta Commands beta < 1 MiB
gcloud app Java Extensions app-engine-java 131.0 MiB
gcloud app PHP Extensions (Mac OS X) app-engine-php-darwin 21.9 MiB
gcloud app Python Extensions app-engine-python 7.2 MiB
BigQuery Command Line Tool bq < 1 MiB
Cloud SDK Core Libraries core 4.1 MiB
Cloud Storage Command Line Tool gsutil 2.6 MiB
Default set of gcloud commands gcloud
kubectl kubectl 8.1 MiB

Requirements


The target computer needs:

  • The tar command.

Additionally, if you're downloading the archive, the target machine must be able to access the internet.

Role Variables


  • gcloud_archive_name: (Default: '') Name of the archive to download from Google. Example: google-cloud-sdk-114.0.0-darwin-x86_64.tar.gz. Check the SDK site for your system's archive name.

  • gcloud_archive_path: (Default: '') Path to the gcloud archive on the Ansible host. If provided, this archive will be copied to the target machine.

  • gcloud_tmp_path: (Default: /tmp) Temporary storage path for the archive.

  • gcloud_force_download: (Default: yes) Always download the archive, even if it already exists in gcloud_tmp_path.

  • gcloud_install_path: (Default: "{{ ansible_env.HOME }}") Location on the target machine for the installed files.

  • gcloud_usage_reporting: (Default: no) Enable usage reporting?

  • gcloud_profile_path: (Default: '~/.profile') Path to the login script to be updated by the installer.

  • gcloud_command_completion: (Default: yes) Enable command completion in the login script?

  • gcloud_update_path: (Default: yes) Update the PATH in the login script?

  • gcloud_override_components: (Default: []) Specify components to install instead of the default.

  • gcloud_additional_components: (Default: [kubectl]) Additional components to install. These will either be added to the default or override list.

Example Playbook


Here’s a sample playbook to run the installation:

- name: Create temporary install path 
  hosts: localhost
  connection: local
  gather_facts: no
  tasks:
    - name: Create temporary path
      file:
        path: "/tmp/install_gcloud"
        state: directory
        mode: 0777

- name: Run the installation
  hosts: localhost
  connection: local
  gather_facts: yes  # Collect facts to define ansible_env.HOME
  roles:
    - role: role-install-gcloud
      gcloud_tmp_path: /tmp/install_gcloud 
      gcloud_archive_name: google-cloud-sdk-114.0.0-darwin-x86_64.tar.gz

- name: Remove temporary install path
  hosts: localhost
  connection: local
  gather_facts: no
  tasks:
    - name: Remove the temporary path
      file:
        path: "/tmp/install_gcloud"
        state: absent

License


MIT

Authors


@chouseknecht

Informazioni sul progetto

Install Google Cloud SDK and kubectl

Installa
ansible-galaxy install ansible.install-gcloud
Licenza
mit
Download
5.1k
Proprietario