Using bash and supported inventories
This commit is contained in:
@@ -4,7 +4,7 @@ FROM public.ecr.aws/docker/library/node:22-alpine3.20
|
||||
ENV PATH=/root/.local/bin:$PATH
|
||||
|
||||
# Install git for gitea actions and ansible
|
||||
RUN apk add --no-cache bash curl python3 pipx git rsync unzip openssh
|
||||
RUN apk add --no-cache bash curl python3 pipx git rsync unzip openssh bash
|
||||
RUN pipx install --include-deps ansible
|
||||
|
||||
ENV PY_COLOR="1"
|
||||
@@ -14,4 +14,4 @@ WORKDIR /usr/src
|
||||
COPY entrypoint.sh .
|
||||
RUN chmod +x /usr/src/entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["ash","-c","/usr/src/entrypoint.sh"]
|
||||
ENTRYPOINT ["bash","-c","/usr/src/entrypoint.sh"]
|
||||
|
||||
@@ -7,6 +7,9 @@ inputs:
|
||||
playbook:
|
||||
description: The playbook's path
|
||||
required: true
|
||||
inventory:
|
||||
description: Comma separated inventory files
|
||||
required: false
|
||||
only_check:
|
||||
description: Whether to only check without changes
|
||||
required: false
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
#!/usr/bin/env ash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
INPUT_PLAYBOOK_PATH="$playbook"
|
||||
INPUT_ONLY_CHECK="$only_check"
|
||||
INPUT_INVENTORY_FILE="$inventory"
|
||||
|
||||
set -e
|
||||
|
||||
ANSIBLE_OPTIONS="-vv"
|
||||
ANSIBLE_OPTIONS=("-vv")
|
||||
|
||||
if [ "$INPUT_ONLY_CHECK" = "true" ]; then
|
||||
ANSIBLE_OPTIONS="${ANSIBLE_OPTIONS} --check --diff"
|
||||
ANSIBLE_OPTIONS+=("--check" "--diff")
|
||||
fi;
|
||||
|
||||
echo "Running playbook with options: ansible-playbook $ANSIBLE_OPTIONS \"$INPUT_PLAYBOOK_PATH\""
|
||||
ansible-playbook $ANSIBLE_OPTIONS "$INPUT_PLAYBOOK_PATH"
|
||||
IFS=',' read -r -a inventories <<< "$INPUT_INVENTORY_FILE"
|
||||
for inv in "${inventories[@]}"; do
|
||||
ANSIBLE_OPTIONS+=("--inventory" "$inv")
|
||||
done
|
||||
|
||||
ANSIBLE_OPTIONS+=("$INPUT_PLAYBOOK_PATH")
|
||||
|
||||
echo "Running playbook with options: ansible-playbook ${ANSIBLE_OPTIONS[*]}"
|
||||
ansible-playbook "${ANSIBLE_OPTIONS[@]}"
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user