Skip to content

Commit acf0ad9

Browse files
authored
Merge pull request #757 from puppetlabs/private
Update module to support yum-puppetcore.puppet.com
2 parents a9bbea7 + e565497 commit acf0ad9

22 files changed

+645
-138
lines changed

REFERENCE.md

+44-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ The following parameters are available in the `puppet_agent` class:
9898
* [`version_file_path`](#-puppet_agent--version_file_path)
9999
* [`skip_if_unavailable`](#-puppet_agent--skip_if_unavailable)
100100
* [`disable_proxy`](#-puppet_agent--disable_proxy)
101+
* [`username`](#-puppet_agent--username)
102+
* [`password`](#-puppet_agent--password)
101103

102104
##### <a name="-puppet_agent--arch"></a>`arch`
103105

@@ -371,6 +373,22 @@ Data type: `Boolean`
371373

372374
Default value: `false`
373375

376+
##### <a name="-puppet_agent--username"></a>`username`
377+
378+
Data type: `Optional`
379+
380+
The username to use when downloading from a source location requiring authentication.
381+
382+
Default value: `undef`
383+
384+
##### <a name="-puppet_agent--password"></a>`password`
385+
386+
Data type: `Optional[Sensitive]`
387+
388+
The password to use when downloading from a source location requiring authentication.
389+
390+
Default value: `undef`
391+
374392
### <a name="puppet_agent--configure"></a>`puppet_agent::configure`
375393

376394
It does not require management of the agent package.
@@ -843,7 +861,7 @@ The version of puppet-agent to install (defaults to latest when no agent is inst
843861

844862
##### `collection`
845863

846-
Data type: `Optional[Enum[puppet7, puppet8, puppet, puppet7-nightly, puppet8-nightly, puppet-nightly]]`
864+
Data type: `Optional[Enum[puppet7, puppet8, puppet, puppet7-nightly, puppet8-nightly, puppet-nightly, puppetcore7, puppetcore8]]`
847865

848866
The Puppet collection to install from (defaults to puppet, which maps to the latest collection released)
849867

@@ -895,6 +913,18 @@ Data type: `Optional[Integer]`
895913

896914
The number of retries in case of network connectivity failures
897915

916+
##### `username`
917+
918+
Data type: `Optional[String]`
919+
920+
The username to use when downloading from a source location requiring authentication
921+
922+
##### `password`
923+
924+
Data type: `Optional[String]`
925+
926+
The password to use when downloading from a source location requiring authentication
927+
898928
### <a name="install_powershell"></a>`install_powershell`
899929

900930
Install the Puppet agent package
@@ -979,7 +1009,7 @@ The version of puppet-agent to install
9791009

9801010
##### `collection`
9811011

982-
Data type: `Optional[Enum[puppet7, puppet8, puppet, puppet7-nightly, puppet8-nightly, puppet-nightly]]`
1012+
Data type: `Optional[Enum[puppet7, puppet8, puppet, puppet7-nightly, puppet8-nightly, puppet-nightly, puppetcore7, puppetcore8]]`
9831013

9841014
The Puppet collection to install from (defaults to puppet, which maps to the latest collection released)
9851015

@@ -1031,6 +1061,18 @@ Data type: `Optional[Integer]`
10311061

10321062
The number of retries in case of network connectivity failures
10331063

1064+
##### `username`
1065+
1066+
Data type: `Optional[String]`
1067+
1068+
The username to use when downloading from a source location requiring authentication
1069+
1070+
##### `password`
1071+
1072+
Data type: `Optional[String]`
1073+
1074+
The password to use when downloading from a source location requiring authentication
1075+
10341076
### <a name="run"></a>`run`
10351077

10361078
Run the Puppet agent. This task may cause problems if run in Puppet Enterprise.

docker/README.md

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# README
2+
3+
These directories contain Dockerfiles that are useful for testing installation and upgrades.
4+
5+
All examples assume the `PUPPET_FORGE_TOKEN` environment variable is set.
6+
7+
## Usage
8+
9+
### Installation
10+
11+
This case uses the `install_shell.sh` task to install puppet-agent 8.x and verifies
12+
`puppet apply` works.
13+
14+
#### Usage
15+
16+
```
17+
docker/bin/install.sh [os name] [agent version]
18+
```
19+
20+
#### Perform default install
21+
22+
Without any arguments, puppet-agent 8.11.0 will be installed on Rocky 8
23+
24+
```
25+
$ docker/bin/install.sh
26+
...
27+
Installing : puppet-agent-8.11.0-1.el8.x86_64
28+
...
29+
Notice: Scope(Class[main]): puppet apply
30+
Notice: Compiled catalog for 201fbd3e5e0b in environment production in 0.02 seconds
31+
Notice: Applied catalog in 0.02 seconds
32+
```
33+
34+
#### Install the latest version of an OS
35+
36+
When given an `os name` parameter, puppet-agent 8.11.0 will be installed on the latest
37+
version of that OS, in this example Fedora 41.
38+
39+
```
40+
$ docker/bin/install.sh fedora
41+
...
42+
Installing : puppet-agent-8.11.0-1.el9.x86_64
43+
...
44+
Notice: Scope(Class[main]): puppet apply
45+
Notice: Compiled catalog for 881280c14d12 in environment production in 0.02 seconds
46+
Notice: Applied catalog in 0.02 seconds
47+
```
48+
49+
#### Install a specific platform and version
50+
51+
When given `os name` and `agent version` parameters, install that version of the
52+
agent on that OS, in this example pupet-agent 8.10.0 on Fedora 40.
53+
54+
```
55+
$ docker/bin/install.sh fedora40 8.10.0
56+
...
57+
Installing : puppet-agent-8.10.0-1.fc40.x86_64
58+
...
59+
Notice: Scope(Class[main]): puppet apply
60+
Notice: Compiled catalog for 6791cd8e4da1 in environment production in 0.02 seconds
61+
Notice: Applied catalog in 0.02 seconds
62+
```
63+
64+
### Upgrades
65+
66+
This case installs a `before` version of puppet-agent and verifies you can use
67+
this module to upgrade to an `after` version.
68+
69+
#### Usage
70+
71+
```
72+
docker/bin/upgrade.sh [os name] [before] [after]
73+
```
74+
75+
##### Perform default upgrade
76+
77+
Without any arguments, puppet-agent 7.34.0 will be installed on Rocky 8 and will
78+
be upgraded to 8.11.0.
79+
80+
```
81+
$ docker/bin/upgrade.sh
82+
...
83+
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.34.0-1.el8' to '8.10.0'
84+
```
85+
86+
##### Upgrade a specific platform
87+
88+
When given an `os name` parameter, puppet-agent 8.11.0 will be installed on the latest
89+
version of that OS, in this example amazon 2023.
90+
91+
```
92+
$ docker/bin/upgrade.sh amazon
93+
...
94+
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.34.0-1.amazon2023' to '8.11.0'
95+
```
96+
97+
##### Upgrade from a specific version
98+
99+
When given an `os name` and `before` parameters, install that version of the
100+
agent and upgrade to the default `after` version, in this example, 8.11.0.
101+
102+
```
103+
$ docker/bin/upgrade.sh rocky 7.12.0
104+
...
105+
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.12.0-1.el8' to '8.11.0'
106+
```
107+
108+
##### Upgrade from and to specific versions
109+
110+
When given an `os name`, `before` and `after` parameters, install the `before`
111+
version of the agent and upgrade to the `after` version.
112+
113+
```
114+
$ docker/bin/upgrade.sh rocky 7.16.0 8.10.0
115+
...
116+
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.16.0-1.el8' to '8.10.0'
117+
```

docker/bin/helpers/run-install.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
to_version="${1}"
6+
if [[ -z "${to_version}" ]]; then
7+
echo "$0: The version to install must be passed as an argument"
8+
exit 1
9+
fi
10+
puppet_version=( ${to_version//./ } )
11+
puppet_major=${puppet_version[0]}
12+
case $puppet_major in
13+
7)
14+
to_collection=puppetcore7
15+
;;
16+
8)
17+
to_collection=puppetcore8
18+
;;
19+
*)
20+
echo "$0: Invalid version supplied" 1>&2
21+
exit 1
22+
esac
23+
24+
export PT__installdir=../
25+
export PT_version=${to_version}
26+
export PT_collection=${to_collection}
27+
export PT_password=${PUPPET_FORGE_TOKEN}
28+
chmod u+x tasks/install_shell.sh
29+
tasks/install_shell.sh
30+
31+
echo "puppet $(/opt/puppetlabs/puppet/bin/puppet --version)"
32+
echo "facter $(/opt/puppetlabs/puppet/bin/facter --version)"
33+
/opt/puppetlabs/puppet/bin/puppet apply -e 'notice("puppet apply")'
34+
35+
# Make e.g. `puppet --version` work out of the box.
36+
PATH=/opt/puppetlabs/bin:$PATH \
37+
read -p "Explore the container? [y/N]: " choice && \
38+
choice=${choice:-N} && \
39+
if [ "${choice}" = "y" ]; then \
40+
bash; \
41+
else \
42+
echo "Moving on..."; \
43+
fi

docker/bin/helpers/run-upgrade.sh

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
#!/usr/bin/env bash
22

3-
# Run upgrades on a container. The default upgrade TO argument will be 6.2.0 if
3+
# Run upgrades on a container. The default upgrade TO argument will be 8.11.0 if
44
# no arguments are passed to this script.
55
set -e
66

7-
to_version=${1:-6.2.0}
7+
to_version=${1:-8.11.0}
88
# Calculate which collection should be used. This is derived from the puppet
99
# version.
1010
puppet_version=( ${to_version//./ } )
1111
puppet_major=${puppet_version[0]}
1212
case $puppet_major in
13-
4)
14-
to_collection=PC1
15-
;;
16-
5)
17-
to_collection=puppet5
18-
;;
19-
6)
20-
to_collection=puppet6
21-
;;
2213
7)
2314
to_collection=puppet7
2415
;;
16+
8)
17+
to_collection=puppet8
18+
;;
2519
*)
2620
echo "Invalid version supplied" 1>&2
2721
exit 1
2822
esac
29-
FACTER_to_version=${1:-6.2.0} FACTER_to_collection=${to_collection} /opt/puppetlabs/puppet/bin/puppet apply --debug --trace --modulepath /tmp/modules /tmp/upgrade.pp
23+
FACTER_to_version=${to_version} \
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+
3029
# Make e.g. `puppet --version` work out of the box.
3130
PATH=/opt/puppetlabs/bin:$PATH \
3231
read -p "Explore the upgraded container? [y/N]: " choice && \

docker/bin/install.sh

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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 "$0: 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.11.0}
30+
for platform in ${platforms//,/ }
31+
do
32+
dockerfile='docker/install/dnf/Dockerfile'
33+
34+
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'
53+
;;
54+
55+
rocky*)
56+
base_image='rockylinux/rockylinux:9'
57+
;;
58+
59+
sles*)
60+
base_image='registry.suse.com/suse/sle15:15.6'
61+
dockerfile='docker/install/sles/Dockerfile'
62+
;;
63+
64+
*)
65+
echo "$0: Usage install.sh [amazon|fedora|rocky|sles]"
66+
exit 1
67+
;;
68+
esac
69+
70+
docker build --rm -f "${dockerfile}" . -t pa-dev:$platform.install \
71+
--build-arg BASE_IMAGE="${base_image}"
72+
docker run -e PUPPET_FORGE_TOKEN --rm -ti pa-dev:$platform.install "${version}"
73+
done
74+
echo Complete

0 commit comments

Comments
 (0)