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
|
ENV PATH=/root/.local/bin:$PATH
|
||||||
|
|
||||||
# Install git for gitea actions and ansible
|
# 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
|
RUN pipx install --include-deps ansible
|
||||||
|
|
||||||
ENV PY_COLOR="1"
|
ENV PY_COLOR="1"
|
||||||
@@ -14,4 +14,4 @@ WORKDIR /usr/src
|
|||||||
COPY entrypoint.sh .
|
COPY entrypoint.sh .
|
||||||
RUN chmod +x /usr/src/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:
|
playbook:
|
||||||
description: The playbook's path
|
description: The playbook's path
|
||||||
required: true
|
required: true
|
||||||
|
inventory:
|
||||||
|
description: Comma separated inventory files
|
||||||
|
required: false
|
||||||
only_check:
|
only_check:
|
||||||
description: Whether to only check without changes
|
description: Whether to only check without changes
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@@ -1,17 +1,25 @@
|
|||||||
#!/usr/bin/env ash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
INPUT_PLAYBOOK_PATH="$playbook"
|
INPUT_PLAYBOOK_PATH="$playbook"
|
||||||
INPUT_ONLY_CHECK="$only_check"
|
INPUT_ONLY_CHECK="$only_check"
|
||||||
|
INPUT_INVENTORY_FILE="$inventory"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
ANSIBLE_OPTIONS="-vv"
|
ANSIBLE_OPTIONS=("-vv")
|
||||||
|
|
||||||
if [ "$INPUT_ONLY_CHECK" = "true" ]; then
|
if [ "$INPUT_ONLY_CHECK" = "true" ]; then
|
||||||
ANSIBLE_OPTIONS="${ANSIBLE_OPTIONS} --check --diff"
|
ANSIBLE_OPTIONS+=("--check" "--diff")
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
echo "Running playbook with options: ansible-playbook $ANSIBLE_OPTIONS \"$INPUT_PLAYBOOK_PATH\""
|
IFS=',' read -r -a inventories <<< "$INPUT_INVENTORY_FILE"
|
||||||
ansible-playbook $ANSIBLE_OPTIONS "$INPUT_PLAYBOOK_PATH"
|
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
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user