feat(main): keep ansible running

this allows us to run any playbook after the
setup is done
This commit is contained in:
Stephan Lüscher 2024-05-01 08:30:11 +00:00
parent b0470d1610
commit 101652eb31
No known key found for this signature in database
GPG key ID: 445779060FF3D3CF
4 changed files with 13 additions and 8 deletions

View file

@ -17,4 +17,8 @@ RUN pipx install poetry==${POETRY_VERSION}
WORKDIR /ansible
COPY . .
RUN poetry install --no-root
CMD poetry env use .venv/bin/python
CMD poetry env use .venv/bin/python && \
chmod +x entrypoint.sh
# Set entrypoint
ENTRYPOINT [ "/ansible/entrypoint.sh" ]

3
ansible/entrypoint.sh Executable file
View file

@ -0,0 +1,3 @@
#! /bin/bash
## Keep container running
sleep infinity

View file

@ -95,7 +95,7 @@ spec:
apiVersion: v1
kind: Pod
metadata:
name: ${FORGE_POD_NAME_SETUP}
name: ${FORGE_POD_NAME_ANVIL}
spec:
restartPolicy: OnFailure
volumes:
@ -121,7 +121,3 @@ spec:
secretKeyRef:
name: ublue-os_forge-secure
key: ANSIBLE_HOST_BECOME_PASSWORD
command:
- ansible-playbook
args:
- playbooks/configure_host.yml

View file

@ -6,7 +6,7 @@ export FORGE_POD_CONFIGURATION="forge-pod.yml"
export FORGE_POD_NAME_PRE_AMBLE="ublue-os_forge-"
export FORGE_POD_NAME_REVERSE_PROXY=${FORGE_POD_NAME_PRE_AMBLE}rvproxy
export FORGE_POD_NAME_REGISTRY=${FORGE_POD_NAME_PRE_AMBLE}registry
export FORGE_POD_NAME_SETUP=${FORGE_POD_NAME_PRE_AMBLE}setup
export FORGE_POD_NAME_ANVIL=${FORGE_POD_NAME_PRE_AMBLE}anvil
# Functions
function setup {
@ -23,7 +23,7 @@ function setup {
configure_host_prerequisites & PID_CONFIG=$!
wait ${PID_CONFIG}
echo -e "${YELLOW}Configuring host system...${ENDCOLOR}"
podman logs --color --follow "${FORGE_POD_NAME_SETUP}-ansible.${FORGE_DOMAIN_NAME}"
podman exec ${FORGE_POD_NAME_ANVIL}-ansible.${FORGE_DOMAIN_NAME} ansible-playbook playbooks/configure_host.yml
echo ""
echo -e "${YELLOW}Cleaning up secrets...${ENDCOLOR}"
delete_secrets
@ -36,6 +36,7 @@ function up {
echo -e "${YELLOW}Heating up forge...${ENDCOLOR}"
podman pod start ${FORGE_POD_NAME_REVERSE_PROXY}
podman pod start ${FORGE_POD_NAME_REGISTRY}
podman pod start ${FORGE_POD_NAME_ANVIL}
echo -e "${GREEN}The following containers are now running...${ENDCOLOR}"
show_containter_info
echo -e "${GREEN}Done. Happy forging!${ENDCOLOR}"
@ -47,6 +48,7 @@ function down {
show_containter_info
podman pod stop "${FORGE_POD_NAME_REVERSE_PROXY}" --ignore
podman pod stop "${FORGE_POD_NAME_REGISTRY}" --ignore
podman pod stop "${FORGE_POD_NAME_ANVIL}" --ignore
echo -e "${GREEN}Done. Have a nice day${ENDCOLOR}"
}