Skip to content

Commit ee94f43

Browse files
committed
Add script to run the install task on dnf platforms
``` $ export PUPPET_FORGE_TOKEN=... $ docker/bin/install.sh rocky ... puppet 8.10.0 facter 4.10.0 Notice: Scope(Class[main]): puppet apply Notice: Compiled catalog for 1b5bf15dd39f in environment production in 0.02 seconds Notice: Applied catalog in 0.02 seconds Complete ```
1 parent 03fe0fd commit ee94f43

File tree

5 files changed

+175
-3
lines changed

5 files changed

+175
-3
lines changed

docker/README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,40 @@
22

33
These directories contain Dockerfiles that are useful for testing installation and upgrades.
44

5+
All examples assume the `PUPPET_FORGE_TOKEN` environment variable is set.
6+
57
## Usage
68

79
### Installation
810

9-
TBD
11+
This case uses the `install_shell.sh` task to install puppet-agent 8.x and verifies
12+
you can run `puppet apply`
13+
14+
#### Usage
15+
16+
#### Perform default install
17+
18+
```
19+
$ docker/bin/install.sh
20+
...
21+
Installing : puppet-agent-8.10.0-1.el8.x86_64
22+
...
23+
Notice: Scope(Class[main]): puppet apply
24+
Notice: Compiled catalog for 201fbd3e5e0b in environment production in 0.02 seconds
25+
Notice: Applied catalog in 0.02 seconds
26+
```
27+
28+
#### Install a specific platform
29+
30+
```
31+
$ docker/bin/install.sh fedora
32+
...
33+
Installing : puppet-agent-8.10.0-1.fc40.x86_64
34+
...
35+
Notice: Scope(Class[main]): puppet apply
36+
Notice: Compiled catalog for 881280c14d12 in environment production in 0.02 seconds
37+
Notice: Applied catalog in 0.02 seconds
38+
```
1039

1140
### Upgrades
1241

@@ -15,8 +44,6 @@ use this module to upgrade to an "after" version of puppet-agent 8.x.
1544

1645
#### Usage
1746

18-
All examples assume the `PUPPET_FORGE_TOKEN` environment variable is set.
19-
2047
##### Perform default upgrade
2148

2249
```

docker/bin/helpers/run-install.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
to_version=${1:-8.10.0}
6+
puppet_version=( ${to_version//./ } )
7+
puppet_major=${puppet_version[0]}
8+
case $puppet_major in
9+
7)
10+
to_collection=puppet7
11+
;;
12+
8)
13+
to_collection=puppet8
14+
;;
15+
*)
16+
echo "Invalid version supplied" 1>&2
17+
exit 1
18+
esac
19+
20+
export PT__installdir=../
21+
export PT_version=${to_version}
22+
export PT_password=${PUPPET_FORGE_TOKEN}
23+
chmod u+x tasks/install_shell.sh
24+
tasks/install_shell.sh
25+
26+
echo "puppet $(/opt/puppetlabs/puppet/bin/puppet --version)"
27+
echo "facter $(/opt/puppetlabs/puppet/bin/facter --version)"
28+
/opt/puppetlabs/puppet/bin/puppet apply -e 'notice("puppet apply")'

docker/bin/install.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
# Usage: `./install.sh [<PLATFORM>] [<VERSION>]`
3+
#
4+
# Builds an upgrade process for the puppet-agent module and tags as
5+
# "pa-dev:<PLATFORM>".
6+
#
7+
# Parameters:
8+
# - PLATFORM: The platform on which the upgrade should occur. This also
9+
# supports comma-separated lists. Available:
10+
# - `amazon`
11+
# - `fedora`
12+
# - `rocky`
13+
# - `sles`
14+
# - `ubuntu`
15+
# Default: `ubuntu`
16+
# - BEFORE: The puppet-agent package version that is installed prior to upgrade.
17+
# Default: 7.34.0
18+
# - AFTER: The puppet-agent package version that should exist after upgrade.
19+
# Default: 8.1.0
20+
set -e
21+
22+
if [ -z "${PUPPET_FORGE_TOKEN}" ]; then
23+
echo "Environment variable PUPPET_FORGE_TOKEN must be set"
24+
exit 1
25+
fi
26+
27+
cd "$(dirname "$0")/../.."
28+
platforms=${1:-rocky}
29+
version=${2:-8.10.0}
30+
for platform in ${platforms//,/ }
31+
do
32+
case $platform in
33+
amazon)
34+
base_image='amazonlinux:2023'
35+
;;
36+
37+
fedora)
38+
base_image='fedora:40'
39+
;;
40+
41+
rocky)
42+
base_image='rockylinux/rockylinux:8'
43+
;;
44+
45+
*)
46+
echo "$0: Usage install.sh [amazon|fedora|rocky]"
47+
exit 1
48+
;;
49+
esac
50+
51+
docker build --rm -f docker/install/dnf/Dockerfile . -t pa-dev:$platform.install \
52+
--build-arg version=${version} \
53+
--build-arg BASE_IMAGE=${base_image}
54+
docker run -e PUPPET_FORGE_TOKEN --rm -ti pa-dev:$platform.install
55+
done
56+
echo Complete

docker/install/dnf/Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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/bin/install.sh rocky` from the project directory.
8+
# 4. Review the output. Repeat steps 2-3 as needed.
9+
#
10+
# At the end of execution, you will see a line like:
11+
# Dependencies resolved.
12+
# ========================================================================================================================================
13+
# Package Architecture Version Repository Size
14+
# ========================================================================================================================================
15+
# Installing:
16+
# puppet-agent x86_64 8.10.0-1.el8 puppet8 27 M
17+
#
18+
# This specifies the versions that were used for upgrade.
19+
#
20+
# Arguments:
21+
# - before: The version to do upgrade FROM. Default: "7.34.0"
22+
23+
ARG BASE_IMAGE=rocky:8
24+
FROM ${BASE_IMAGE}
25+
26+
# Use this to force a cache reset (e.g. for output purposes)
27+
#COPY $0 /tmp/Dockerfile
28+
29+
# Install some other dependencies for ease of life.
30+
RUN dnf update -y \
31+
&& dnf install -y git \
32+
&& dnf clean all
33+
34+
# This is also duplicated in the docker/bin/helpers/run-upgrade.sh.
35+
ENV module_path=/tmp/modules
36+
WORKDIR "${module_path}/puppet_agent"
37+
COPY metadata.json ./
38+
39+
# Installing dependencies from source. These versions should be within the range
40+
# of `dependencies` in metadata.json.
41+
RUN git clone --depth 1 https://github.com/puppetlabs/puppetlabs-stdlib ../stdlib --branch v9.7.0
42+
RUN git clone --depth 1 https://github.com/puppetlabs/puppetlabs-inifile ../inifile --branch v6.2.0
43+
RUN git clone --depth 1 https://github.com/puppetlabs/puppetlabs-apt ../apt --branch v10.0.1
44+
RUN git clone --depth 1 https://github.com/puppetlabs/puppetlabs-facts ../facts --branch 1.7.0
45+
46+
# Now move the project directory's files into the image. That way, if these
47+
# files change, caching will skip everything before this.
48+
COPY docker/bin/helpers/run-install.sh /tmp/bin/run-install.sh
49+
COPY files/ ./files/
50+
COPY locales/ ./locales/
51+
COPY spec/ ./spec/
52+
COPY task_spec/ ./task_spec/
53+
COPY tasks/ ./tasks/
54+
COPY templates/ ./templates
55+
COPY types/ ./types/
56+
COPY Gemfile Gemfile.lock Rakefile ./
57+
COPY lib/ ./lib/
58+
COPY manifests/ ./manifests/
59+
60+
# Perform the install.
61+
ENTRYPOINT ["/tmp/bin/run-install.sh"]

tasks/install_shell.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)