From 6076e31518572c8de7a32b7e79321ccfdfa67c76 Mon Sep 17 00:00:00 2001 From: Yosafat Marselino Date: Sat, 17 May 2025 10:00:15 -0400 Subject: [PATCH] Parse arguments for install script from ansible --- curl_execute.yaml | 11 ++++++++++- test-scripts/install_k8s.sh | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/curl_execute.yaml b/curl_execute.yaml index 578ff9e..5fd8a19 100644 --- a/curl_execute.yaml +++ b/curl_execute.yaml @@ -3,6 +3,14 @@ hosts: target_hosts become: yes # Use sudo if needed tasks: + - name: Convert params dictionary to command line arguments + set_fact: + cli_args: "{{ script_params | dict2items | map('format', '--{key} {value}') | join(' ') }}" + + - name: Show arguments to be used + debug: + var: cli_args + - name: Create temporary directory for scripts file: path: /tmp/downloaded_scripts @@ -29,7 +37,8 @@ - { name: 'script1.sh' } - name: Execute downloaded scripts - shell: "/tmp/downloaded_scripts/{{ item.item.name }} --ip 192.168.8.54 --prune true " + #shell: "/tmp/downloaded_scripts/{{ item.item.name }} --ip 192.168.8.54 --prune true " + shell: "/tmp/downloaded_scripts/{{ item.item.name }} {{ cli_args }} " loop: "{{ downloaded_scripts.results }}" register: script_output diff --git a/test-scripts/install_k8s.sh b/test-scripts/install_k8s.sh index 3b8aa70..6d2029e 100644 --- a/test-scripts/install_k8s.sh +++ b/test-scripts/install_k8s.sh @@ -95,7 +95,7 @@ check_existing_cluster() { if command_exists kubectl && kubectl cluster-info &>/dev/null; then echo "Found existing installation" echo "Proceed to clean em UP" - if [[ $PRUNE != false ]]; then + if [[ $PRUNE != true ]]; then echo "Kubernetes cluster removal skipped. Exiting script." exit 0 fi