Skip to content

Commit

Permalink
Allow for choice in where file is written
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Jackson committed Jul 26, 2024
1 parent 41bc42d commit 7bcfbd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@
token: {{ k8s_api_key }}
dest: '{{ kubeconfig_file }}'
mode: '0640'

- name: Notify user
ansible.builtin.debug:
msg: "Wrote {{ kubeconfig_file }}"
6 changes: 3 additions & 3 deletions scripts/write-token-kubeconfig.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -eu

OUTPUTFILE=${1:-"~/.kube/config"}

get_abs_filename() {
# $1 : relative filename
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
Expand All @@ -14,6 +16,4 @@ ANSIBLEPATH="$(dirname ${SCRIPTPATH})/ansible"
PLAYBOOKPATH="${ANSIBLEPATH}/playbooks"
export ANSIBLE_CONFIG="${ANSIBLEPATH}/ansible.cfg"

PATTERN_NAME=${1:-$(basename "`pwd`")}

ansible-playbook -e pattern_name="${PATTERN_NAME}" -e pattern_dir="${PATTERNPATH}" "${PLAYBOOKPATH}/write-token-kubeconfig/write-token-kubeconfig.yml"
ansible-playbook -e pattern_dir="${PATTERNPATH}" -e kubeconfig_file="${OUTPUTFILE}" "${PLAYBOOKPATH}/write-token-kubeconfig/write-token-kubeconfig.yml"

0 comments on commit 7bcfbd3

Please sign in to comment.