From 444a0e00415d9e67b9ce217c8c28c94a61b0ef9d Mon Sep 17 00:00:00 2001 From: tsousa111 Date: Sun, 29 Oct 2023 16:34:24 +0000 Subject: [PATCH] init repo --- README.md | 1 + codebase/.DS_Store | Bin 0 -> 6148 bytes codebase/docker/Dockerfile | 2 + codebase/gke-cluster-create.yml | 7 +++ codebase/gke-cluster-destroy.yml | 7 +++ codebase/inventory/gcp.yml | 23 +++++++++ codebase/laravelio-deploy.yml | 3 ++ codebase/laravelio-undeploy.yml | 3 ++ codebase/roles/.DS_Store | Bin 0 -> 6148 bytes .../roles/gke_cluster_create/tasks/main.yml | 47 ++++++++++++++++++ .../roles/gke_cluster_destroy/tasks/main.yml | 31 ++++++++++++ codebase/roles/test_laravelio/tasks/main.yml | 14 ++++++ codebase/test-all.yml | 22 ++++++++ 13 files changed, 160 insertions(+) create mode 100644 README.md create mode 100644 codebase/.DS_Store create mode 100644 codebase/docker/Dockerfile create mode 100644 codebase/gke-cluster-create.yml create mode 100644 codebase/gke-cluster-destroy.yml create mode 100644 codebase/inventory/gcp.yml create mode 100644 codebase/laravelio-deploy.yml create mode 100644 codebase/laravelio-undeploy.yml create mode 100644 codebase/roles/.DS_Store create mode 100644 codebase/roles/gke_cluster_create/tasks/main.yml create mode 100644 codebase/roles/gke_cluster_destroy/tasks/main.yml create mode 100644 codebase/roles/test_laravelio/tasks/main.yml create mode 100644 codebase/test-all.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d623d7 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# GrupoTP-37 diff --git a/codebase/.DS_Store b/codebase/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b2fba7773df3d5c0a1490d6c42a0a765961b5e69 GIT binary patch literal 6148 zcmeHKPiqrF6n~R$+lfU9rAkjS=rv$sidcHt#wZ@e6%|xsw!5TDH#1>()1V=+XZt1k zF$B-vJnJX$Q+V;spVEw3^;A)r2Q$CfH}B2+?Jw+11^`HR614#u06?)x^e$mnVRBx! zC94_F6-1)eh#?E7`8Z5PxD@RiP64OD-=={4cGn;R0S9md_V@cf9H&WMv|67@ZN*z% zTc_)EgT4w5#WW}e#U$?zvKR8{i4bXcHXejelX%*1Y~2&Q7$iK-R6-KP81nL2!Xq*5 ziV2T$l^f^@TBr4XV|zC1-0d`3duMmvWV7AdttQ*)+?mho^y4=MWT10|- zjyCE^EeJN zo(euhzvNzr1UMX{>KqFE1u}SJGp&88j#}jV;eq$u@U2*HB+gm?IkuOT9{qrbM5P=Q^UuKIOkCvVb_0z1)N>50_OXn8y8&1E$^w6yg$LiceWYU4?8!R=V2aV`dM4d{^6@%z>^fMFZ8!R>IbReoSu45__ zb3-AjI{KLk2jXjVy;Hy`U@Neq9~<)gzyI_5zn$csoB~dP|4ISk^@3g(U&)-UOD`wS wT88a4Hfb`h)TmOhGsm$S$fI~0n=+hZa)9U?EH$DB&HWKjGPuqu@JAK+4oNqweE # ID of GCP Project + gcp_auth_kind: serviceaccount # Do not change + gcp_cred_file: # 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: # Needs to be updated + app_port: # Needs to be updated + + + # Additional variables + # ... \ No newline at end of file diff --git a/codebase/laravelio-deploy.yml b/codebase/laravelio-deploy.yml new file mode 100644 index 0000000..2aa6972 --- /dev/null +++ b/codebase/laravelio-deploy.yml @@ -0,0 +1,3 @@ +--- +# Playbook to deploy laravel.io and its components +# TO DO diff --git a/codebase/laravelio-undeploy.yml b/codebase/laravelio-undeploy.yml new file mode 100644 index 0000000..996dd9e --- /dev/null +++ b/codebase/laravelio-undeploy.yml @@ -0,0 +1,3 @@ +--- +# Playbook to undeploy laravel.io and its component +# TO DO \ No newline at end of file diff --git a/codebase/roles/.DS_Store b/codebase/roles/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fcc31b9225bc1cd93f069d88b96c380bbd508d77 GIT binary patch literal 6148 zcmeHKO-sW-5S_IZf{GNqcntUpdh_5RmiP;L@nr3XR52wbT0u|wC;l4oR|&qES=xl8 zHHwJH4D7ySvM<~B%I;)|$n_SJE>VYw0yM_<4!WA)=iDl>iQ&md5cYNk=wbWW*$O&NNF;_$e;gkwgs`Ez-r*z~)KQ8i^ zD=M9w%#8Q=nVmnOIGG*!P==F>6saP7Ds z_aMpF)`~c;wISLS8V8Td6@`M%mt(o$QhbCafoCCK03(mNA~Fd35D*)zGY5Xvfe(Q` Bn}+}Z literal 0 HcmV?d00001 diff --git a/codebase/roles/gke_cluster_create/tasks/main.yml b/codebase/roles/gke_cluster_create/tasks/main.yml new file mode 100644 index 0000000..83940d4 --- /dev/null +++ b/codebase/roles/gke_cluster_create/tasks/main.yml @@ -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 diff --git a/codebase/roles/gke_cluster_destroy/tasks/main.yml b/codebase/roles/gke_cluster_destroy/tasks/main.yml new file mode 100644 index 0000000..0bdb44f --- /dev/null +++ b/codebase/roles/gke_cluster_destroy/tasks/main.yml @@ -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 }}"' \ No newline at end of file diff --git a/codebase/roles/test_laravelio/tasks/main.yml b/codebase/roles/test_laravelio/tasks/main.yml new file mode 100644 index 0000000..097aceb --- /dev/null +++ b/codebase/roles/test_laravelio/tasks/main.yml @@ -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 \ No newline at end of file diff --git a/codebase/test-all.yml b/codebase/test-all.yml new file mode 100644 index 0000000..55b8b87 --- /dev/null +++ b/codebase/test-all.yml @@ -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' \ No newline at end of file