[ADD] Script that launches containers

This commit is contained in:
Jorge Enrique Gómez Gómez 2021-10-28 19:55:16 -05:00
parent 74813cead2
commit f80cc7b7eb

14
launch-odoo14-container.sh Normal file → Executable file
View File

@ -10,7 +10,7 @@ usage ()
} }
is_in () { is_in () {
[[ $2 =~ (^|[[:space:]])$1($|[[:space:]]) ]] && return 1 || return 0 [[ $2 =~ (^|[[:space:]])$1($|[[:space:]]) ]] && return 0 || return 1
} }
CONTAINER="$1" CONTAINER="$1"
@ -24,13 +24,15 @@ fi
# Container cannot exist already: # Container cannot exist already:
ALLCONTAINERS=$(lxc ls -c n --format csv) ALLCONTAINERS=$(lxc ls -c n --format csv)
is_in "$CONTAINER" "${ALLCONTAINERS}" if is_in "$CONTAINER" "${ALLCONTAINERS}"; then
container_exists=$?
if [[ ${container_exists} -eq 0 ]]; then
printf 'ERROR: %s\n' "A container with that name exists already" >&2 printf 'ERROR: %s\n' "A container with that name exists already" >&2
exit 2 exit 2
fi fi
echo "Would have launched container" ~/.venv/ansible/bin/ansible-pull \
--url ssh://git@gitea.agofer.net:22001/jegomez/ansible-role-odoo14-launch-container \
--extra-vars nombre=${CONTAINER} \
--vault-password-file ~/.vault_pass.txt \
--limit localhost,nginx \
--inventory hosts