mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
158 lines
4.6 KiB
YAML
158 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
|
|
|
|
- name: Pause a few seconds to ensure IAM role is available to next task
|
|
pause:
|
|
seconds: 10
|
|
|
|
# ================== 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
|
|
|
|
- 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
|