generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from GomathiselviS/webapp_HA
Create a playbook to deploy a simple flask web app into high availability architecture
- Loading branch information
Showing
16 changed files
with
506 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
minor_changes: | ||
- "Add a playbook to deploy a simple flask web app into high availability architecture (https://github.com/redhat-cop/cloud.aws_ops/pull/97)." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
- name: Migrate webapp | ||
hosts: localhost | ||
gather_facts: false | ||
|
||
vars_files: | ||
- vars/main.yaml | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
- name: Add Route53 configurations | ||
module_defaults: | ||
group/aws: | ||
aws_access_key: "{{ aws_access_key | default(omit) }}" | ||
aws_secret_key: "{{ aws_secret_key | default(omit) }}" | ||
security_token: "{{ security_token | default(omit) }}" | ||
block: | ||
|
||
- name: Add route53 health check for the load balancer in primary region | ||
amazon.aws.route53_health_check: | ||
health_check_name: "healthchk-lb-primary" | ||
fqdn: "{{ primary_lb.elb.dns_name }}" | ||
port: 5000 | ||
type: HTTP | ||
use_unique_names: true | ||
state: present | ||
register: healthchk_primary_result | ||
|
||
- name: Add route53 health check for the load balancer in replica region | ||
amazon.aws.route53_health_check: | ||
health_check_name: "healthchk-lb-replica" | ||
fqdn: "{{ replica_lb.elb.dns_name }}" | ||
port: 5000 | ||
type: HTTP | ||
use_unique_names: true | ||
state: present | ||
register: healthchk_replica_result | ||
|
||
- name: Pause for 30 secs for the health check status to be in sync | ||
ansible.builtin.pause: | ||
seconds: 30 | ||
|
||
- name: Add an alias record that points to an aws ELB in the primary region | ||
amazon.aws.route53: | ||
state: present | ||
zone: "{{ route53_zone_name }}" | ||
record: "{{ route53_subdomain }}.{{ route53_zone_name }}" | ||
type: A | ||
value: "{{ primary_lb.elb.dns_name }}" | ||
alias: true | ||
identifier: "primary-record" | ||
failover: "PRIMARY" | ||
health_check: "{{ healthchk_primary_result.health_check.id }}" | ||
alias_hosted_zone_id: "{{ primary_lb.elb.hosted_zone_id }}" | ||
register: alias_record_primary_result | ||
|
||
- name: Add an alias record that points to an aws ELB in the replica region | ||
amazon.aws.route53: | ||
state: present | ||
zone: "{{ route53_zone_name }}" | ||
record: "{{ route53_subdomain }}.{{ route53_zone_name }}" | ||
type: A | ||
value: "{{ replica_lb.elb.dns_name }}" | ||
alias: true | ||
identifier: "replica-record" | ||
failover: "SECONDARY" | ||
health_check: "{{ healthchk_replica_result.health_check.id }}" | ||
alias_hosted_zone_id: "{{ replica_lb.elb.hosted_zone_id }}" | ||
register: alias_record_replica_result | ||
|
||
- name: Pause for 30 secs for the alias records to be active | ||
ansible.builtin.pause: | ||
seconds: 30 | ||
|
||
- name: Get Application URL | ||
ansible.builtin.debug: | ||
msg: "Application url: {{ route53_subdomain }}.{{ route53_zone_name }}:{{ deploy_flask_app_listening_port }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
- name: Create resources playbook | ||
module_defaults: | ||
group/aws: | ||
aws_access_key: "{{ aws_access_key | default(omit) }}" | ||
aws_secret_key: "{{ aws_secret_key | default(omit) }}" | ||
security_token: "{{ security_token | default(omit) }}" | ||
block: | ||
- name: Get security group id - primary region | ||
amazon.aws.ec2_security_group_info: | ||
filters: | ||
group-name: "{{ rds_secgroup_name }}" | ||
region: "{{ rds_primary_cluster_region }}" | ||
register: rds_primary_sg | ||
|
||
- name: Get security group id - replica region | ||
amazon.aws.ec2_security_group_info: | ||
filters: | ||
group-name: "{{ rds_secgroup_name }}" | ||
region: "{{ rds_replica_cluster_region }}" | ||
register: rds_replica_sg | ||
|
||
- name: Create Aurora db cluster | ||
ansible.builtin.include_role: | ||
name: cloud.aws_ops.create_rds_global_cluster | ||
vars: | ||
create_rds_global_cluster_operation: create | ||
create_rds_global_cluster_engine: "{{ rds_engine }}" | ||
create_rds_global_cluster_engine_version: "{{ rds_engine_version }}" | ||
create_rds_global_cluster_instance_class: "{{ rds_instance_class }}" | ||
create_rds_global_cluster_master_username: "{{ deploy_flask_app_rds_master_username }}" | ||
create_rds_global_cluster_master_user_password: "{{ deploy_flask_app_rds_master_password }}" | ||
create_rds_global_cluster_global_cluster_name: "{{ rds_global_cluster_name }}" | ||
create_rds_global_cluster_primary_cluster_name: "{{ rds_primary_cluster_name }}" | ||
create_rds_global_cluster_primary_cluster_region: "{{ rds_primary_cluster_region }}" | ||
create_rds_global_cluster_primary_cluster_instance_name: "{{ rds_primary_cluster_instance_name }}" | ||
create_rds_global_cluster_replica_cluster_name: "{{ rds_replica_cluster_name }}" | ||
create_rds_global_cluster_replica_cluster_region: "{{ rds_replica_cluster_region }}" | ||
create_rds_global_cluster_replica_cluster_instance_name: "{{ rds_replica_cluster_instance_name }}" | ||
create_rds_global_cluster_db_subnet_group_name: "{{ rds_subnet_group_name }}" | ||
create_rds_global_cluster_primary_cluster_db_name: "{{ rds_instance_name }}" | ||
create_rds_global_cluster_primary_cluster_vpc_security_group_ids: | ||
- "{{ rds_primary_sg.security_groups[0].group_id }}" | ||
create_rds_global_cluster_replica_cluster_vpc_security_group_ids: | ||
- "{{ rds_replica_sg.security_groups[0].group_id }}" | ||
|
||
- name: Get primary instance info | ||
amazon.aws.rds_instance_info: | ||
db_instance_identifier: "{{ rds_primary_cluster_instance_name }}" | ||
region: "{{ rds_primary_cluster_region }}" | ||
register: primary_instance_info_result | ||
|
||
- name: Get primary cluster info | ||
amazon.aws.rds_cluster_info: | ||
db_cluster_identifier: "{{ rds_primary_cluster_name }}" | ||
region: "{{ rds_primary_cluster_region }}" | ||
register: primary_cluster_info_result | ||
|
||
- name: Get replica cluster info | ||
amazon.aws.rds_cluster_info: | ||
db_cluster_identifier: "{{ rds_replica_cluster_name }}" | ||
region: "{{ rds_replica_cluster_region }}" | ||
register: replica_cluster_info_result | ||
|
||
- name: Get replica instance info | ||
amazon.aws.rds_instance_info: | ||
db_instance_identifier: "{{ rds_replica_cluster_instance_name }}" | ||
region: "{{ rds_replica_cluster_region }}" | ||
register: replica_instance_info_result | ||
|
||
- name: Get global db info | ||
Check failure on line 71 in playbooks/webapp/tasks/create_aurora_db_cluster.yaml GitHub Actions / ansible-lintsyntax-check[specific]
|
||
amazon.aws.rds_global_cluster_info: | ||
global_cluster_identifier: "{{ rds_global_cluster_name }}" | ||
region: "{{ rds_primary_cluster_region }}" | ||
register: global_cluster_info | ||
|
||
- name: Assert that primary and replica cluster are part of global db | ||
ansible.builtin.assert: | ||
that: | ||
- global_cluster_info.global_clusters[0].global_cluster_members[0].db_cluster_arn == primary_cluster_info_result.clusters[0].db_cluster_arn | ||
- global_cluster_info.global_clusters[0].global_cluster_members[1].db_cluster_arn == replica_cluster_info_result.clusters[0].db_cluster_arn |
Oops, something went wrong.