Skip to content

Test Ansible roles

Daniel Matos edited this page Mar 21, 2023 · 4 revisions

Variables

This variables need to be set, depending on the system the machine is running

export HOST=       # Domain name
export CDR_MAILS=  # Emails to receive requests from CDR side (separated by commas)
export SSL_CERT=   # Remote path to SSH certificate
export SSL_KEY=    # Remote path to SSH key
export IMAGE_DIR=  # Images directory
export MYSQL_HOST= # MySQL host
export DB_NAME=    # MySQL DB name
export MYSQL_USER= # MySQL user
export MYSQL_PASS= # MySQL password
export SMTP_HOST=  # SMTP host
export SMTP_PORT=  # SMTP port
export SMTP_USER=  # SMTP username
export SMTP_PASS=  # SMTP password
export SMTP_MAIL=  # Mail to send email from
export BACKEND=    # Local path to built backend
export FRONTEND=   # Local path to built frontend

Caddy stores SSL certificates and keys in /var/lib/caddy/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/${HOST}/

This variables are filled with the values of the previous ones and can be directly sourced:

export BACKEND_SRC=${BACKEND}
export FRONTEND_SRC=${FRONTEND}
export DOMAIN_NAME=${HOST}
export CDR_EMAILS=${CDR_MAILS}
export QUARKUS_HTTP_SSL_CERTIFICATE_FILE=${SSL_CERT}
export QUARKUS_HTTP_SSL_CERTIFICATE_KEY_FILE=${SSL_KEY}
export QUARKUS_HTTP_CORS=true
export QUARKUS_HTTP_CORS_ORIGINS=https://${HOST}
export QUARKUS_HTTP_CORS_METHODS=GET,PUT,POST,DELETE
export QUARKUS_HTTP_BODY_UPLOADS_DIRECTORY=${IMAGE_DIR}
export QUARKUS_DATASOURCE_REACTIVE_URL=mysql://${MYSQL_HOST}:3306/${DB_NAME}
export QUARKUS_DATASOURCE_USERNAME=${MYSQL_USER}
export QUARKUS_DATASOURCE_PASSWORD=${MYSQL_PASS}
export QUARKUS_MAILER_HOST=${SMTP_HOST}
export QUARKUS_MAILER_PORT=${SMTP_PORT}
export QUARKUS_MAILER_USERNAME=${SMTP_USER}
export QUARKUS_MAILER_PASSWORD=${SMTP_PASS}
export QUARKUS_MAILER_FROM=${SMTP_MAIL

Preparation

Currently only libvirt is supported

After deploying the VM, need to make sure the vagrant user belongs to the groups backend and frontend

Create an inventory file (inventory.yml) like this one:

all:
  hosts:
    test:
      ansible_connection: ssh
      ansible_host: 192.168.121.2
      ansible_user: vagrant

Running

ansible-playbook -i inventory.yml deploy.yml

Clone this wiki locally