9ee0deea24
- Add retries instead of a pause task - Shorten the IAM role name length - Put the IAM role name in defaults/main.yml instead - Fix the aws_codepipeline tests too
156 lines
4.6 KiB
YAML
156 lines
4.6 KiB
YAML
---
|
|
# tasks file for aws_codepipeline
|
|
|
|
- name: Run aws_codebuild module integration tests
|
|
|
|
block:
|
|
|
|
# ==================== preparaions ========================================
|
|
|
|
- name: set connection information for all tasks
|
|
set_fact:
|
|
aws_connection_info: &aws_connection_info
|
|
aws_access_key: "{{ aws_access_key }}"
|
|
aws_secret_key: "{{ aws_secret_key }}"
|
|
security_token: "{{ security_token }}"
|
|
region: "{{ aws_region }}"
|
|
no_log: yes
|
|
|
|
- name: create IAM role needed for CodePipeline test
|
|
iam_role:
|
|
name: "{{ codepipeline_service_role_name }}"
|
|
description: Role with permissions for CodePipeline actions.
|
|
assume_role_policy_document: "{{ lookup('file', 'codepipeline_iam_trust_policy.json') }}"
|
|
state: present
|
|
<<: *aws_connection_info
|
|
register: codepipeline_iam_role
|
|
|
|
# ================== integration test ==========================================
|
|
|
|
- name: create CodePipeline
|
|
aws_codepipeline:
|
|
name: "{{ codepipeline_name }}"
|
|
role_arn: "{{ codepipeline_iam_role.iam_role.arn }}"
|
|
artifact_store:
|
|
type: S3
|
|
location: foo
|
|
stages:
|
|
- name: step_1
|
|
actions:
|
|
- name: action
|
|
actionTypeId:
|
|
category: Source
|
|
owner: AWS
|
|
provider: S3
|
|
version: '1'
|
|
configuration:
|
|
S3Bucket: foo
|
|
S3ObjectKey: bar
|
|
outputArtifacts:
|
|
- { name: step_one_output }
|
|
- name: step_2
|
|
actions:
|
|
- name: action
|
|
actionTypeId:
|
|
category: Build
|
|
owner: AWS
|
|
provider: CodeBuild
|
|
version: '1'
|
|
inputArtifacts:
|
|
- { name: step_one_output }
|
|
outputArtifacts:
|
|
- { name: step_two_output }
|
|
configuration:
|
|
ProjectName: foo
|
|
state: present
|
|
<<: *aws_connection_info
|
|
register: output
|
|
retries: 10
|
|
delay: 5
|
|
until: output is success
|
|
|
|
- assert:
|
|
that:
|
|
- output.changed == True
|
|
- output.pipeline.name == "{{ codepipeline_name }}"
|
|
- output.pipeline.stages|length > 1
|
|
|
|
- name: idempotence check rerunning same CodePipeline task
|
|
aws_codepipeline:
|
|
name: "{{ codepipeline_name }}"
|
|
role_arn: "{{ codepipeline_iam_role.iam_role.arn }}"
|
|
artifact_store:
|
|
type: S3
|
|
location: foo
|
|
stages:
|
|
- name: step_1
|
|
actions:
|
|
- name: action
|
|
actionTypeId:
|
|
category: Source
|
|
owner: AWS
|
|
provider: S3
|
|
version: '1'
|
|
configuration:
|
|
S3Bucket: foo
|
|
S3ObjectKey: bar
|
|
outputArtifacts:
|
|
- { name: step_one_output }
|
|
- name: step_2
|
|
actions:
|
|
- name: action
|
|
actionTypeId:
|
|
category: Build
|
|
owner: AWS
|
|
provider: CodeBuild
|
|
version: '1'
|
|
inputArtifacts:
|
|
- { name: step_one_output }
|
|
outputArtifacts:
|
|
- { name: step_two_output }
|
|
configuration:
|
|
ProjectName: foo
|
|
state: present
|
|
<<: *aws_connection_info
|
|
register: rerun_test_output
|
|
|
|
- assert:
|
|
that:
|
|
- rerun_test_output.changed == False
|
|
- rerun_test_output.pipeline == output.pipeline
|
|
|
|
- name: Test deletion of CodePipeline
|
|
aws_codepipeline:
|
|
name: "{{ codepipeline_name }}"
|
|
role_arn: ''
|
|
artifact_store: {}
|
|
stages: []
|
|
state: absent
|
|
<<: *aws_connection_info
|
|
register: absent_test_output
|
|
|
|
- assert:
|
|
that:
|
|
- absent_test_output.changed == True
|
|
- absent_test_output.pipeline is undefined
|
|
|
|
# ==================== cleanup =======================
|
|
|
|
always:
|
|
|
|
- name: Cleanup - delete test CodePipeline
|
|
aws_codepipeline:
|
|
name: "{{ codepipeline_name }}"
|
|
role_arn: ''
|
|
artifact_store: {}
|
|
stages: []
|
|
state: absent
|
|
<<: *aws_connection_info
|
|
ignore_errors: true
|
|
|
|
- name: Cleanup - delete IAM role needed for CodePipeline test
|
|
iam_role:
|
|
name: "{{ codepipeline_name }}"
|
|
state: absent
|
|
<<: *aws_connection_info
|
|
ignore_errors: true
|