-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add codedeploy_deployment_group module
- Loading branch information
Showing
11 changed files
with
1,344 additions
and
0 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
cloud/aws |
2 changes: 2 additions & 0 deletions
2
tests/integration/targets/codedeploy_deployment_group/defaults/main.yml
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,2 @@ | ||
--- | ||
codedeploy_service_role_name: "ansible-test-{{ tiny_prefix | truncate(6, True, '') }}-codedeploy-role" |
13 changes: 13 additions & 0 deletions
13
tests/integration/targets/codedeploy_deployment_group/files/codedeploy_iam_trust_policy.json
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,13 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "codedeploy.amazonaws.com" | ||
}, | ||
"Action": "sts:AssumeRole" | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/codedeploy_deployment_group/meta/main.yml
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 @@ | ||
dependencies: [] |
29 changes: 29 additions & 0 deletions
29
tests/integration/targets/codedeploy_deployment_group/tasks/01_create_requirements.yml
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,29 @@ | ||
- name: create IAM role needed for CodeDeploy deploy | ||
iam_role: | ||
name: "{{ codedeploy_service_role_name }}" | ||
description: Role with permissions for CodePipeline actions. | ||
assume_role_policy_document: "{{ lookup('file', 'codedeploy_iam_trust_policy.json') }}" | ||
create_instance_profile: no | ||
managed_policies: | ||
- 'AWSCodeDeployRole' | ||
state: present | ||
wait: True | ||
register: codedeploy_service_role | ||
|
||
- name: wait for 15 seconds # IAM policy takes time to propagate | ||
pause: | ||
seconds: 15 | ||
|
||
- name: create codedeploy_application - Server | ||
codedeploy_application: | ||
application_name: "{{ resource_prefix }}_app_server" | ||
compute_platform: Server | ||
state: present | ||
register: codedeploy_application_server | ||
|
||
- name: create codedeploy_application - Lambda | ||
codedeploy_application: | ||
application_name: "{{ resource_prefix }}_app_lambda" | ||
compute_platform: Lambda | ||
state: present | ||
register: codedeploy_application_lambda |
235 changes: 235 additions & 0 deletions
235
tests/integration/targets/codedeploy_deployment_group/tasks/10_dg_servers.yml
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,235 @@ | ||
- name: Create deployment group - Server, No Options (CHECK_MODE) | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_server.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_server_no_options" | ||
service_role: "{{ codedeploy_service_role.iam_role.arn }}" | ||
state: present | ||
check_mode: true | ||
register: codedeploy_deployment_group_server | ||
|
||
- name: check that deployment group was correctly created | ||
assert: | ||
that: | ||
- codedeploy_deployment_group_server.changed | ||
|
||
- name: Create deployment group - Server, No Options | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_server.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_server_no_options" | ||
service_role: "{{ codedeploy_service_role.iam_role.arn }}" | ||
state: present | ||
|
||
- name: Create deployment group - tag sets | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_server.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_server_all_options" | ||
service_role: "{{ codedeploy_service_role.iam_role.arn }}" | ||
deployment_config_name: CodeDeployDefault.HalfAtATime | ||
alarm_configuration: | ||
enabled: True | ||
ignore_poll_alarm_failure: True | ||
alarm_names: | ||
- "{{ tiny_prefix }}_test_alarm_1" | ||
- "{{ tiny_prefix }}_test_alarm_2" | ||
outdated_instances_strategy: IGNORE | ||
deployment_style: | ||
deployment_type: IN_PLACE | ||
deployment_option: WITHOUT_TRAFFIC_CONTROL | ||
auto_rollback_configuration: | ||
enabled: True | ||
events: | ||
- DEPLOYMENT_STOP_ON_ALARM | ||
- DEPLOYMENT_STOP_ON_REQUEST | ||
ec2_tag_set: | ||
ec2_tag_set_list: | ||
- ec2_tag: | ||
- key: Name | ||
value: "{{ tiny_prefix }}_ec2_instance_tagset_1" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_test" | ||
type: KEY_AND_VALUE | ||
- ec2_tag: | ||
- key: Name | ||
value: "{{ tiny_prefix }}_ec2_instance_tagset_2" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_test" | ||
type: KEY_AND_VALUE | ||
on_premises_tag_set: | ||
on_premises_tag_set_list: | ||
- on_premises_tag: | ||
- key: Name | ||
value: "{{ tiny_prefix }}_instance_tagset_1" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_test" | ||
type: KEY_AND_VALUE | ||
- on_premises_tag: | ||
- key: Name | ||
value: "{{ tiny_prefix }}_instance_tagset_2" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_test" | ||
type: KEY_AND_VALUE | ||
state: present | ||
register: codedeploy_deployment_group_server | ||
|
||
- name: check that deployment group was correctly created | ||
assert: | ||
that: | ||
- codedeploy_deployment_group_server.changed | ||
- codedeploy_deployment_group_server.deployment_group is defined | ||
- codedeploy_deployment_group_server.deployment_group.deployment_group_name == "{{ tiny_prefix }}_dg_server_all_options" | ||
|
||
- name: update deployment group - tag sets (CHECK_MODE) | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_server.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_server_all_options" | ||
new_deployment_group_name: "{{ tiny_prefix }}_dg_server_all_options_updated" # change deployment group name | ||
service_role: "{{ codedeploy_service_role.iam_role.arn }}" | ||
deployment_config_name: CodeDeployDefault.AllAtOnce # change deployment config | ||
alarm_configuration: | ||
enabled: True | ||
ignore_poll_alarm_failure: True | ||
alarm_names: | ||
- "{{ tiny_prefix }}_test_alarm_1" | ||
- "{{ tiny_prefix }}_test_alarm_2" | ||
outdated_instances_strategy: IGNORE | ||
deployment_style: | ||
deployment_type: IN_PLACE | ||
deployment_option: WITHOUT_TRAFFIC_CONTROL | ||
auto_rollback_configuration: | ||
enabled: True | ||
events: | ||
- DEPLOYMENT_STOP_ON_ALARM | ||
- DEPLOYMENT_FAILURE | ||
ec2_tag_set: | ||
ec2_tag_set_list: | ||
- ec2_tag: # change ec2 tag set | ||
- key: Name | ||
value: "{{ tiny_prefix }}_ec2_instance_tagset_1_updated" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_new_test_updated" | ||
type: KEY_AND_VALUE | ||
- ec2_tag: | ||
- key: Name | ||
value: "{{ tiny_prefix }}_ec2_instance_new_tagset_2_updated" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_new_test_updated" | ||
type: KEY_AND_VALUE | ||
on_premises_tag_set: | ||
on_premises_tag_set_list: | ||
- on_premises_tag: | ||
- key: Name | ||
value: "{{ tiny_prefix }}_instance_tagset_1_updated" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_test_updated" | ||
type: KEY_AND_VALUE | ||
- on_premises_tag: | ||
- key: Name | ||
value: "{{ tiny_prefix }}_instance_tagset_2_updated" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_test_updated" | ||
type: KEY_AND_VALUE | ||
state: present | ||
check_mode: true | ||
register: codedeploy_deployment_group_server | ||
|
||
- name: check that deployment group was correctly updated | ||
assert: | ||
that: | ||
- codedeploy_deployment_group_server.changed | ||
- codedeploy_deployment_group_server.deployment_group is defined | ||
- codedeploy_deployment_group_server.deployment_group.deployment_group_name == "{{ tiny_prefix }}_dg_server_all_options" | ||
|
||
- name: update deployment group - tag sets | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_server.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_server_all_options" | ||
new_deployment_group_name: "{{ tiny_prefix }}_dg_server_all_options_updated" # change deployment group name | ||
service_role: "{{ codedeploy_service_role.iam_role.arn }}" | ||
deployment_config_name: CodeDeployDefault.AllAtOnce # change deployment config | ||
alarm_configuration: | ||
enabled: True | ||
ignore_poll_alarm_failure: True | ||
alarm_names: | ||
- "{{ tiny_prefix }}_test_alarm_1" | ||
- "{{ tiny_prefix }}_test_alarm_2" | ||
outdated_instances_strategy: IGNORE | ||
deployment_style: | ||
deployment_type: IN_PLACE | ||
deployment_option: WITHOUT_TRAFFIC_CONTROL | ||
auto_rollback_configuration: | ||
enabled: True | ||
events: | ||
- DEPLOYMENT_STOP_ON_ALARM | ||
- DEPLOYMENT_FAILURE | ||
ec2_tag_set: | ||
ec2_tag_set_list: | ||
- ec2_tag: # change ec2 tag set | ||
- key: Name | ||
value: "{{ tiny_prefix }}_ec2_instance_tagset_1_updated" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_new_test_updated" | ||
type: KEY_AND_VALUE | ||
- ec2_tag: | ||
- key: Name | ||
value: "{{ tiny_prefix }}_ec2_instance_new_tagset_2_updated" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_new_test_updated" | ||
type: KEY_AND_VALUE | ||
on_premises_tag_set: | ||
on_premises_tag_set_list: | ||
- on_premises_tag: | ||
- key: Name | ||
value: "{{ tiny_prefix }}_instance_tagset_1_updated" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_test_updated" | ||
type: KEY_AND_VALUE | ||
- on_premises_tag: | ||
- key: Name | ||
value: "{{ tiny_prefix }}_instance_tagset_2_updated" | ||
type: KEY_AND_VALUE | ||
- key: Env | ||
value: "{{ tiny_prefix }}_ansible_test_updated" | ||
type: KEY_AND_VALUE | ||
state: present | ||
register: codedeploy_deployment_group_server | ||
|
||
- name: check that deployment group was correctly updated | ||
assert: | ||
that: | ||
- codedeploy_deployment_group_server.changed | ||
- codedeploy_deployment_group_server.deployment_group is defined | ||
- codedeploy_deployment_group_server.deployment_group.deployment_group_name == "{{ tiny_prefix }}_dg_server_all_options_updated" | ||
- codedeploy_deployment_group_server.deployment_group.deployment_config_name == "CodeDeployDefault.AllAtOnce" | ||
|
||
|
||
- name: delete deployment group - tag sets (CHECK_MODE) | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_server.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_server_all_options_updated" | ||
service_role: "{{ codedeploy_service_role.iam_role.arn }}" | ||
state: absent | ||
check_mode: true | ||
register: codedeploy_deployment_group_server | ||
|
||
- name: check that deployment group was correctly deleted | ||
assert: | ||
that: | ||
- codedeploy_deployment_group_server.changed | ||
|
||
- name: delete deployment group - tag sets | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_server.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_server_all_options_updated" | ||
state: absent | ||
register: codedeploy_deployment_group_server |
92 changes: 92 additions & 0 deletions
92
tests/integration/targets/codedeploy_deployment_group/tasks/20_dg_lambda.yml
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,92 @@ | ||
- name: Create deployment group - Lambda, no options(Check mode) | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_lambda.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_lambda_no_options" | ||
service_role: "{{ codedeploy_service_role.iam_role.arn }}" | ||
state: present | ||
check_mode: true | ||
register: codedeploy_deployment_group_lambda | ||
|
||
- name: check that deployment group was correctly created | ||
assert: | ||
that: | ||
- codedeploy_deployment_group_lambda.changed | ||
|
||
- name: Create deployment group - Lambda, no options | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_lambda.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_lambda_no_options" | ||
service_role: "{{ codedeploy_service_role.iam_role.arn }}" | ||
deployment_style: | ||
deployment_type: BLUE_GREEN | ||
deployment_option: WITH_TRAFFIC_CONTROL | ||
state: present | ||
register: codedeploy_deployment_group_lambda | ||
|
||
- name: Create deployment group - Lambda, all options | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_lambda.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_lambda_all_options" | ||
service_role: "{{ codedeploy_service_role.iam_role.arn }}" | ||
deployment_config_name: CodeDeployDefault.LambdaCanary10Percent30Minutes | ||
alarm_configuration: | ||
enabled: True | ||
ignore_poll_alarm_failure: True | ||
alarm_names: | ||
- "{{ tiny_prefix }}_test_alarm_1" | ||
- "{{ tiny_prefix }}_test_alarm_2" | ||
auto_rollback_configuration: | ||
enabled: True | ||
events: | ||
- DEPLOYMENT_STOP_ON_ALARM | ||
deployment_style: | ||
deployment_type: BLUE_GREEN | ||
deployment_option: WITH_TRAFFIC_CONTROL | ||
state: present | ||
register: codedeploy_deployment_group_lambda | ||
|
||
- name: check that deployment group was correctly created | ||
assert: | ||
that: | ||
- codedeploy_deployment_group_lambda.changed | ||
- codedeploy_deployment_group_lambda.deployment_group is defined | ||
- codedeploy_deployment_group_lambda.deployment_group.deployment_group_name == "{{ tiny_prefix }}_dg_lambda_all_options" | ||
|
||
- name: Update deployment group - Lambda, all options | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_lambda.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_lambda_all_options" | ||
new_deployment_group_name: "{{ tiny_prefix }}_dg_lambda_all_options_updated" | ||
deployment_config_name: CodeDeployDefault.LambdaLinear10PercentEvery1Minute | ||
alarm_configuration: | ||
enabled: True | ||
ignore_poll_alarm_failure: True | ||
alarm_names: | ||
- "{{ tiny_prefix }}_test_alarm_1_updated" | ||
- "{{ tiny_prefix }}_test_alarm_2_updated" | ||
auto_rollback_configuration: | ||
enabled: True | ||
events: | ||
- DEPLOYMENT_STOP_ON_ALARM | ||
- DEPLOYMENT_FAILURE | ||
deployment_style: | ||
deployment_type: BLUE_GREEN | ||
deployment_option: WITH_TRAFFIC_CONTROL | ||
state: present | ||
register: codedeploy_deployment_group_lambda | ||
|
||
|
||
- name: check that deployment group was correctly updated | ||
assert: | ||
that: | ||
- codedeploy_deployment_group_lambda.changed | ||
- codedeploy_deployment_group_lambda.deployment_group is defined | ||
- codedeploy_deployment_group_lambda.deployment_group.deployment_group_name == "{{ tiny_prefix }}_dg_lambda_all_options_updated" | ||
- codedeploy_deployment_group_lambda.deployment_group.deployment_config_name == "CodeDeployDefault.LambdaLinear10PercentEvery1Minute" | ||
|
||
- name: delete deployment group - Lambda | ||
codedeploy_deployment_group: | ||
application_name: "{{ codedeploy_application_lambda.application.application_name }}" | ||
deployment_group_name: "{{ tiny_prefix }}_dg_lambda_all_options_updated" | ||
state: absent | ||
register: codedeploy_deployment_group_lambda |
Oops, something went wrong.