Skip to content

Commit 1a6c499

Browse files
committed
Install puppetcore* dpkg from apt-puppetcore.puppet.com
Adds support for puppetcore* collections to the apt-based install task. When installing the puppetcore* collection, the task will download a release package from apt-puppetcore.puppet.com/public and add the credentials to /etc/apt/auth.conf.d/apt-puppetcore-puppet.conf. The other collections are unaffected. The `PUPPET_FORGE_TOKEN` environment variable must be set, which will be passed as the `password` to the task. Add debian 10-12 and ubuntu 18.04-24.04 to test installs in docker. By default, it will install 8.11.0 on Ubuntu noble. The tzdata package prompts for input, so use DEBIAN_FRONTEND=noninteractive when building the image.
1 parent 60e3526 commit 1a6c499

File tree

3 files changed

+106
-33
lines changed

3 files changed

+106
-33
lines changed

docker/bin/install.sh

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,45 @@ platforms=${1:-rocky}
2929
version=${2:-8.11.0}
3030
for platform in ${platforms//,/ }
3131
do
32-
dockerfile='docker/install/dnf/Dockerfile'
33-
3432
case $platform in
35-
amazon*)
36-
base_image='amazonlinux:2023'
37-
;;
38-
39-
fedora40)
40-
base_image='fedora:40'
41-
;;
42-
43-
fedora36)
44-
base_image='fedora:36'
45-
;;
46-
47-
fedora*)
48-
base_image='fedora:41'
49-
;;
50-
51-
rocky8)
52-
base_image='rockylinux/rockylinux:8'
33+
amazon*|fedora*|rocky*)
34+
dockerfile='docker/install/dnf/Dockerfile'
5335
;;
54-
55-
rocky*)
56-
base_image='rockylinux/rockylinux:9'
57-
;;
58-
5936
sles*)
60-
base_image='registry.suse.com/suse/sle15:15.6'
6137
dockerfile='docker/install/sles/Dockerfile'
6238
;;
39+
debian*|ubuntu*)
40+
dockerfile='docker/install/apt/Dockerfile'
41+
;;
42+
*)
43+
echo "$0: platform ${platform} is not supported"
44+
exit 1
45+
;;
46+
esac
6347

48+
# Default to the latest OS version for each distro
49+
case $platform in
50+
amazon*) base_image='amazonlinux:2023';;
51+
fedora36) base_image='fedora:36';;
52+
fedora40) base_image='fedora:40';;
53+
fedora*) base_image='fedora:41';;
54+
rocky8) base_image='rockylinux/rockylinux:8';;
55+
rocky*) base_image='rockylinux/rockylinux:9';;
56+
sles*) base_image='registry.suse.com/suse/sle15:15.6';;
57+
debian10) base_image='debian:buster';;
58+
debian11) base_image='debian:bullseye';;
59+
debian*) base_image='debian:bookworm';;
60+
ubuntu1804) base_image='ubuntu:bionic';;
61+
ubuntu2004) base_image='ubuntu:focal';;
62+
ubuntu2204) base_image='ubuntu:jammy';;
63+
ubuntu*) base_image='ubuntu:noble';;
6464
*)
65-
echo "$0: Usage install.sh [amazon|fedora|rocky|sles]"
65+
echo "$0: Usage install.sh [amazon|debian|fedora|rocky|sles|ubuntu]"
6666
exit 1
6767
;;
6868
esac
6969

70+
# Add "--progress plain" for complete build output
7071
docker build --rm -f "${dockerfile}" . -t pa-dev:$platform.install \
7172
--build-arg BASE_IMAGE="${base_image}"
7273
docker run -e PUPPET_FORGE_TOKEN --rm -ti pa-dev:$platform.install "${version}"

docker/install/apt/Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 ubuntu` 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+
#
12+
# REMIND
13+
14+
ARG BASE_IMAGE=ubuntu:noble
15+
FROM ${BASE_IMAGE}
16+
17+
# Use this to force a cache reset (e.g. for output purposes)
18+
#COPY $0 /tmp/Dockerfile
19+
20+
# Install some other dependencies for ease of life.
21+
RUN apt-get update \
22+
&& DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y wget git lsb-release apt-utils systemd \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
26+
# This is also duplicated in docker/bin/helpers/run-upgrade.sh.
27+
ENV module_path=/tmp/modules
28+
WORKDIR "${module_path}/puppet_agent"
29+
COPY metadata.json ./
30+
31+
# Installing dependencies from source. These versions should be within the range
32+
# of `dependencies` in metadata.json.
33+
RUN git clone --tags https://github.com/puppetlabs/puppetlabs-stdlib ../stdlib && \
34+
$(cd ../stdlib && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)))
35+
RUN git clone --tags https://github.com/puppetlabs/puppetlabs-inifile ../inifile && \
36+
$(cd ../inifile && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)))
37+
RUN git clone --tags https://github.com/puppetlabs/puppetlabs-apt ../apt && \
38+
$(cd ../apt && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)))
39+
RUN git clone --tags https://github.com/puppetlabs/puppetlabs-facts ../facts && \
40+
$(cd ../facts && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)))
41+
42+
# Now move the project directory's files into the image. That way, if these
43+
# files change, caching will skip everything before this.
44+
COPY docker/bin/helpers/run-install.sh /tmp/bin/run-install.sh
45+
COPY files/ ./files/
46+
COPY locales/ ./locales/
47+
COPY spec/ ./spec/
48+
COPY task_spec/ ./task_spec/
49+
COPY tasks/ ./tasks/
50+
COPY templates/ ./templates
51+
COPY types/ ./types/
52+
COPY Gemfile Gemfile.lock Rakefile ./
53+
COPY lib/ ./lib/
54+
COPY manifests/ ./manifests/
55+
56+
# Perform the install.
57+
ENTRYPOINT ["/tmp/bin/run-install.sh"]

tasks/install_shell.sh

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,18 @@ fi
144144
if [ -n "$PT_apt_source" ]; then
145145
apt_source=$PT_apt_source
146146
else
147-
if [ "$nightly" = true ]; then
148-
apt_source='http://nightlies.puppet.com/apt'
147+
if [[ "$collection" == "puppetcore"* ]]; then
148+
apt_source='https://apt-puppetcore.puppet.com/public'
149+
if [ -z "$password" ]; then
150+
echo "A password parameter is required to install from ${apt_source}"
151+
exit 1
152+
fi
149153
else
150-
apt_source='http://apt.puppet.com'
154+
if [ "$nightly" = true ]; then
155+
apt_source='http://nightlies.puppet.com/apt'
156+
else
157+
apt_source='http://apt.puppet.com'
158+
fi
151159
fi
152160
fi
153161

@@ -667,6 +675,13 @@ install_file() {
667675
assert_unmodified_apt_config
668676

669677
dpkg -i --force-confmiss "$2"
678+
if [[ "$collection" =~ core ]]; then
679+
auth_conf="/etc/apt/auth.conf.d/apt-puppetcore-puppet.conf"
680+
sed -i "/^#?login/d" "${auth_conf}"
681+
echo "login ${username}" >> "${auth_conf}"
682+
sed -i "/^#?password/d" "${auth_conf}"
683+
echo "password ${password}" >> "${auth_conf}"
684+
fi
670685
run_cmd 'apt-get update -y'
671686

672687
if test "$version" = 'latest'; then
@@ -759,7 +774,7 @@ case $platform in
759774
"12") deb_codename="bookworm";;
760775
esac
761776
filetype="deb"
762-
filename="${collection}-release-${deb_codename}.deb"
777+
filename="${collection/core/}-release-${deb_codename}.deb"
763778
download_url="${apt_source}/${filename}"
764779
;;
765780
"Linuxmint"|"LinuxMint")
@@ -776,7 +791,7 @@ case $platform in
776791
"17") deb_codename="trusty";;
777792
esac
778793
filetype="deb"
779-
filename="${collection}-release-${deb_codename}.deb"
794+
filename="${collection/core/}-release-${deb_codename}.deb"
780795
download_url="${apt_source}/${filename}"
781796
;;
782797
"Ubuntu")
@@ -790,7 +805,7 @@ case $platform in
790805
"24.04") deb_codename="noble";;
791806
esac
792807
filetype="deb"
793-
filename="${collection}-release-${deb_codename}.deb"
808+
filename="${collection/core/}-release-${deb_codename}.deb"
794809
download_url="${apt_source}/${filename}"
795810
;;
796811
"mac_os_x")

0 commit comments

Comments
 (0)