Skip to content

Commit

Permalink
Run the awscli commands on the ansible controller
Browse files Browse the repository at this point in the history
  • Loading branch information
jewnix committed Dec 1, 2023
1 parent 28064e2 commit 7ddf16f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ If all goes well, you should have six new docker images:

#### Pushing to an ECR repository

To use a ECR repository on AWS, set `is_ecr_registry: true` this will call the `aws_tools` role and install the aws cli on the build host, and grab the password for `docker_login` to use.
To use a ECR repository on AWS, set `is_ecr_registry: true` this will call the `aws_tools` role and install the aws cli on the ansible controller, and grab the password for `docker_login` to use.

The following variables need to be set to use a ECR repository:
* ecr_access_key_id
Expand Down
3 changes: 2 additions & 1 deletion roles/aws_tools/tasks/install_awscli.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- name: Install AWS CLI
delegate_to: 127.0.0.1
when: awscli_command_path.rc != 0
block:
- name: Download AWS CLI
Expand All @@ -7,7 +8,7 @@
dest: "{{ awscli_stage_dest }}"
register: downloaded_awscli_archive

- name: Unarchive "{{ awscli_stage_archive.dest }}"
- name: "Unarchive {{ awscli_stage_archive.dest }}"
unarchive:
src: "{{ downloaded_awscli_archive.dest }}"
dest: "{{ awscli_stage_dest }}"
Expand Down
3 changes: 2 additions & 1 deletion roles/aws_tools/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- name: Configure AWS CLI
delegate_to: localhost
block:
- name: Check if AWS CLI is installed
command: "which aws"
Expand All @@ -18,7 +19,7 @@
shell: "{{ awscli_command_path.stdout }} ecr get-login-password"
become: "{{ docker_become_user is defined }}"
become_user: "{{ docker_become_user|default(omit) }}"
delegate_to: "{{ groups['docker_build_hosts'] | first }}"
delegate_to: localhost
run_once: true
no_log: yes
changed_when: no
Expand Down

0 comments on commit 7ddf16f

Please sign in to comment.