mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-08-22 05:51:49 -07:00
fix: upgrade ansible version, address test and lint errors
This commit is contained in:
parent
c15b47250d
commit
08ada5354d
216 changed files with 4394 additions and 4262 deletions
|
@ -2,20 +2,20 @@
|
|||
- name: Gcloud | Archive | Ensure temp path exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ gcloud_archive_path }}"
|
||||
state: "directory"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Gcloud | Archive | Extract Cloud SDK archive
|
||||
ansible.builtin.unarchive:
|
||||
src: "{{ gcloud_archive_url }}"
|
||||
dest: "{{ gcloud_archive_path }}"
|
||||
remote_src: yes
|
||||
remote_src: true
|
||||
creates: "{{ gcloud_library_path }}"
|
||||
|
||||
- name: Gcloud | Archive | Link binaries to /usr/bin (like package install)
|
||||
ansible.builtin.file:
|
||||
src: "{{ gcloud_library_path }}/bin/{{ item }}"
|
||||
dest: "/usr/bin/{{ item }}"
|
||||
dest: /usr/bin/{{ item }}
|
||||
state: link
|
||||
loop:
|
||||
- bq
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# task file to configure bash completion for gcloud
|
||||
- name: Gcloud | Archive | Debian | Ensure bash completion is installed
|
||||
ansible.builtin.apt:
|
||||
name: "bash-completion"
|
||||
name: bash-completion
|
||||
register: task_result
|
||||
until: task_result is success
|
||||
retries: 10
|
||||
|
@ -25,7 +25,7 @@
|
|||
owner: root
|
||||
group: root
|
||||
state: directory
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
|
||||
- name: Gcloud | Archive | Link binaries to /usr/bin (like package install)
|
||||
ansible.builtin.file:
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
- name: Gcloud | Archive | Get gcloud_status
|
||||
ansible.builtin.debug:
|
||||
var: "gcloud_status"
|
||||
var: gcloud_status
|
||||
|
||||
- name: Gcloud | Archive | Set installed version if installation exists
|
||||
when: gcloud_status.stat.exists
|
||||
|
@ -30,11 +30,10 @@
|
|||
{{ gcloud_installed_version }} is already installed.
|
||||
|
||||
- name: Gcloud | Archive | Start installation
|
||||
when: gcloud_installed_version is undefined or
|
||||
gcloud_version is version(gcloud_installed_version, '>')
|
||||
when: gcloud_installed_version is undefined or gcloud_version is version(gcloud_installed_version, '>')
|
||||
ansible.builtin.include_tasks: archive_install.yml
|
||||
|
||||
- name: Gcloud | Debian | Install the google-cloud-sdk additional components # noqa 301
|
||||
- name: Gcloud | Debian | Install the google-cloud-sdk additional components # noqa no-changed-when
|
||||
ansible.builtin.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"
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
---
|
||||
|
||||
- name: Gcloud | Load Distro and OS specific variables
|
||||
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
|
||||
vars:
|
||||
params:
|
||||
files:
|
||||
- "os/{{ ansible_distribution | lower }}.yml"
|
||||
- "os/{{ ansible_os_family | lower }}.yml"
|
||||
- os/{{ ansible_distribution | lower }}.yml
|
||||
- os/{{ ansible_os_family | lower }}.yml
|
||||
- main.yml
|
||||
paths:
|
||||
- 'vars'
|
||||
- vars
|
||||
|
||||
- name: Gcloud | Install the google-cloud-sdk from {{ gcloud_install_type }}
|
||||
ansible.builtin.include_tasks: "{{ gcloud_install_type }}/main.yml"
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
- name: Gcloud | Debian | Add the gcloud repository
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb {{ gcloud_apt_url }} {{ gcloud_apt_repo }} main"
|
||||
repo: deb {{ gcloud_apt_url }} {{ gcloud_apt_repo }} main
|
||||
state: present
|
||||
filename: google-cloud-sdk
|
||||
|
||||
- name: Gcloud | Debian | Install the google-cloud-sdk package
|
||||
ansible.builtin.apt:
|
||||
name: "google-cloud-sdk"
|
||||
name: google-cloud-sdk
|
||||
update_cache: "yes"
|
||||
register: task_result
|
||||
until: task_result is success
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
- name: Gcloud | Debian | Install the google-cloud-sdk additional components
|
||||
ansible.builtin.apt:
|
||||
name: "google-cloud-sdk-{{ item }}"
|
||||
name: google-cloud-sdk-{{ item }}
|
||||
update_cache: "yes"
|
||||
register: task_result
|
||||
until: task_result is success
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
name: google-cloud-sdk
|
||||
description: Google Cloud SDK
|
||||
baseurl: https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
|
||||
enabled: yes
|
||||
gpgcheck: yes
|
||||
repo_gpgcheck: yes
|
||||
enabled: true
|
||||
gpgcheck: true
|
||||
repo_gpgcheck: true
|
||||
gpgkey:
|
||||
- https://packages.cloud.google.com/yum/doc/yum-key.gpg
|
||||
- https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
|
||||
|
||||
- name: Gcloud | RHEL | Install the google-cloud-sdk package
|
||||
ansible.builtin.yum:
|
||||
name: "google-cloud-sdk"
|
||||
name: google-cloud-sdk
|
||||
update_cache: "yes"
|
||||
register: task_result
|
||||
until: task_result is success
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
- name: Gcloud | Debian | Install the google-cloud-sdk additional components
|
||||
ansible.builtin.yum:
|
||||
name: "google-cloud-sdk-{{ item }}"
|
||||
name: google-cloud-sdk-{{ item }}
|
||||
update_cache: "yes"
|
||||
register: task_result
|
||||
until: task_result is success
|
||||
|
|
|
@ -14,8 +14,8 @@ Role Variables
|
|||
|
||||
```
|
||||
gcp_http_lb_backend: the selflink for the backend that this load balancer will be supporting
|
||||
gcp_project: the name of your gcp project
|
||||
service_account_file: the path to your service account JSON file
|
||||
gcp_http_lb_gcp_project: the name of your gcp project
|
||||
gcp_http_lb_service_account_file: the path to your service account JSON file
|
||||
```
|
||||
|
||||
Example Playbook
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
# defaults file for gcp-http-lb
|
||||
gcp_http_lb_state: present
|
||||
gcp_http_lb_cdn: true
|
||||
gcp_http_lb_name_prefix: 'gcp'
|
||||
gcp_http_lb_name_prefix: gcp
|
||||
|
||||
# Name schemes for resources being created
|
||||
gcp_http_lb_globaladdress: "{{gcp_lb_name_prefix}}-globaladdress"
|
||||
gcp_http_lb_instancegroup: "{{gcp_lb_name_prefix}}-instancegroup"
|
||||
gcp_http_lb_healthcheck: "{{gcp_lb_name_prefix}}-healthcheck"
|
||||
gcp_http_lb_backendservice: "{{gcp_lb_name_prefix}}-backendservice"
|
||||
gcp_http_lb_urlmap: "{{gcp_lb_name_prefix}}-urlmap"
|
||||
gcp_http_lb_httpproxy: "{{gcp_lb_name_prefix}}-httpproxy"
|
||||
gcp_http_lb_forwardingrule: "{{gcp_lb_name_prefix}}-forwardingrule"
|
||||
gcp_http_lb_globaladdress: "{{ gcp_lb_name_prefix }}-globaladdress"
|
||||
gcp_http_lb_instancegroup: "{{ gcp_lb_name_prefix }}-instancegroup"
|
||||
gcp_http_lb_healthcheck: "{{ gcp_lb_name_prefix }}-healthcheck"
|
||||
gcp_http_lb_backendservice: "{{ gcp_lb_name_prefix }}-backendservice"
|
||||
gcp_http_lb_urlmap: "{{ gcp_lb_name_prefix }}-urlmap"
|
||||
gcp_http_lb_httpproxy: "{{ gcp_lb_name_prefix }}-httpproxy"
|
||||
gcp_http_lb_forwardingrule: "{{ gcp_lb_name_prefix }}-forwardingrule"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
---
|
||||
galaxy_info:
|
||||
author: googlecloudplatform
|
||||
description: Create a HTTP Load Balancer on GCP
|
||||
|
@ -16,7 +17,7 @@ galaxy_info:
|
|||
# - CC-BY
|
||||
license: GPLv3
|
||||
|
||||
min_ansible_version: 2.7
|
||||
min_ansible_version: "2.7"
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
|
@ -47,12 +48,12 @@ galaxy_info:
|
|||
# - 99.99
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
|
|
|
@ -1,65 +1,65 @@
|
|||
---
|
||||
- name: create a global address for the load balancer.
|
||||
gcp_compute_global_address:
|
||||
name: "{{ gcp_http_lb_globaladdress }}"
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
- name: Create a global address for the load balancer.
|
||||
google.cloud.gcp_compute_global_address:
|
||||
name: "{{ gcp_http_lb_globaladdress }}"
|
||||
project: "{{ gcp_http_lb_gcp_project }}"
|
||||
auth_kind: "{{ gcp_http_lb_auth_kind }}"
|
||||
service_account_file: "{{ gcp_http_lb_service_account_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
register: globaladdress
|
||||
- name: create a http health check to verify lb working
|
||||
gcp_compute_http_health_check:
|
||||
name: "{{ gcp_http_lb_healthcheck }}"
|
||||
healthy_threshold: 10
|
||||
port: 80
|
||||
timeout_sec: 2
|
||||
unhealthy_threshold: 5
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
- name: Create a http health check to verify lb working
|
||||
google.cloud.gcp_compute_http_health_check:
|
||||
name: "{{ gcp_http_lb_healthcheck }}"
|
||||
healthy_threshold: 10
|
||||
port: 80
|
||||
timeout_sec: 2
|
||||
unhealthy_threshold: 5
|
||||
project: "{{ gcp_http_lb_gcp_project }}"
|
||||
auth_kind: "{{ gcp_http_lb_auth_kind }}"
|
||||
service_account_file: "{{ gcp_http_lb_service_account_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
register: healthcheck
|
||||
- name: create a backend service
|
||||
gcp_compute_backend_service:
|
||||
name: "{{ gcp_http_lb_backendservice }}"
|
||||
backends:
|
||||
- name: Create a backend service
|
||||
google.cloud.gcp_compute_backend_service:
|
||||
name: "{{ gcp_http_lb_backendservice }}"
|
||||
backends:
|
||||
- group: "{{ gcp_http_lb_backend.selfLink }}"
|
||||
health_checks:
|
||||
health_checks:
|
||||
- "{{ healthcheck.selfLink }}"
|
||||
enable_cdn: "{{ gcp_http_lb_cdn }}"
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
enable_cdn: "{{ gcp_http_lb_cdn }}"
|
||||
project: "{{ gcp_http_lb_gcp_project }}"
|
||||
auth_kind: "{{ gcp_http_lb_auth_kind }}"
|
||||
service_account_file: "{{ gcp_http_lb_service_account_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
register: backendservice
|
||||
- name: create a url map
|
||||
gcp_compute_url_map:
|
||||
name: "{{ gcp_http_lb_urlmap }}"
|
||||
default_service: "{{ backendservice }}"
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
- name: Create a url map
|
||||
google.cloud.gcp_compute_url_map:
|
||||
name: "{{ gcp_http_lb_urlmap }}"
|
||||
default_service: "{{ backendservice }}"
|
||||
project: "{{ gcp_http_lb_gcp_project }}"
|
||||
auth_kind: "{{ gcp_http_lb_auth_kind }}"
|
||||
service_account_file: "{{ gcp_http_lb_service_account_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
register: urlmap
|
||||
- name: create a target http proxy
|
||||
gcp_compute_target_http_proxy:
|
||||
name: "{{ gcp_http_lb_httpproxy }}"
|
||||
url_map: "{{ urlmap }}"
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
- name: Create a target http proxy
|
||||
google.cloud.gcp_compute_target_http_proxy:
|
||||
name: "{{ gcp_http_lb_httpproxy }}"
|
||||
url_map: "{{ urlmap }}"
|
||||
project: "{{ gcp_http_lb_gcp_project }}"
|
||||
auth_kind: "{{ gcp_http_lb_auth_kind }}"
|
||||
service_account_file: "{{ gcp_http_lb_service_account_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
register: httpproxy
|
||||
- name: create a global forwarding rule
|
||||
gcp_compute_global_forwarding_rule:
|
||||
name: "{{ gcp_http_lb_forwardingrule }}"
|
||||
ip_address: "{{ globaladdress.address }}"
|
||||
load_balancing_scheme: "EXTERNAL"
|
||||
ip_protocol: TCP
|
||||
port_range: 80-80
|
||||
target: "{{ httpproxy.selfLink }}"
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
- name: Create a global forwarding rule
|
||||
google.cloud.gcp_compute_global_forwarding_rule:
|
||||
name: "{{ gcp_http_lb_forwardingrule }}"
|
||||
ip_address: "{{ globaladdress.address }}"
|
||||
load_balancing_scheme: EXTERNAL
|
||||
ip_protocol: TCP
|
||||
port_range: 80-80
|
||||
target: "{{ httpproxy.selfLink }}"
|
||||
project: "{{ gcp_http_lb_gcp_project }}"
|
||||
auth_kind: "{{ gcp_http_lb_auth_kind }}"
|
||||
service_account_file: "{{ gcp_http_lb_service_account_file }}"
|
||||
state: "{{ gcp_http_lb_state }}"
|
||||
register: result
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
- name: Test gcp_http_lb role
|
||||
hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- gcp_http_lb
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
---
|
||||
# vars file for gcp-http-lb
|
||||
vars:
|
||||
# The backend this LB will be supporting. This will typically be a Instance Group:
|
||||
# example: projects/sample-project/zones/us-central1-c/instanceGroups/sample-instance-group
|
||||
gcp_http_lb_backend: your-backend
|
||||
# The name of your GCP project
|
||||
gcp_project: your-project
|
||||
# The kind of authentication you will use (serviceaccount is recommended)
|
||||
auth_kind: serviceaccount
|
||||
# The path to your service account file (if using the serviceaccount auth kind)
|
||||
service_account_file: path-to-service-account-file
|
||||
|
||||
# The backend this LB will be supporting. This will typically be a Instance Group:
|
||||
# example: projects/sample-project/zones/us-central1-c/instanceGroups/sample-instance-group
|
||||
gcp_http_lb_backend: your-backend
|
||||
# The name of your GCP project
|
||||
gcp_http_lb_gcp_project: your-project
|
||||
# The kind of authentication you will use (serviceaccount is recommended)
|
||||
gcp_http_lb_auth_kind: serviceaccount
|
||||
# The path to your service account file (if using the serviceaccount auth kind)
|
||||
gcp_http_lb_service_account_file: path-to-service-account-file
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- name: Gcsfuse | Ensure gpg is installed
|
||||
ansible.builtin.apt:
|
||||
name: "gnupg"
|
||||
name: gnupg
|
||||
register: task_result
|
||||
until: task_result is success
|
||||
retries: 10
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
- name: Gcsfuse | Install gcsfuse
|
||||
ansible.builtin.apt:
|
||||
name: "gcsfuse"
|
||||
name: gcsfuse
|
||||
update_cache: "yes"
|
||||
register: task_result
|
||||
until: task_result is success
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue