Commit 1340aeee authored by Laurent CROQ's avatar Laurent CROQ Committed by Pierre Smeyers
Browse files

fix: remove failing functions export + add exec_hook

parent a213ef00
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -325,6 +325,17 @@ stages:
    awk '{while(match($0,"[$%]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH-3);val=ENVIRON[var]; gsub("[$%]{"var"}",val)}}1'
  }

  function exec_hook() {
    if [[ ! -x "$1" ]] && ! chmod +x "$1"
    then
      log_warn "... could not make \\e[33;1m${1}\\e[0m executable: please do it (chmod +x)"
      # fallback technique
      sh "$1"
    else
      "$1"
    fi
  }

  function run_ansible() {
    inventory=$1
    tags=$2
@@ -355,10 +366,7 @@ stages:
    prescript="$ANSIBLE_SCRIPTS_DIR/pre-ansible-playbook.sh"
    if [[ -f "$prescript" ]]; then
      log_info "--- \\e[32mpre-ansible-playbook\\e[0m hook (\\e[33;1m${prescript}\\e[0m) found: execute"
      # export utility functions first
      export -f log_info log_warn log_error cleanup_secrets
      chmod +x "$prescript"
      "$prescript"
      exec_hook "$prescript"
    else
      log_info "--- \\e[32mpre-ansible-playbook\\e[0m hook (\\e[33;1m${prescript}\\e[0m) not found: skip"
    fi
@@ -436,10 +444,7 @@ stages:
    postscript="$ANSIBLE_SCRIPTS_DIR/post-ansible-playbook.sh"
    if [[ -f "$postscript" ]]; then
      log_info "--- \\e[32mpost-ansible-playbook\\e[0m hook (\\e[33;1m${postscript}\\e[0m) found: execute"
      # export utility functions first
      export -f log_info log_warn log_error cleanup_secrets
      chmod +x "$postscript"
      "$postscript"
      exec_hook "$postscript"
    else
      log_info "--- \\e[32mpost-ansible-playbook\\e[0m hook (\\e[33;1m${postscript}\\e[0m) not found: skip"
    fi