|
30 | 30 | with_items: "{{ new_repos }}" |
31 | 31 | when: new_repos |
32 | 32 |
|
33 | | -# TEST REPO (override this for testing) - DELETE |
34 | | - |
35 | | -- set_fact: |
36 | | - test_repo: "canary_canary-api" |
37 | | - |
38 | 33 | - name: Read lifecycle policy file |
39 | 34 | ansible.builtin.slurp: |
40 | 35 | src: "{{ playbook_dir }}/ecr-lifecycle/ecr_lifecycle.json" |
41 | 36 | register: desired_policy_raw |
42 | | - # when: new_repos # Uncomment |
43 | | - |
44 | | -- name: Debug raw slurp output |
45 | | - debug: |
46 | | - var: desired_policy_raw |
| 37 | + # when: new_repos UNCOMMENT |
47 | 38 |
|
48 | 39 | - name: Decode lifecycle policy JSON |
49 | 40 | set_fact: |
50 | 41 | desired_policy_json: "{{ desired_policy_raw.content | b64decode | from_json }}" |
51 | | - # when: new_repos # Uncomment |
| 42 | + # when: new_repos UNCOMMENT |
52 | 43 |
|
53 | | -- name: Debug decoded lifecycle policy JSON |
54 | | - debug: |
55 | | - var: desired_policy_json |
56 | | - |
57 | | -- name: Apply lifecycle policy to ECR repo |
| 44 | +- name: Apply lifecycle policy to each new repo |
58 | 45 | ansible.builtin.command: > |
59 | 46 | {{ aws_cmd }} ecr put-lifecycle-policy |
60 | | - --repository-name {{ test_repo }} |
| 47 | + --repository-name {{ item }} |
61 | 48 | --lifecycle-policy-text '{{ desired_policy_json | to_json }}' |
| 49 | + with_items: "{{ new_repos }}" |
62 | 50 | register: lifecycle_update |
63 | | - # ignore_errors: yes |
64 | | - # with_items: "{{ new_repos }}" # Uncomment |
65 | | - # when: |
66 | | - # - new_repos # Uncomment |
67 | | - |
68 | | -- name: Debug lifecycle update result |
69 | | - debug: |
70 | | - var: lifecycle_update |
| 51 | + ignore_errors: yes |
| 52 | + # when: new_repos UNCOMMENT |
71 | 53 |
|
72 | 54 | - name: ecr login |
73 | 55 | shell: "eval $({{ aws_cmd }} ecr get-login --no-include-email)" |
|
0 commit comments