| 1 |
--- |
| 2 |
- module_defaults: |
| 3 |
group/aws: |
| 4 |
access_key: "{{ aws_access_key }}" |
| 5 |
secret_key: "{{ aws_secret_key }}" |
| 6 |
session_token: "{{ security_token | default(omit) }}" |
| 7 |
region: "{{ aws_region }}" |
| 8 |
block: |
| 9 |
# ============================================================ |
| 10 |
- name: Create a repository (CHECK MODE) |
| 11 |
codecommit_repository: |
| 12 |
name: "{{ resource_prefix }}_repo" |
| 13 |
description: original comment |
| 14 |
state: present |
| 15 |
register: output |
| 16 |
check_mode: yes |
| 17 |
- assert: |
| 18 |
that: |
| 19 |
- output is changed |
| 20 |
|
| 21 |
- name: Create a repository |
| 22 |
codecommit_repository: |
| 23 |
name: "{{ resource_prefix }}_repo" |
| 24 |
description: original comment |
| 25 |
state: present |
| 26 |
register: output |
| 27 |
- assert: |
| 28 |
that: |
| 29 |
- output is changed |
| 30 |
- output.repository_metadata.repository_name == resource_prefix ~ '_repo' |
| 31 |
- output.repository_metadata.repository_description == 'original comment' |
| 32 |
|
| 33 |
- name: No-op update to repository |
| 34 |
codecommit_repository: |
| 35 |
name: "{{ resource_prefix }}_repo" |
| 36 |
description: original comment |
| 37 |
state: present |
| 38 |
register: output |
| 39 |
- assert: |
| 40 |
that: |
| 41 |
- output is not changed |
| 42 |
- output.repository_metadata.repository_name == resource_prefix ~ '_repo' |
| 43 |
- output.repository_metadata.repository_description == 'original comment' |
| 44 |
|
| 45 |
- name: Update repository description (CHECK MODE) |
| 46 |
codecommit_repository: |
| 47 |
name: "{{ resource_prefix }}_repo" |
| 48 |
description: new comment |
| 49 |
state: present |
| 50 |
register: output |
| 51 |
check_mode: yes |
| 52 |
- assert: |
| 53 |
that: |
| 54 |
- output is changed |
| 55 |
- output.repository_metadata.repository_name == resource_prefix ~ '_repo' |
| 56 |
- output.repository_metadata.repository_description == 'original comment' |
| 57 |
|
| 58 |
- name: Update repository description |
| 59 |
codecommit_repository: |
| 60 |
name: "{{ resource_prefix }}_repo" |
| 61 |
description: new comment |
| 62 |
state: present |
| 63 |
register: output |
| 64 |
- assert: |
| 65 |
that: |
| 66 |
- output is changed |
| 67 |
- output.repository_metadata.repository_name == resource_prefix ~ '_repo' |
| 68 |
- output.repository_metadata.repository_description == 'new comment' |
| 69 |
|
| 70 |
# ============================================================ |
| 71 |
- name: Delete a repository (CHECK MODE) |
| 72 |
codecommit_repository: |
| 73 |
name: "{{ resource_prefix }}_repo" |
| 74 |
state: absent |
| 75 |
register: output |
| 76 |
check_mode: yes |
| 77 |
- assert: |
| 78 |
that: |
| 79 |
- output is changed |
| 80 |
|
| 81 |
- name: Delete a repository |
| 82 |
codecommit_repository: |
| 83 |
name: "{{ resource_prefix }}_repo" |
| 84 |
state: absent |
| 85 |
register: output |
| 86 |
- assert: |
| 87 |
that: |
| 88 |
- output is changed |
| 89 |
|
| 90 |
- name: Delete a non-existent repository |
| 91 |
codecommit_repository: |
| 92 |
name: "{{ resource_prefix }}_repo" |
| 93 |
state: absent |
| 94 |
register: output |
| 95 |
- assert: |
| 96 |
that: |
| 97 |
- output is not changed |
| 98 |
|
| 99 |
- name: Create a repository without description |
| 100 |
codecommit_repository: |
| 101 |
name: "{{ resource_prefix }}_repo" |
| 102 |
state: present |
| 103 |
register: output |
| 104 |
- assert: |
| 105 |
that: |
| 106 |
- output is changed |
| 107 |
- output.repository_metadata.repository_name == resource_prefix ~ '_repo' |
| 108 |
|
| 109 |
- name: No-op update to repository without description |
| 110 |
codecommit_repository: |
| 111 |
name: "{{ resource_prefix }}_repo" |
| 112 |
state: present |
| 113 |
register: output |
| 114 |
- assert: |
| 115 |
that: |
| 116 |
- output is not changed |
| 117 |
- output.repository_metadata.repository_name == resource_prefix ~ '_repo' |
| 118 |
|
| 119 |
- name: Delete a repository without description |
| 120 |
codecommit_repository: |
| 121 |
name: "{{ resource_prefix }}_repo" |
| 122 |
state: absent |
| 123 |
register: output |
| 124 |
- assert: |
| 125 |
that: |
| 126 |
- output is changed |
| 127 |
|
| 128 |
always: |
| 129 |
###### TEARDOWN STARTS HERE ###### |
| 130 |
- name: Delete a repository |
| 131 |
codecommit_repository: |
| 132 |
name: "{{ resource_prefix }}_repo" |
| 133 |
state: absent |
| 134 |
ignore_errors: yes |