Skip to content

Commit 7bcfbd3

Browse files
author
Martin Jackson
committed
Allow for choice in where file is written
1 parent 41bc42d commit 7bcfbd3

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

ansible/playbooks/write-token-kubeconfig/write-token-kubeconfig.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,7 @@
8787
token: {{ k8s_api_key }}
8888
dest: '{{ kubeconfig_file }}'
8989
mode: '0640'
90+
91+
- name: Notify user
92+
ansible.builtin.debug:
93+
msg: "Wrote {{ kubeconfig_file }}"

scripts/write-token-kubeconfig.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env bash
22
set -eu
33

4+
OUTPUTFILE=${1:-"~/.kube/config"}
5+
46
get_abs_filename() {
57
# $1 : relative filename
68
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
@@ -14,6 +16,4 @@ ANSIBLEPATH="$(dirname ${SCRIPTPATH})/ansible"
1416
PLAYBOOKPATH="${ANSIBLEPATH}/playbooks"
1517
export ANSIBLE_CONFIG="${ANSIBLEPATH}/ansible.cfg"
1618

17-
PATTERN_NAME=${1:-$(basename "`pwd`")}
18-
19-
ansible-playbook -e pattern_name="${PATTERN_NAME}" -e pattern_dir="${PATTERNPATH}" "${PLAYBOOKPATH}/write-token-kubeconfig/write-token-kubeconfig.yml"
19+
ansible-playbook -e pattern_dir="${PATTERNPATH}" -e kubeconfig_file="${OUTPUTFILE}" "${PLAYBOOKPATH}/write-token-kubeconfig/write-token-kubeconfig.yml"

0 commit comments

Comments
 (0)