Skip to content

Add support for Ubuntu platform #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions documentation/basic_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,13 @@ Example params.json Bolt parameters file:
"version": "2019.1.1"
}
```

## Offline usage

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.

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.

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`.

Installation content can be downloaded from [https://puppet.com/try-puppet/puppet-enterprise/download/](https://puppet.com/try-puppet/puppet-enterprise/download/).
14 changes: 10 additions & 4 deletions plans/action/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,18 @@
},
}

$precheck_results = run_task('peadm::precheck', $all_targets)
$platform = $precheck_results.first['platform'] # Assume the platform of the first result correct

# Validate that the name given for each system is both a resolvable name AND
# the configured hostname.
run_task('peadm::hostname', $all_targets).each |$result| {
# the configured hostname, and that all systems return the same platform
$precheck_results.each |$result| {
if $result.target.name != $result['hostname'] {
fail_plan("Hostname / DNS name mismatch: target ${result.target.name} reports '${result['hostname']}'")
}
if $result['platform'] != $platform {
fail_plan("Platform mismatch: target ${result.target.name} reports '${result['platform']}; expected ${platform}'")
}
}

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

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

run_plan('peadm::util::retrieve_and_upload', $pe_installer_targets,
source => "https://s3.amazonaws.com/pe-builds/released/${version}/puppet-enterprise-${version}-el-7-x86_64.tar.gz",
source => "https://s3.amazonaws.com/pe-builds/released/${version}/puppet-enterprise-${version}-${platform}.tar.gz",
local_path => $local_tarball_path,
upload_path => $upload_tarball_path,
)
Expand Down
4 changes: 2 additions & 2 deletions tasks/enable_replica.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

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

if [ -z "$PT_token_file" -o "$PT_token_file" = "null" ]; then
TOKEN_FILE="${HOME}/.puppetlabs/token"
Expand Down
8 changes: 0 additions & 8 deletions tasks/hostname.json

This file was deleted.

6 changes: 0 additions & 6 deletions tasks/hostname.sh

This file was deleted.

8 changes: 8 additions & 0 deletions tasks/precheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"description": "Return pre-check information about a system",
"parameters": { },
"input_method": "environment",
"implementations": [
{"name": "precheck.sh"}
]
}
17 changes: 17 additions & 0 deletions tasks/precheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

hostname=$(hostname -f)
osfamily=$(cat /etc/os-release | grep -qi ubuntu && echo "ubuntu" || echo "el")
version=$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2)
arch=$(uname -m)

# Because 64-bit Ubuntu wanted to be special.
[ "$osfamily" = "ubuntu" -a "$arch" = "x86_64" ] && arch="amd64"

# Output a JSON result for ease of Task usage in Puppet Task Plans
cat <<EOS
{
"hostname": "${hostname}",
"platform": "${osfamily}-${version}-${arch}"
}
EOS
4 changes: 2 additions & 2 deletions tasks/provision_replica.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

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

if [ -z "$PT_token_file" -o "$PT_token_file" = "null" ]; then
TOKEN_FILE="${HOME}/.puppetlabs/token"
Expand Down
5 changes: 4 additions & 1 deletion tasks/read_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"description": "Path to the file to read"
}
},
"input_method": "environment"
"input_method": "stdin",
"implementations": [
{"name": "read_file.rb"}
]
}
9 changes: 9 additions & 0 deletions tasks/read_file.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/opt/puppetlabs/puppet/bin/ruby

require 'json'

params = JSON.parse(STDIN.read)
content = File.read(params['path'])
result = { 'content' => content }.to_json

puts result
18 changes: 0 additions & 18 deletions tasks/read_file.sh

This file was deleted.