Skip to content

Commit 7f1cd3d

Browse files
authored
Adding tokenfile option (#13)
* added token file option to enable_replica * changes to enable token_file to be a param * adding token_file param to configure plan * default for token_file * fix the param type
1 parent 4198fdf commit 7f1cd3d

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

plans/configure.pp

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

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

1920
String[1] $stagingdir = '/tmp',
@@ -64,11 +65,13 @@
6465
# Run the PE Replica Provision
6566
run_task('pe_xl::provision_replica', $primary_master_target,
6667
primary_master_replica => $primary_master_replica_host,
68+
token_file => $token_file,
6769
)
6870

6971
# Run the PE Replica Enable
7072
run_task('pe_xl::enable_replica', $primary_master_target,
7173
primary_master_replica => $primary_master_replica_host,
74+
token_file => $token_file,
7275
)
7376

7477
# Run Puppet everywhere to pick up last remaining config tweaks

tasks/enable_replica.json

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"primary_master_replica": {
55
"type": "String",
66
"description": "The name of the replica to enable"
7+
},
8+
"token_file": {
9+
"type": "Optional[String]",
10+
"description": "The name of the token file to use for auth"
711
}
812
},
913
"input_method": "environment",

tasks/enable_replica.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
#!/bin/bash
22

3+
USER="${USER:=$(id -un)}"
4+
HOME="${HOME:=$(getent passwd "$USER" | cut -d : -f 6)}"
5+
6+
if [[ "${PT_token_file}x" != 'x' ]] ; then
7+
TOKEN_FILE="$PT_token_file"
8+
else
9+
TOKEN_FILE="${HOME}/.puppetlabs/token"
10+
fi
11+
312
set -e
413

514
env PATH="/opt/puppetlabs/bin:${PATH}" \
6-
USER="${USER:=$(id -un)}" \
7-
HOME="${HOME:=$(getent passwd "$USER" | cut -d : -f 6)}" \
15+
USER="$USER" \
16+
HOME="$HOME" \
817
puppet infrastructure enable replica "$PT_primary_master_replica" \
918
--skip-agent-config \
1019
--topology mono-with-compile \
11-
--yes
20+
--yes --token-file "$TOKEN_FILE"

tasks/provision_replica.json

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"primary_master_replica": {
55
"type": "String",
66
"description": "The name of the replica to provision"
7+
},
8+
"token_file": {
9+
"type": "Optional[String]",
10+
"description": "The name of the token-file for auth"
711
}
812
},
913
"input_method": "environment",

tasks/provision_replica.sh

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
#!/bin/bash
22

3+
USER="${USER:=$(id -un)}"
4+
HOME="${HOME:=$(getent passwd "$USER" | cut -d : -f 6)}"
5+
6+
if [[ "${PT_token_file}x" != 'x' ]] ; then
7+
TOKEN_FILE="$PT_token_file"
8+
else
9+
TOKEN_FILE="${HOME}/.puppetlabs/token"
10+
fi
11+
312
set -e
413

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

0 commit comments

Comments
 (0)