init repo
This commit is contained in:
commit
444a0e0041
13 changed files with 160 additions and 0 deletions
1
README.md
Normal file
1
README.md
Normal file
|
@ -0,0 +1 @@
|
|||
# GrupoTP-37
|
BIN
codebase/.DS_Store
vendored
Normal file
BIN
codebase/.DS_Store
vendored
Normal file
Binary file not shown.
2
codebase/docker/Dockerfile
Normal file
2
codebase/docker/Dockerfile
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Dockerfile for the laravel.io application
|
||||
# TO DO
|
7
codebase/gke-cluster-create.yml
Normal file
7
codebase/gke-cluster-create.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
# DO NOT CHANGE!
|
||||
---
|
||||
- name: Create a GKE cluster
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
roles:
|
||||
- gke_cluster_create
|
7
codebase/gke-cluster-destroy.yml
Normal file
7
codebase/gke-cluster-destroy.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
# DO NOT CHANGE!
|
||||
---
|
||||
- name: Destroy GKE cluster
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
roles:
|
||||
- gke_cluster_destroy
|
23
codebase/inventory/gcp.yml
Normal file
23
codebase/inventory/gcp.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
all:
|
||||
vars:
|
||||
|
||||
# GKE cluster variables
|
||||
gcp_project: <project_name> # ID of GCP Project
|
||||
gcp_auth_kind: serviceaccount # Do not change
|
||||
gcp_cred_file: <path_service_account> # Path to service account keys (json file downloaded from GCP)
|
||||
|
||||
gcp_zone: us-central1-a
|
||||
gcp_image_type: ubuntu_containerd
|
||||
gcp_machine_type: e2-small # Can be changed if necessary
|
||||
gcp_disk_size_gb: 100 # Can be changed if necessary
|
||||
gcp_initial_node_count: 2 # Number of nodes to create. Can be changed if necessary
|
||||
|
||||
|
||||
# APP variables
|
||||
app_ip: <APP_SERVICE_IP> # Needs to be updated
|
||||
app_port: <APP_PORT> # Needs to be updated
|
||||
|
||||
|
||||
# Additional variables
|
||||
# ...
|
3
codebase/laravelio-deploy.yml
Normal file
3
codebase/laravelio-deploy.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
# Playbook to deploy laravel.io and its components
|
||||
# TO DO
|
3
codebase/laravelio-undeploy.yml
Normal file
3
codebase/laravelio-undeploy.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
# Playbook to undeploy laravel.io and its component
|
||||
# TO DO
|
BIN
codebase/roles/.DS_Store
vendored
Normal file
BIN
codebase/roles/.DS_Store
vendored
Normal file
Binary file not shown.
47
codebase/roles/gke_cluster_create/tasks/main.yml
Normal file
47
codebase/roles/gke_cluster_create/tasks/main.yml
Normal 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
|
31
codebase/roles/gke_cluster_destroy/tasks/main.yml
Normal file
31
codebase/roles/gke_cluster_destroy/tasks/main.yml
Normal 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 }}"'
|
14
codebase/roles/test_laravelio/tasks/main.yml
Normal file
14
codebase/roles/test_laravelio/tasks/main.yml
Normal 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
|
22
codebase/test-all.yml
Normal file
22
codebase/test-all.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
# Playbook to test the full deployment of laravel.io (from creation to destruction)
|
||||
|
||||
- import_playbook: laravelio-deploy.yml
|
||||
|
||||
- name: Tests
|
||||
hosts: localhost
|
||||
gather_facts: true
|
||||
roles:
|
||||
- { role: test_app }
|
||||
|
||||
- import_playbook: laravelio-undeploy.yml
|
||||
|
||||
- import_playbook: laravelio-deploy.yml
|
||||
|
||||
- name: Tests
|
||||
hosts: localhost
|
||||
gather_facts: yes
|
||||
roles:
|
||||
- { role: test_app }
|
||||
|
||||
- import_playbook: laravelio-undeploy.yml delete_data='true'
|
Loading…
Reference in a new issue