init repo

This commit is contained in:
Tiago Sousa 2023-10-29 16:34:24 +00:00
commit 444a0e0041
13 changed files with 160 additions and 0 deletions

BIN
codebase/roles/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,47 @@
# DO NOT CHANGE!
---
- name: Create Google Kubernetes Engine Cluster
gcp_container_cluster:
name: ascn-cluster
initial_node_count: "{{ gcp_initial_node_count }}"
node_config:
machine_type: "{{ gcp_machine_type }}"
disk_size_gb: "{{ gcp_disk_size_gb }}"
image_type: "{{ gcp_image_type }}"
location: "{{ gcp_zone }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_auth_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: cluster
until: "cluster is not failed"
delay: 60
retries: 3
- name: Verify that the cluster was created
shell: gcloud container clusters describe --project="{{ gcp_project}}" --zone="{{ gcp_zone }}" ascn-cluster
register: results
- name: Verify that the command succeeded
assert:
that:
- results.rc == 0
- name: Create a node pool
gcp_container_node_pool:
name: default-pool
initial_node_count: "{{ gcp_initial_node_count }}"
cluster: "{{ cluster }}"
config:
machine_type: "{{ gcp_machine_type }}"
image_type: "{{ gcp_image_type }}"
disk_size_gb: "{{ gcp_disk_size_gb }}"
location: "{{ gcp_zone }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_auth_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
- name: Connect to the cluster (update kubeconfig)"
shell: gcloud container clusters get-credentials --project="{{ gcp_project}}" --zone="{{ gcp_zone }}" ascn-cluster

View file

@ -0,0 +1,31 @@
# DO NOT CHANGE!
---
- name: Destroy Google Kubernetes Engine Cluster
gcp_container_cluster:
name: ascn-cluster
location: "{{ gcp_zone }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_auth_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: cluster
until: "cluster is not failed"
delay: 60
retries: 3
- name: Verify that the cluster was deleted
gcp_container_cluster_info:
location: "{{ gcp_zone }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_auth_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/cloud-platform
register: results
- name: Verify that the command succeeded
assert:
that:
- '''ascn-cluster'' not in "{{ results[''resources''] | map(attribute=''name'')
| list }}"'

View file

@ -0,0 +1,14 @@
---
- name: Refresh inventory
meta: refresh_inventory
- name: Check that you can connect (GET) to App and it returns a status 200
ansible.builtin.uri:
url: "http://{{ app_ip }}:{{app_port}}/"
method: GET
status_code: 200
register: result
until: result.status == 200
retries: 3
delay: 5