Skip to content

Commit 3ad773b

Browse files
committed
Add Amazon
1 parent fdd06a4 commit 3ad773b

File tree

2 files changed

+102
-1
lines changed

2 files changed

+102
-1
lines changed

docker/amazon/Dockerfile

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# This Dockerfile enables an iterative development workflow where you can make
2+
# a change and test it out quickly. The majority of commands in this file will
3+
# be cached, making the feedback loop typically quite short. The workflow is
4+
# as follows:
5+
# 1. Set up pre-conditions for the system in puppet code using `deploy.pp`.
6+
# 2. Make a change to the module.
7+
# 3. Run `docker build -f docker/Dockerfile .` or
8+
# `./docker/bin/upgrade.sh rocky` from the project directory. If you would
9+
# like to test specific version upgrades, you can add run this like so:
10+
# `docker build -f docker/rocky/Dockerfile . \
11+
# -t pa-dev:rocky --build-arg before=1.10.14`
12+
# 4. Upgrade the container by running the image:
13+
# `docker run -it pa-dev:rocky`
14+
# Specify your upgrade TO version as an argument to the `docker run`
15+
# command.
16+
# 5. Review the output. Repeat steps 2-5 as needed.
17+
#
18+
# At the end of execution, you will see a line like:
19+
#
20+
# Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '1.10.14-1.el8' to '6.2.0'
21+
#
22+
# This specifies the versions that were used for upgrade.
23+
#
24+
# Arguments:
25+
# - before: The version to do upgrade FROM. Default: "7.34.0"
26+
27+
FROM amazonlinux:2023
28+
29+
# Use this to force a cache reset (e.g. for output purposes)
30+
#COPY $0 /tmp/Dockerfile
31+
32+
# Install some other dependencies for ease of life.
33+
RUN dnf update -y \
34+
&& dnf install -y git \
35+
&& dnf clean all
36+
37+
ARG before=7.34.0
38+
LABEL before=${before}
39+
40+
# Install proper FROM repo pupet 7
41+
RUN if [[ ${before} == 7.* ]]; then \
42+
echo Installing puppet7 repo; \
43+
rpm -Uvh https://yum.puppet.com/puppet7-release-amazon-2023.noarch.rpm; \
44+
else echo no; \
45+
fi
46+
47+
# Print out which versions of the puppet-agent package are available (for reference).
48+
#RUN dnf list puppet-agent --showduplicates
49+
50+
# Install FROM version of puppet-agent.
51+
RUN dnf -y update && \
52+
dnf install -y puppet-agent-${before} && \
53+
dnf clean all
54+
55+
# This is also duplicated in the docker/bin/helpers/run-upgrade.sh.
56+
ENV module_path=/tmp/modules
57+
WORKDIR "${module_path}/puppet_agent"
58+
COPY metadata.json ./
59+
60+
# Dependency installation: Forge or source? The former is what the user will
61+
# have downloaded, but the latter allows testing of version bumps.
62+
# Install module dependencies from the Forge using Puppet Module Tool (PMT).
63+
RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-stdlib
64+
RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-inifile
65+
RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-apt
66+
RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-facts
67+
68+
# Installing dependencies from source. These versions should be within the range
69+
# of `dependencies` in metadata.json.
70+
#RUN git clone https://github.com/puppetlabs/puppetlabs-stdlib ../stdlib --branch 9.7.0
71+
#RUN git clone https://github.com/puppetlabs/puppetlabs-inifile ../inifile --branch 6.2.0
72+
#RUN git clone https://github.com/puppetlabs/puppetlabs-apt ../apt --branch 10.0.1
73+
#RUN git clone https://github.com/puppetlabs/puppetlabs-facts ../facts --branch 1.7.0
74+
75+
# Check that all dependencies are installed.
76+
RUN /opt/puppetlabs/puppet/bin/puppet module --modulepath $module_path list --tree
77+
COPY docker/deploy.pp /tmp/deploy.pp
78+
RUN ["sh", "-c", "/opt/puppetlabs/puppet/bin/puppet apply --modulepath $module_path /tmp/deploy.pp"]
79+
80+
# Now move the project directory's files into the image. That way, if these
81+
# files change, caching will skip everything before this.
82+
COPY docker/bin/helpers/run-upgrade.sh /tmp/bin/run-upgrade.sh
83+
COPY files/ ./files/
84+
COPY locales/ ./locales/
85+
COPY spec/ ./spec/
86+
COPY task_spec/ ./task_spec/
87+
COPY tasks/ ./tasks/
88+
COPY templates/ ./templates
89+
COPY types/ ./types/
90+
COPY Gemfile Gemfile.lock Rakefile ./
91+
COPY lib/ ./lib/
92+
COPY manifests/ ./manifests/
93+
94+
COPY docker/upgrade.pp /tmp/upgrade.pp
95+
96+
# Print out which versions of the puppet-agent package are available (for reference).
97+
#RUN yum list puppet-agent --showduplicates
98+
99+
# Perform the upgrade.
100+
ENTRYPOINT ["/tmp/bin/run-upgrade.sh"]

docker/bin/upgrade.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
# Parameters:
88
# - PLATFORM: The platform on which the upgrade should occur. This also
99
# supports comma-separated lists. Available:
10-
# - `ubuntu`
10+
# - `amazon`
1111
# - `fedora`
1212
# - `rocky`
13+
# - `ubuntu`
1314
# Default: `ubuntu`
1415
# - BEFORE: The puppet-agent package version that is installed prior to upgrade.
1516
# Default: 7.34.0

0 commit comments

Comments
 (0)