From 21e04fac17b271c8d65a68d83c26e05b61625f18 Mon Sep 17 00:00:00 2001 From: Troy Klein Date: Wed, 26 Sep 2018 22:48:25 +0000 Subject: [PATCH 1/5] added token file option to enable_replica --- tasks/enable_replica.json | 4 ++++ tasks/enable_replica.sh | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tasks/enable_replica.json b/tasks/enable_replica.json index 58d4d58b..126afc75 100644 --- a/tasks/enable_replica.json +++ b/tasks/enable_replica.json @@ -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", diff --git a/tasks/enable_replica.sh b/tasks/enable_replica.sh index 51979498..c058d73a 100755 --- a/tasks/enable_replica.sh +++ b/tasks/enable_replica.sh @@ -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}" From bb3dececb9f5d2f98f693d8eef4494f3b61607c0 Mon Sep 17 00:00:00 2001 From: Troy Klein Date: Wed, 26 Sep 2018 23:06:37 +0000 Subject: [PATCH 2/5] changes to enable token_file to be a param --- tasks/enable_replica.sh | 8 ++++---- tasks/provision_replica.json | 4 ++++ tasks/provision_replica.sh | 16 +++++++++++++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/tasks/enable_replica.sh b/tasks/enable_replica.sh index c058d73a..4a91de58 100755 --- a/tasks/enable_replica.sh +++ b/tasks/enable_replica.sh @@ -4,7 +4,7 @@ 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}" + TOKEN_FILE="$PT_token_file" else TOKEN_FILE="${HOME}/.puppetlabs/token" fi @@ -12,9 +12,9 @@ fi set -e env PATH="/opt/puppetlabs/bin:${PATH}" \ - USER="${USER}" \ - HOME="${HOME}" \ + USER="$USER" \ + HOME="$HOME" \ puppet infrastructure enable replica "$PT_primary_master_replica" \ --skip-agent-config \ --topology mono-with-compile \ - --yes --token-file "${TOKEN_FILE}" + --yes --token-file "$TOKEN_FILE" diff --git a/tasks/provision_replica.json b/tasks/provision_replica.json index 0fe8eb5e..9536ecb5 100644 --- a/tasks/provision_replica.json +++ b/tasks/provision_replica.json @@ -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", diff --git a/tasks/provision_replica.sh b/tasks/provision_replica.sh index 64dd86de..042a2f3f 100755 --- a/tasks/provision_replica.sh +++ b/tasks/provision_replica.sh @@ -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" From 3f0ce5c8b2a28164feba25cc860b6bb41af30aaa Mon Sep 17 00:00:00 2001 From: Troy Klein Date: Wed, 26 Sep 2018 23:35:48 +0000 Subject: [PATCH 3/5] adding token_file param to configure plan --- plans/configure.pp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plans/configure.pp b/plans/configure.pp index 1d875e71..7fe5a36d 100644 --- a/plans/configure.pp +++ b/plans/configure.pp @@ -14,6 +14,7 @@ String[1] $compile_master_pool_address = $primary_master_host, Boolean $manage_environment_groups = true, + Optional[String[1]] $token_file = '${HOME}/.puppetlabs/token', Optional[String[1]] $deploy_environment = undef, String[1] $stagingdir = '/tmp', @@ -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 From 49373668bd3487b9ff25d46708de0c1ed45f6e5f Mon Sep 17 00:00:00 2001 From: Troy Klein Date: Thu, 27 Sep 2018 01:15:35 +0000 Subject: [PATCH 4/5] default for token_file --- plans/configure.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plans/configure.pp b/plans/configure.pp index 7fe5a36d..7eaf0b70 100644 --- a/plans/configure.pp +++ b/plans/configure.pp @@ -14,7 +14,7 @@ String[1] $compile_master_pool_address = $primary_master_host, Boolean $manage_environment_groups = true, - Optional[String[1]] $token_file = '${HOME}/.puppetlabs/token', + String[1] $token_file = '${HOME}/.puppetlabs/token', Optional[String[1]] $deploy_environment = undef, String[1] $stagingdir = '/tmp', From ddca5869532c93601757cc4ee3456dd6e277bbb8 Mon Sep 17 00:00:00 2001 From: Troy Klein Date: Thu, 27 Sep 2018 15:21:45 +0000 Subject: [PATCH 5/5] fix the param type --- tasks/enable_replica.json | 2 +- tasks/provision_replica.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/enable_replica.json b/tasks/enable_replica.json index 126afc75..7be5fa23 100644 --- a/tasks/enable_replica.json +++ b/tasks/enable_replica.json @@ -6,7 +6,7 @@ "description": "The name of the replica to enable" }, "token_file": { - "type": "Optional['String']", + "type": "Optional[String]", "description": "The name of the token file to use for auth" } }, diff --git a/tasks/provision_replica.json b/tasks/provision_replica.json index 9536ecb5..595d768c 100644 --- a/tasks/provision_replica.json +++ b/tasks/provision_replica.json @@ -6,7 +6,7 @@ "description": "The name of the replica to provision" }, "token_file": { - "type": "Optional['String']", + "type": "Optional[String]", "description": "The name of the token-file for auth" } },