Skip to content

Miscellaneous resilience improvements #2358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ansible/ci/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ gcp_instance_prefix: ci
gcp_available_zones:
- us-central1-a
- us-central1-b
- us-central1-c
- us-central1-f
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- us-central1-f
- us-central1-f
- us-central1-d

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ gcloud compute machine-types list --filter="name=t2a-standard-2 AND zone~'^us-'" --format="value(zone)"
us-central1-a
us-central1-b
us-central1-f
us-central1-d

ansible_user: runner
gcp_network_name: collector-ci
Expand Down
1 change: 0 additions & 1 deletion ansible/dev/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ gcp_instance_prefix: "{{ lookup('env', 'USER') }}-dev"
gcp_available_zones:
- us-central1-a
- us-central1-b
- us-central1-c
- us-central1-f
ansible_user: "{{ lookup('env', 'USER') }}"
gcp_network_name: default
Expand Down
34 changes: 34 additions & 0 deletions ansible/roles/create-vm/tasks/create-gcp-instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: Safely create GCP compute instance
block:
- name: Create compute instance
google.cloud.gcp_compute_instance:
name: "{{ vm_name }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_auth_kind }}"
service_account_file: "{{ gcp_service_account_file }}"
zone: "{{ gcp_zone }}"
machine_type: "{{ vm_machine_type | default('e2-standard-2') }}"
disks:
- auto_delete: true
boot: true
initialize_params:
disk_size_gb: "{{ vm_disk_size | default(20) }}"
source_image: "{{ gcp_source_image }}"
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: External NAT
type: ONE_TO_ONE_NAT
labels: "{{ gcp_default_labels | combine(gcp_extra_labels) }}"
metadata: "{{ gcp_meta_data | default({}) }}"
register: instance_result
rescue:
- name: Remove failed GCP compute instance
google.cloud.gcp_compute_instance:
name: "{{ vm_name }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_auth_kind }}"
service_account_file: "{{ gcp_service_account_file }}"
zone: "{{ gcp_zone }}"
state: absent
24 changes: 2 additions & 22 deletions ansible/roles/create-vm/tasks/create-gcp-vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,8 @@
register: network

- name: Create GCP VM
google.cloud.gcp_compute_instance:
name: "{{ vm_name }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_auth_kind }}"
service_account_file: "{{ gcp_service_account_file }}"
zone: "{{ gcp_zone }}"
machine_type: "{{ vm_machine_type | default('e2-standard-2') }}"
disks:
- auto_delete: true
boot: true
initialize_params:
disk_size_gb: "{{ vm_disk_size | default(20) }}"
source_image: "{{ gcp_source_image }}"
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: External NAT
type: ONE_TO_ONE_NAT
labels: "{{ gcp_default_labels | combine(gcp_extra_labels) }}"
metadata: "{{ gcp_meta_data | default({}) }}"
ansible.builtin.include_tasks:
file: create-gcp-instance.yml

# This looks like a lot, and its mostly because ansible support
# for "breaking" from a loop is not all that great at the moment.
Expand All @@ -80,9 +62,7 @@
loop: "{{ vm_available_zones }}"
loop_control:
loop_var: gcp_zone
register: instance_result
when: >
(vm_arch == "amd64" or vm_arch == "arm64") and not condition and excluded == false
vars:
condition: "{{ (instance_result | default({'changed': false})).changed }}"

Loading