Skip to content

Commit 711682f

Browse files
committed
Update rocky Dockerfiles
Add README describing how to run these Dockerfiles * Dockerfile is used to verify upgrades, by default from 7.34.0 to 8.10.0. * Dockerfile.versions is used to install multiple release packages and verify you can get a listing. Update `Dockerfile` and `Dockerfile.versions` to allow credentials to be specified, taking care not to save the credentials in the docker image. Update `Dockerfile.versions` to download the puppet8 release package from yum-support and after installation, configure the username and password in the repo config. Added `run-versions.shUpdate `Dockerfile` to copy `run-upgrade.sh` into the docker image and run it using an externally provided password. Update `run-upgrade.sh` to pass username and password as facts to `upgrade.pp`. When the upgrade is performed, the module will create pc_repo with the provided credentials and use that to upgrade to 8.10.0.
1 parent 79631c2 commit 711682f

File tree

8 files changed

+97
-22
lines changed

8 files changed

+97
-22
lines changed

docker/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# README
2+
3+
These directories contain Dockerfiles that are useful for testing installation and upgrades.
4+
5+
## Usage
6+
7+
### Installation
8+
9+
TBD
10+
11+
### Upgrades
12+
13+
This case installs a "before" version of puppet-agent 7.x and verifies you can
14+
use this module to upgrade to an "after" version of puppet-agent 8.x.
15+
16+
#### Usage
17+
18+
All examples assume the `PUPPET_FORGE_TOKEN` environment variable is set.
19+
20+
##### Perform default upgrade
21+
22+
```
23+
$ docker/bin/upgrade.sh
24+
...
25+
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.34.0-1.el8' to '8.10.0'
26+
```
27+
28+
##### Upgrade a specific platform
29+
30+
```
31+
$ docker/bin/upgrade.sh rocky
32+
...
33+
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.34.0-1.el8' to '8.10.0'
34+
```
35+
36+
##### Upgrade from a specific version
37+
38+
```
39+
$ docker/bin/upgrade.sh rocky 7.12.0
40+
...
41+
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.12.0-1.el8' to '8.10.0'
42+
```
43+
44+
##### Upgrade from and to specific versions
45+
46+
```
47+
$ docker/bin/upgrade.sh rocky 7.34.0 8.11.0
48+
...
49+
Error: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: change from '7.12.0-1.el8' to '8.11.0' failed: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y update puppet-agent-8.11.0' returned 1
50+
```

docker/bin/helpers/run-upgrade.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ case $puppet_major in
2020
echo "Invalid version supplied" 1>&2
2121
exit 1
2222
esac
23-
FACTER_to_version=${1:-8.10.0} FACTER_to_collection=${to_collection} /opt/puppetlabs/puppet/bin/puppet apply --debug --trace --modulepath /tmp/modules /tmp/upgrade.pp
23+
FACTER_to_version=${1:-8.10.0} \
24+
FACTER_to_collection=${to_collection} \
25+
FACTER_forge_username=forge-key \
26+
FACTER_forge_password="${PUPPET_FORGE_TOKEN}" \
27+
/opt/puppetlabs/puppet/bin/puppet apply --debug --trace --modulepath /tmp/modules /tmp/upgrade.pp
28+
2429
# Make e.g. `puppet --version` work out of the box.
2530
PATH=/opt/puppetlabs/bin:$PATH \
2631
read -p "Explore the upgraded container? [y/N]: " choice && \

docker/bin/helpers/run-versions.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
# Install several repos: puppet 7 and 8
4+
wget -O puppet7.rpm http://yum.puppet.com/puppet7-release-el-8.noarch.rpm
5+
rpm -i puppet7.rpm --force --replacefiles --nodeps
6+
wget -O puppet8.rpm https://yum-puppetcore.puppet.com/public/puppet8-release-el-8.noarch.rpm
7+
rpm -i puppet8.rpm --force --replacefiles --nodeps
8+
9+
sed -i 's/^#\?username=.*/username=forge-key/' /etc/yum.repos.d/puppet8-dev-release.repo
10+
sed -i "s/^#\\?password=.*/password=${PUPPET_FORGE_TOKEN}/" /etc/yum.repos.d/puppet8-dev-release.repo
11+
12+
dnf list puppet-agent --showduplicates

docker/bin/upgrade.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,27 @@
88
# - PLATFORM: The platform on which the upgrade should occur. This also
99
# supports comma-separated lists. Available:
1010
# - `ubuntu`
11-
# - `centos`
1211
# - `rocky`
1312
# Default: `ubuntu`
1413
# - BEFORE: The puppet-agent package version that is installed prior to upgrade.
15-
# Default: 1.10.14
14+
# Default: 7.34.0
1615
# - AFTER: The puppet-agent package version that should exist after upgrade.
17-
# Default: 6.2.0
16+
# Default: 8.1.0
1817
set -e
1918

19+
if [ -z "${PUPPET_FORGE_TOKEN}" ]; then
20+
echo "Environment variable PUPPET_FORGE_TOKEN must be set"
21+
exit 1
22+
fi
23+
2024
cd "$(dirname "$0")/../.."
21-
platforms=${1:-ubuntu}
25+
platforms=${1:-rocky}
2226
before=${2:-7.34.0}
2327
after=${3:-8.10.0}
2428
for platform in ${platforms//,/ }
2529
do
2630
docker build --rm -f docker/$platform/Dockerfile . -t pa-dev:$platform \
2731
--build-arg before=${before}
28-
docker run --rm -ti pa-dev:$platform ${after}
32+
docker run -e PUPPET_FORGE_TOKEN --rm -ti pa-dev:$platform ${after}
2933
done
30-
echo Complete
34+
echo Complete

docker/bin/versions.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
# Default: `ubuntu`
1212
set -e
1313

14-
platform=${1:-ubuntu}
14+
if [ -z "${PUPPET_FORGE_TOKEN}" ]; then
15+
echo "Environment variable PUPPET_FORGE_TOKEN must be set"
16+
exit 1
17+
fi
18+
19+
platform=${1:-rocky}
1520

1621
case "${platform}" in
1722
ubuntu|rocky)
@@ -21,5 +26,5 @@ case "${platform}" in
2126
;;
2227
esac
2328
cd "$(dirname "$0")/../.."
24-
docker build -f docker/${platform}/Dockerfile.versions . -t pa-dev:${platform}-versions
25-
docker run -it --rm pa-dev:${platform}-versions
29+
docker build --rm -f docker/${platform}/Dockerfile.versions . -t pa-dev:${platform}-versions
30+
docker run -e PUPPET_FORGE_TOKEN --rm -it pa-dev:${platform}-versions

docker/rocky/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ FROM rockylinux/rockylinux:8
3131

3232
# Install some other dependencies for ease of life.
3333
RUN dnf update -y \
34-
&& dnf install -y wget git \
34+
&& dnf install -y git \
3535
&& dnf clean all
3636

3737
ARG before=7.34.0
@@ -40,8 +40,7 @@ LABEL before=${before}
4040
# Install proper FROM repo pupet 7
4141
RUN if [[ ${before} == 7.* ]]; then \
4242
echo Installing puppet7 repo; \
43-
wget -O puppet7.rpm http://yum.puppet.com/puppet7-release-el-8.noarch.rpm && \
44-
rpm -i puppet7.rpm; \
43+
rpm -Uvh http://yum.puppet.com/puppet7-release-el-8.noarch.rpm; \
4544
else echo no; \
4645
fi
4746

@@ -50,7 +49,8 @@ RUN if [[ ${before} == 7.* ]]; then \
5049

5150
# Install FROM version of puppet-agent.
5251
RUN dnf -y update && \
53-
dnf install -y puppet-agent-${before}-1.el8
52+
dnf install -y puppet-agent-${before} && \
53+
dnf clean all
5454

5555
# This is also duplicated in the docker/bin/helpers/run-upgrade.sh.
5656
ENV module_path=/tmp/modules

docker/rocky/Dockerfile.versions

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ RUN dnf update -y \
55
&& dnf install -y wget git \
66
&& dnf clean all
77

8-
# Install several repos: puppet 7 and 8
9-
RUN wget -O puppet7.rpm http://yum.puppet.com/puppet7-release-el-8.noarch.rpm && \
10-
rpm -i puppet7.rpm --force --replacefiles --nodeps && \
11-
wget -O puppet8.rpm http://yum.puppet.com/puppet8-release-el-8.noarch.rpm && \
12-
rpm -i puppet8.rpm --force --replacefiles --nodeps
8+
# Now move the project directory's files into the image. That way, if these
9+
# files change, caching will skip everything before this.
10+
COPY docker/bin/helpers/run-versions.sh /tmp/bin/run-versions.sh
1311

14-
# Print out available package versions for puppet-agent. If a specific version
15-
# is desired, pass that in with e.g. `--build-arg before=1.1.1`
16-
ENTRYPOINT ["dnf", "list", "puppet-agent", "--showduplicates"]
12+
# Print out available package versions for puppet-agent.
13+
ENTRYPOINT ["/tmp/bin/run-versions.sh"]

docker/upgrade.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
# process.
99
service_names => [],
1010
collection => $facts['to_collection'],
11+
username => $facts['forge_username'],
12+
password => Sensitive($facts['forge_password'])
1113
}
1214
}

0 commit comments

Comments
 (0)