Skip to content

Commit 6e70cc1

Browse files
authoredJan 22, 2020
Merge pull request #54 from puppetlabs/ubuntu
Add support for Ubuntu platform
2 parents 9fd519e + eb8b1d6 commit 6e70cc1

11 files changed

+62
-41
lines changed
 

Diff for: ‎documentation/basic_usage.md

+10
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,13 @@ Example params.json Bolt parameters file:
7474
"version": "2019.1.1"
7575
}
7676
```
77+
78+
## Offline usage
79+
80+
The peadm::provision plan downloads installation content from an online repository by default. To perform an offline installation, you can prefetch the needed content and place it in the staging directory. If content is available in the staging directory, peadm::provision will not try to download it.
81+
82+
The default staging directory is `/tmp`. If a different staging dir is being used, it can be specified using the `stagingdir` parameter to the peadm::provision plan.
83+
84+
The content needed is the PE installation tarball for the target version. The installation content should be in the staging dir, and should have its original name. E.g. `/tmp/puppet-enterprise-2019.2.2-el-7-x86_64.tar.gz`.
85+
86+
Installation content can be downloaded from [https://puppet.com/try-puppet/puppet-enterprise/download/](https://puppet.com/try-puppet/puppet-enterprise/download/).

Diff for: ‎plans/action/install.pp

+10-4
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,18 @@
106106
},
107107
}
108108

109+
$precheck_results = run_task('peadm::precheck', $all_targets)
110+
$platform = $precheck_results.first['platform'] # Assume the platform of the first result correct
111+
109112
# Validate that the name given for each system is both a resolvable name AND
110-
# the configured hostname.
111-
run_task('peadm::hostname', $all_targets).each |$result| {
113+
# the configured hostname, and that all systems return the same platform
114+
$precheck_results.each |$result| {
112115
if $result.target.name != $result['hostname'] {
113116
fail_plan("Hostname / DNS name mismatch: target ${result.target.name} reports '${result['hostname']}'")
114117
}
118+
if $result['platform'] != $platform {
119+
fail_plan("Platform mismatch: target ${result.target.name} reports '${result['platform']}; expected ${platform}'")
120+
}
115121
}
116122

117123
# Generate all the needed pe.conf files
@@ -143,12 +149,12 @@
143149
peadm::file_content_upload($puppetdb_database_replica_pe_conf, '/tmp/pe.conf', $puppetdb_database_replica_target)
144150

145151
# Download the PE tarball and send it to the nodes that need it
146-
$pe_tarball_name = "puppet-enterprise-${version}-el-7-x86_64.tar.gz"
152+
$pe_tarball_name = "puppet-enterprise-${version}-${platform}.tar.gz"
147153
$local_tarball_path = "${stagingdir}/${pe_tarball_name}"
148154
$upload_tarball_path = "/tmp/${pe_tarball_name}"
149155

150156
run_plan('peadm::util::retrieve_and_upload', $pe_installer_targets,
151-
source => "https://s3.amazonaws.com/pe-builds/released/${version}/puppet-enterprise-${version}-el-7-x86_64.tar.gz",
157+
source => "https://s3.amazonaws.com/pe-builds/released/${version}/puppet-enterprise-${version}-${platform}.tar.gz",
152158
local_path => $local_tarball_path,
153159
upload_path => $upload_tarball_path,
154160
)

Diff for: ‎tasks/enable_replica.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
USER="${USER:-$(id -un)}"
4-
HOME="${HOME:-$(getent passwd "$USER" | cut -d : -f 6)}"
3+
USER=$(id -un)
4+
HOME=$(getent passwd "$USER" | cut -d : -f 6)
55

66
if [ -z "$PT_token_file" -o "$PT_token_file" = "null" ]; then
77
TOKEN_FILE="${HOME}/.puppetlabs/token"

Diff for: ‎tasks/hostname.json

-8
This file was deleted.

Diff for: ‎tasks/hostname.sh

-6
This file was deleted.

Diff for: ‎tasks/precheck.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"description": "Return pre-check information about a system",
3+
"parameters": { },
4+
"input_method": "environment",
5+
"implementations": [
6+
{"name": "precheck.sh"}
7+
]
8+
}

Diff for: ‎tasks/precheck.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
hostname=$(hostname -f)
4+
osfamily=$(cat /etc/os-release | grep -qi ubuntu && echo "ubuntu" || echo "el")
5+
version=$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2)
6+
arch=$(uname -m)
7+
8+
# Because 64-bit Ubuntu wanted to be special.
9+
[ "$osfamily" = "ubuntu" -a "$arch" = "x86_64" ] && arch="amd64"
10+
11+
# Output a JSON result for ease of Task usage in Puppet Task Plans
12+
cat <<EOS
13+
{
14+
"hostname": "${hostname}",
15+
"platform": "${osfamily}-${version}-${arch}"
16+
}
17+
EOS

Diff for: ‎tasks/provision_replica.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
USER="${USER:-$(id -un)}"
4-
HOME="${HOME:-$(getent passwd "$USER" | cut -d : -f 6)}"
3+
USER=$(id -un)
4+
HOME=$(getent passwd "$USER" | cut -d : -f 6)
55

66
if [ -z "$PT_token_file" -o "$PT_token_file" = "null" ]; then
77
TOKEN_FILE="${HOME}/.puppetlabs/token"

Diff for: ‎tasks/read_file.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
"description": "Path to the file to read"
77
}
88
},
9-
"input_method": "environment"
9+
"input_method": "stdin",
10+
"implementations": [
11+
{"name": "read_file.rb"}
12+
]
1013
}

Diff for: ‎tasks/read_file.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/opt/puppetlabs/puppet/bin/ruby
2+
3+
require 'json'
4+
5+
params = JSON.parse(STDIN.read)
6+
content = File.read(params['path'])
7+
result = { 'content' => content }.to_json
8+
9+
puts result

Diff for: ‎tasks/read_file.sh

-18
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.