Commit 14cfc33f authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

fix(lint): install requirements prior to running ansible-lint

Fixes #15
parent 1300d56e
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -525,6 +525,16 @@ stages:
    fi
  }

  function maybe_install_requirements() {
    if [ -f "$ANSIBLE_REQUIREMENTS_FILE" ]
    then
      log_info "--- \\e[32mrequirements\\e[0m file (\\e[33;1m${ANSIBLE_REQUIREMENTS_FILE}\\e[0m) found: running \\e[33;1mansible-galaxy install\\e[0m"
      # roles and collections are downloaded relatively to ANSIBLE_HOME (cached dir)
      # shellcheck disable=SC2086
      ansible-galaxy install -r "$ANSIBLE_REQUIREMENTS_FILE" $ANSIBLE_GALAXY_EXTRA_ARGS
    fi
  }

  function run_ansible() {
    inventory=$1
    tags=$2
@@ -571,12 +581,7 @@ stages:
      chmod 0600 ~/.netrc
    fi

    if [ -f "$ANSIBLE_REQUIREMENTS_FILE" ]; then
      log_info "--- \\e[32mrequirements\\e[0m file (\\e[33;1m${ANSIBLE_REQUIREMENTS_FILE}\\e[0m) found: running \\e[33;1mansible-galaxy install\\e[0m"
      # roles and collections are downloaded relatively to ANSIBLE_HOME (cached dir)
      # shellcheck disable=SC2086
      ansible-galaxy install -r "$ANSIBLE_REQUIREMENTS_FILE" $ANSIBLE_GALAXY_EXTRA_ARGS
    fi
    maybe_install_requirements

    # extra var environment_type & environment_name
    ansible_opts="-e environment_type=$environment_type -e environment_name=$environment_name"
@@ -713,6 +718,7 @@ ansible-lint:
      - ENV_PREFIX: STAGING
      - ENV_PREFIX: PROD
  script:
    - maybe_install_requirements
    - mkdir -p -m 777 reports
    - env_name=$(echo "$ENV_PREFIX" | tr '[:upper:]' '[:lower:]')
    - playbook_file=$(eval echo "\$ANSIBLE_${ENV_PREFIX}_PLAYBOOK_FILE")