[WIP] First version of script that simplifies launch

This commit is contained in:
Jorge Enrique Gómez Gómez 2021-10-28 19:05:01 -05:00
parent 4dc5f2c911
commit 74813cead2
2 changed files with 37 additions and 2 deletions

View File

@ -16,8 +16,7 @@ ansible-pull \
* Launches a new LXD container called **newodoocontainer**, that uses a LXD profile to download * Launches a new LXD container called **newodoocontainer**, that uses a LXD profile to download
and setup Odoo v14. and setup Odoo v14.
* Creates a DNS alias for **externo.agofer.net** or **externo2.agofer.net** * Creates a DNS alias for **externo.agofer.net** or **externo2.agofer.net**
(see role variables in `local.yml` file), called (see role variables in `local.yml` file), called **_newodoocontainer_.agofer.net**.
**<newodoocontainer>.agofer.net**.
* Registers this container in the existing Nginx Proxy container. * Registers this container in the existing Nginx Proxy container.
* Requests an SSL certificate to _Let's Encrypt_ for the new domain, storing * Requests an SSL certificate to _Let's Encrypt_ for the new domain, storing
the certificates in the Nginx Proxy container. the certificates in the Nginx Proxy container.

View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Uses ansible-pull from a Python venv to create a LXD container
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
usage ()
{
echo "Uses ansible-pull from a Python venv to create a LXD container"
echo " Usage: $1 <new-container-name>"
}
is_in () {
[[ $2 =~ (^|[[:space:]])$1($|[[:space:]]) ]] && return 1 || return 0
}
CONTAINER="$1"
# Need a container name:
if [ -z "$CONTAINER" ]; then
usage "$0"
exit 1
fi
# Container cannot exist already:
ALLCONTAINERS=$(lxc ls -c n --format csv)
is_in "$CONTAINER" "${ALLCONTAINERS}"
container_exists=$?
if [[ ${container_exists} -eq 0 ]]; then
printf 'ERROR: %s\n' "A container with that name exists already" >&2
exit 2
fi
echo "Would have launched container"