Skip to content

Commit

Permalink
fix: adds ssm from docker image (#1139)
Browse files Browse the repository at this point in the history
* fix: adds ssm from docker image directly

* fix: suggestion from review

* fix: disable gpg for aws ssm

* fix: dont run zypper for nonsuse

* fix: adds enable and disable repo
  • Loading branch information
faiq authored Aug 8, 2024
1 parent a236e58 commit 46c805a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 30 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ ARG BUILDARCH
# Packer copies /usr/local/bin/goss-amd64 from this container to the remote host
COPY --from=devkit /usr/local/bin/goss-amd64 /usr/local/bin/goss-amd64

COPY --from=devkit /opt/amazon-ssm-agent.rpm /opt/amazon-ssm-agent.rpm

# we copy this to remote hosts to execute mindthegap so its always amd64
COPY --from=devkit /usr/local/bin/mindthegap /usr/local/bin/
COPY --from=devkit /usr/local/bin/packer-${BUILDARCH} /usr/local/bin/packer
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.devkit
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ RUN curl -L "https://github.com/goss-org/goss/releases/download/${GOSS_VERSION}/
RUN chmod +rx /usr/local/bin/goss-amd64
ARG BUILDARCH
RUN ln -s /usr/local/bin/goss-${BUILDARCH} /usr/local/bin/goss
RUN curl -o /opt/amazon-ssm-agent.rpm https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm

COPY --from=packer-amd64 /bin/packer /usr/local/bin/packer-amd64
COPY --from=packer-arm64 /bin/packer /usr/local/bin/packer-arm64
Expand Down
49 changes: 22 additions & 27 deletions ansible/roles/providers/tasks/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,34 @@
- ansible_distribution != "Amazon"
- ansible_os_family != "Suse"

- name: install aws agents RPM
package:
name: "{{ item }}"
state: present
# must be fixed by amazon https://github.com/aws/amazon-ssm-agent/issues/235
disable_gpg_check: yes
enablerepo: "{{ 'offline' if offline_mode_enabled else '' }}"
disablerepo: "{{ '*' if offline_mode_enabled else '' }}"
with_items:
- "{{ 'amazon-ssm-agent' if offline_mode_enabled else 'https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm' }}"
when:
- ansible_os_family == "RedHat"
- ansible_distribution != "Amazon"

- name: install aws agents RPM
package:
name: "{{ item }}"
state: present
# must be fixed by amazon https://github.com/aws/amazon-ssm-agent/issues/235
disable_gpg_check: yes
with_items:
- https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
when:
- ansible_os_family == "Suse"
- ansible_distribution != "Amazon"
- block:
- name: copy ssm rpm
copy:
src: /opt/amazon-ssm-agent.rpm
dest: /opt/amazon-ssm-agent.rpm

- name: install aws agents RPM
- name: install aws agents RPM
ansible.builtin.yum:
name: /opt/amazon-ssm-agent.rpm
state: present
disable_gpg_check: yes
enablerepo: "{{ 'offline' if offline_mode_enabled else '' }}"
disablerepo: "{{ '*' if offline_mode_enabled else '' }}"
when: ansible_os_family == "RedHat" and ansible_distribution != "Amazon"

- name: install aws agents RPM
ansible.builtin.zypper:
name: /opt/amazon-ssm-agent.rpm
state: present
disable_gpg_check: yes
when: ansible_os_family == "Suse" and ansible_distribution != "Amazon"

- name: install aws cli for amazon linux
package:
name: "{{ item }}"
state: present
with_items:
- amazon-ssm-agent
- awscli
when: ansible_distribution == "Amazon"

Expand All @@ -94,4 +90,3 @@
state: started
enabled: yes
when: ansible_distribution == "Ubuntu"

1 change: 0 additions & 1 deletion bundles/redhat8.6/bundle.sh.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ yumdownloader --setopt=skip_missing_names_on_install=False -x \*i686 --archlist=
$(< packages.txt)

rm packages.txt reqs.txt
curl https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm -o amazon-ssm-agent.rpm
createrepo -v .
repo2module . --module-name offline
createrepo_mod .
Expand Down
1 change: 0 additions & 1 deletion bundles/redhat8.8/bundle.sh.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ yumdownloader --setopt=skip_missing_names_on_install=False -x \*i686 --archlist=
$(< packages.txt)

rm packages.txt reqs.txt
curl https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm -o amazon-ssm-agent.rpm
createrepo -v .
repo2module . --module-name offline
createrepo_mod .
Expand Down
1 change: 0 additions & 1 deletion bundles/rocky9.1/bundle.sh.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ repoquery --archlist=x86_64,noarch --resolve --requires --recursive $(< packag
#shellcheck disable=SC2046
yumdownloader --archlist=x86_64,noarch -x \*i686 $(< packages.txt)
rm packages.txt
curl https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm -o amazon-ssm-agent.rpm
createrepo -v . && chown -R 1000:1000 repodata/
#shellcheck disable=SC1083,SC2035
tar -czf {{ .OutputDirectory }}/{{ .KubernetesVersion }}_rocky_9.1_x86_64.tar.gz *
Expand Down

0 comments on commit 46c805a

Please sign in to comment.