Skip to content
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

Adding tokenfile option #13

Merged
merged 6 commits into from
Sep 27, 2018
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
3 changes: 3 additions & 0 deletions plans/configure.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

String[1] $compile_master_pool_address = $primary_master_host,
Boolean $manage_environment_groups = true,
String[1] $token_file = '${HOME}/.puppetlabs/token',
Optional[String[1]] $deploy_environment = undef,

String[1] $stagingdir = '/tmp',
Expand Down Expand Up @@ -64,11 +65,13 @@
# Run the PE Replica Provision
run_task('pe_xl::provision_replica', $primary_master_target,
primary_master_replica => $primary_master_replica_host,
token_file => $token_file,
)

# Run the PE Replica Enable
run_task('pe_xl::enable_replica', $primary_master_target,
primary_master_replica => $primary_master_replica_host,
token_file => $token_file,
)

# Run Puppet everywhere to pick up last remaining config tweaks
Expand Down
4 changes: 4 additions & 0 deletions tasks/enable_replica.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"primary_master_replica": {
"type": "String",
"description": "The name of the replica to enable"
},
"token_file": {
"type": "Optional[String]",
"description": "The name of the token file to use for auth"
}
},
"input_method": "environment",
Expand Down
15 changes: 12 additions & 3 deletions tasks/enable_replica.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#!/bin/bash

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

if [[ "${PT_token_file}x" != 'x' ]] ; then
TOKEN_FILE="$PT_token_file"
else
TOKEN_FILE="${HOME}/.puppetlabs/token"
fi

set -e

env PATH="/opt/puppetlabs/bin:${PATH}" \
USER="${USER:=$(id -un)}" \
HOME="${HOME:=$(getent passwd "$USER" | cut -d : -f 6)}" \
USER="$USER" \
HOME="$HOME" \
puppet infrastructure enable replica "$PT_primary_master_replica" \
--skip-agent-config \
--topology mono-with-compile \
--yes
--yes --token-file "$TOKEN_FILE"
4 changes: 4 additions & 0 deletions tasks/provision_replica.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"primary_master_replica": {
"type": "String",
"description": "The name of the replica to provision"
},
"token_file": {
"type": "Optional[String]",
"description": "The name of the token-file for auth"
}
},
"input_method": "environment",
Expand Down
16 changes: 13 additions & 3 deletions tasks/provision_replica.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
#!/bin/bash

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

if [[ "${PT_token_file}x" != 'x' ]] ; then
TOKEN_FILE="$PT_token_file"
else
TOKEN_FILE="${HOME}/.puppetlabs/token"
fi

set -e

env PATH="/opt/puppetlabs/bin:${PATH}" \
USER="${USER:=$(id -un)}" \
HOME="${HOME:=$(getent passwd "$USER" | cut -d : -f 6)}" \
puppet infrastructure provision replica "$PT_primary_master_replica"
USER="$USER" \
HOME="$HOME" \
puppet infrastructure provision replica --token-file "$TOKEN_FILE" \
"$PT_primary_master_replica"