Skip to content

Commit 3c36dbc

Browse files
committed
ansible updates ecs
1 parent 8af5928 commit 3c36dbc

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

ansible/deploy-ecs-proxies-retag.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
connection: local
44
gather_facts: no
55

6+
7+
vars:
8+
service_id: "{{ lookup('env','service_id') }}"
9+
aws_profile: "build-{{ service_id | lower }}"
10+
611
pre_tasks:
712
- name: include container vars
813
include_vars:

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,19 @@
3434
ansible.builtin.slurp:
3535
src: "{{ playbook_dir }}/ecr-lifecycle/ecr_lifecycle.json"
3636
register: desired_policy_raw
37-
# when: new_repos UNCOMMENT
37+
when: new_repos
3838

3939
- name: Decode lifecycle policy JSON
4040
set_fact:
4141
desired_policy_json: "{{ desired_policy_raw.content | b64decode | from_json }}"
42-
# when: new_repos UNCOMMENT
42+
when: new_repos
4343

4444
- name: Apply lifecycle policy to each new repo
4545
ansible.builtin.command: >
4646
{{ aws_cmd }} ecr put-lifecycle-policy
4747
--repository-name {{ item }}
4848
--lifecycle-policy-text '{{ desired_policy_json | to_json }}'
49-
50-
# ORIGINAL (commented out for testing)
51-
# with_items: "{{ new_repos }}"
52-
53-
# TEST: apply to a specific existing repo
54-
with_items:
55-
- canary_canary-api
56-
49+
with_items: "{{ new_repos }}"
5750
register: lifecycle_update
5851
ignore_errors: yes
5952

ansible/roles/deploy-ecs-proxies-retag/tasks/main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1+
- name: Debug pulling image
2+
debug:
3+
msg: "Pulling {{ ecr_registry }}/{{ item }}:{{ build_label }}"
4+
with_items: "{{ repo_names }}"
5+
16
- name: Pull existing image {{ item }}:{{ build_label }}
27
ansible.builtin.command:
38
cmd: >
49
docker pull {{ ecr_registry }}/{{ item }}:{{ build_label }}
510
with_items: "{{ repo_names }}"
611
register: pull_results
712

13+
- name: Debug retagging image
14+
debug:
15+
msg: "Retagging {{ item.item }}:{{ build_label }} → ecs-{{ build_label }}"
16+
with_items: "{{ pull_results.results }}"
17+
when: item.rc == 0
18+
819
- name: Retag image {{ item.item }}:{{ build_label }} → ecs-{{ build_label }}
920
ansible.builtin.command:
1021
cmd: >
@@ -14,6 +25,12 @@
1425
with_items: "{{ pull_results.results }}"
1526
when: item.rc == 0
1627

28+
- name: Debug pushing image
29+
debug:
30+
msg: "Pushing ecs-{{ build_label }} for {{ item.item }}"
31+
with_items: "{{ pull_results.results }}"
32+
when: item.rc == 0
33+
1734
- name: Push new tag ecs-{{ build_label }} for {{ item.item }}
1835
ansible.builtin.command:
1936
cmd: >

0 commit comments

Comments
 (0)