diff options
author | Matt Clay <mclay@redhat.com> | 2020-02-25 23:18:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-25 23:18:50 -0800 |
commit | e3591223a042caa537fcc88cf7553227b8657f70 (patch) | |
tree | 137991b3e16fb757859fcbbeafd93d7d46ef2a7b /test/integration/targets/incidental_aws_codebuild/tasks/main.yml | |
parent | a19ae28326ce861c0eeae803e939050b5bcd64bd (diff) | |
download | ansible-e3591223a042caa537fcc88cf7553227b8657f70.tar.gz |
Second batch of incidental integration tests. (#67765)
* Update incidental test aliases.
* Rewrite target references for renamed targets.
* Add incidental tests to CI.
* Update sanity tests for incidental cloud tests.
* Initial copy of incidental tests.
* Copy contrib files into test.
* Update paths in test.
* Add support plugins.
* Update plugin to work around missing deps.
* Update sanity ignores.
* Fix matrix entries.
* Remove debug echo.
Diffstat (limited to 'test/integration/targets/incidental_aws_codebuild/tasks/main.yml')
-rw-r--r-- | test/integration/targets/incidental_aws_codebuild/tasks/main.yml | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/test/integration/targets/incidental_aws_codebuild/tasks/main.yml b/test/integration/targets/incidental_aws_codebuild/tasks/main.yml new file mode 100644 index 0000000000..953aaeaad8 --- /dev/null +++ b/test/integration/targets/incidental_aws_codebuild/tasks/main.yml @@ -0,0 +1,119 @@ +--- +# tasks file for aws_codebuild + +- name: Run aws_codebuild integration tests. + + block: + + # ==================== preparations ======================================== + + - 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 CodeBuild + iam_role: + name: "{{ iam_role_name }}" + description: Role with permissions for CodeBuild actions. + assume_role_policy_document: "{{ lookup('file', 'codebuild_iam_trust_policy.json') }}" + state: present + <<: *aws_connection_info + register: codebuild_iam_role + + - name: Set variable with aws account id + set_fact: + aws_account_id: "{{ codebuild_iam_role.iam_role.arn.split(':')[4] }}" + + # ================== integration test ========================================== + + - name: create CodeBuild project + aws_codebuild: + name: "{{ resource_prefix }}-test-ansible-codebuild" + description: Build project for testing the Ansible aws_codebuild module + service_role: "{{ codebuild_iam_role.iam_role.arn }}" + timeout_in_minutes: 30 + source: + type: CODEPIPELINE + buildspec: '' + artifacts: + namespace_type: NONE + packaging: NONE + type: CODEPIPELINE + name: test + environment: + compute_type: BUILD_GENERAL1_SMALL + privileged_mode: true + image: 'aws/codebuild/docker:17.09.0' + type: LINUX_CONTAINER + environment_variables: + - { name: 'FOO_ENV', value: 'other' } + tags: + - { key: 'purpose', value: 'ansible-test' } + state: present + <<: *aws_connection_info + register: output + retries: 10 + delay: 5 + until: output is success + + - assert: + that: + - "output.project.description == 'Build project for testing the Ansible aws_codebuild module'" + + - name: idempotence check rerunning same Codebuild task + aws_codebuild: + name: "{{ resource_prefix }}-test-ansible-codebuild" + description: Build project for testing the Ansible aws_codebuild module + service_role: "{{ codebuild_iam_role.iam_role.arn }}" + timeout_in_minutes: 30 + source: + type: CODEPIPELINE + buildspec: '' + artifacts: + namespace_type: NONE + packaging: NONE + type: CODEPIPELINE + name: test + encryption_key: 'arn:aws:kms:{{ aws_region }}:{{ aws_account_id }}:alias/aws/s3' + environment: + compute_type: BUILD_GENERAL1_SMALL + privileged_mode: true + image: 'aws/codebuild/docker:17.09.0' + type: LINUX_CONTAINER + environment_variables: + - { name: 'FOO_ENV', value: 'other' } + tags: + - { key: 'purpose', value: 'ansible-test' } + state: present + <<: *aws_connection_info + register: rerun_test_output + + - assert: + that: + - "rerun_test_output.project.created == output.project.created" + + - name: delete CodeBuild project + aws_codebuild: + name: "{{ output.project.name }}" + source: + type: CODEPIPELINE + buildspec: '' + artifacts: {} + state: absent + <<: *aws_connection_info + async: 300 + + # ============================== cleanup ====================================== + + always: + + - name: cleanup IAM role created for CodeBuild test + iam_role: + name: "{{ iam_role_name }}" + state: absent + <<: *aws_connection_info |