Skip to content

Commit 11d0d9c

Browse files
committed
lifecycle prod test
1 parent 0d58349 commit 11d0d9c

File tree

2 files changed

+39
-50
lines changed

2 files changed

+39
-50
lines changed

ansible/roles/build-ecs-proxies/tasks/build-container.yml

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -31,53 +31,3 @@
3131
ansible.builtin.command:
3232
cmd: "docker push {{ image_name }}"
3333
when: build_result.rc == 0
34-
35-
- name: Get existing lifecycle policy JSON for {{ service_id }}_{{ item }}
36-
ansible.builtin.command: >
37-
{{ aws_cmd }} ecr get-lifecycle-policy
38-
--repository-name {{ service_id }}_{{ item }}
39-
--query 'lifecyclePolicyText'
40-
--output text
41-
register: existing_policy_raw
42-
failed_when: false
43-
changed_when: false
44-
45-
- name: Parse existing lifecycle policy JSON if present
46-
set_fact:
47-
existing_policy_json: "{{ existing_policy_raw.stdout | from_json }}"
48-
when:
49-
- existing_policy_raw.stdout is defined
50-
- existing_policy_raw.stdout != ""
51-
- existing_policy_raw.stdout != "None"
52-
- existing_policy_raw.stdout != "null"
53-
54-
- name: Ensure existing_policy_json always exists
55-
set_fact:
56-
existing_policy_json: {}
57-
when: existing_policy_json is not defined
58-
59-
- name: Read lifecycle policy from the shared file
60-
ansible.builtin.slurp:
61-
src: "{{ playbook_dir }}/ecr-lifecycle/ecr_lifecycle.json"
62-
register: desired_policy_raw
63-
64-
- name: Debug raw slurp output
65-
debug:
66-
var: desired_policy_raw
67-
68-
- name: Show decoded lifecycle policy content
69-
debug:
70-
msg: "{{ desired_policy_raw.content | b64decode }}"
71-
72-
- name: Decode lifecycle policy file
73-
set_fact:
74-
desired_policy_json: "{{ desired_policy_raw.content | b64decode | from_json }}"
75-
76-
- name: Apply lifecycle policy to ecr {{ service_id }}_{{ item }} if different
77-
ansible.builtin.command: >
78-
{{ aws_cmd }} ecr put-lifecycle-policy
79-
--repository-name {{ service_id }}_{{ item }}
80-
--lifecycle-policy-text '{{ desired_policy_json | to_json }}'
81-
when:
82-
- existing_policy_json != desired_policy_json
83-

ansible/roles/build-ecs-proxies/tasks/main.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,45 @@
3030
with_items: "{{ new_repos }}"
3131
when: new_repos
3232

33+
# TEST REPO (override this for testing) - DELETE
34+
35+
- set_fact:
36+
test_repo: "canary_canary-api"
37+
38+
- name: Read lifecycle policy file
39+
ansible.builtin.slurp:
40+
src: "{{ playbook_dir }}/ecr-lifecycle/ecr_lifecycle.json"
41+
register: desired_policy_raw
42+
# when: new_repos # Uncomment
43+
44+
- name: Debug raw slurp output
45+
debug:
46+
var: desired_policy_raw
47+
48+
- name: Decode lifecycle policy JSON
49+
set_fact:
50+
desired_policy_json: "{{ desired_policy_raw.content | b64decode | from_json }}"
51+
# when: new_repos # Uncomment
52+
53+
- name: Debug decoded lifecycle policy JSON
54+
debug:
55+
var: desired_policy_json
56+
57+
- name: Apply lifecycle policy to ECR repo
58+
ansible.builtin.command: >
59+
{{ aws_cmd }} ecr put-lifecycle-policy
60+
--repository-name {{ test_repo }}
61+
--lifecycle-policy-text '{{ desired_policy_json | to_json }}'
62+
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
71+
3372
- name: ecr login
3473
shell: "eval $({{ aws_cmd }} ecr get-login --no-include-email)"
3574
changed_when: no

0 commit comments

Comments
 (0)