Skip to content
ansibleformsPublic

About

A Docker Compose setup for AnsibleForms

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

 

History

49 Commits

Folders and files

Repository files navigation

AnsibleForms Docker Compose

CI License Docs

A Docker Compose setup that runs AnsibleForms with its MySQL database, sample playbooks and sample forms, so docker and docker compose are all you need to get started. The full installation guide is at ansibleforms.com.

Versions

Each branch pins one AnsibleForms major, so a setup never jumps on its own; read Upgrading to 7 before moving up.

Branch Image
main ghcr.io/ansibleforms/ansibleforms:7
v6 ghcr.io/ansibleforms/ansibleforms:6

Every AnsibleForms release also tags this repository as vX.Y.Z, so the setup of a version can be taken exactly as it was.

Images live on GHCR only; ansibleguy/ansibleforms on Docker Hub is no longer updated.

Getting started

Clone the repository, review the settings in .env (change every password), and start the stack. The app then listens on https://localhost with a self-signed certificate; log in as admin with the ADMIN_PASSWORD of .env. While that is still the public default, AnsibleForms!123, the app first asks you to choose a new password.

git clone https://github.com/ansibleforms/docker.git ansibleforms
cd ansibleforms
sudo chown -R 1000:1000 data
sed -i "s/^ENGINE_SOCKET_GID=.*/ENGINE_SOCKET_GID=$(stat -c %g /var/run/docker.sock)/" .env
docker compose up -d

The app and the RTE run as the user node (uid 1000), so they need to own data/: that is what the chown is for. The RTE starts each job's container through Docker's socket, so it joins the socket's group: that is what the sed is for. Coming from 6, whose container ran as root, run the same chown once before you start 7; MySQL takes its own folder back when it starts.

What you get

Everything under data/ is mounted into the containers and survives a restart or an upgrade.

  • A demo config.yaml with categories, roles and constants, and sample forms
  • Sample maintenance playbooks and a dummy.yaml playbook
  • Sample custom JavaScript functions and jq definitions to extend AnsibleForms
  • An RTE Runner that runs each playbook in a container of its own, with ansible, Python 3 and a set of Galaxy collections
  • A config seed, data/seed.yaml, that registers the RTE as the default runner

Database

The app connects to MySQL as ansibleforms (MYSQLDB_USER in .env), with all rights on the AnsibleForms schema and none elsewhere: a hole in the app then stays a hole in its own data. Root (MYSQLDB_ROOT_PASSWORD) is for MySQL.

MySQL creates that user on its first start only. An install that has connected as root so far keeps its database, so create the user once, with the password you set in MYSQLDB_PASSWORD, before you start it with this .env:

docker compose up -d mysqldb
docker compose exec mysqldb mysql -uroot -p -e "CREATE USER 'ansibleforms'@'%' IDENTIFIED BY '<MYSQLDB_PASSWORD>';
  GRANT ALL PRIVILEGES ON AnsibleForms.* TO 'ansibleforms'@'%';"

MySQL 9.7 LTS

main runs MySQL 9.7, the LTS that follows 8.4; the v6 branch stays on 8.4. A setup on 8.4 upgrades in place on its first start with 9.7, as MySQL supports moving to the next LTS, once these steps are done while it still runs 8.4.

  1. Back up the database (data/mysql/db), as before any upgrade.

  2. List the users still signing in with mysql_native_password, which MySQL 9 no longer has, and move each of them to caching_sha2_password with its own password:

    docker compose exec mysqldb mysql -uroot -p -e "SELECT user, host FROM mysql.user WHERE plugin='mysql_native_password';"
    docker compose exec mysqldb mysql -uroot -p -e "ALTER USER '<user>'@'<host>' IDENTIFIED WITH caching_sha2_password BY '<its password>';"
  3. Remove the line mysql_native_password=ON from data/mysql/my.cnf: MySQL 9 refuses to start with it.

  4. Pull this version of the setup and start it again: docker compose pull && docker compose up -d.

Running playbooks

AnsibleForms 7 runs no playbook in the app: the rte container, the RTE Runner, starts each job in a container of its own from ghcr.io/ansibleforms/ansibleforms-rte-full:7 (RTE_IMAGE). The app dials it on http://rte:8000 with RTE_TOKEN from .env and keeps one WebSocket open (RTE_MODE=inbound): the RTE gets no database credentials, and is not published on the host.

It starts the jobs through the engine's socket (ENGINE_SOCKET in .env), which gives it that engine's full rights on this host. With Podman, set RTE_ENGINE=podman and ENGINE_SOCKET to Podman's socket (/run/podman/podman.sock, or /run/user/<uid>/podman/podman.sock rootless, with RTE_USER=0).

data/seed.yaml registers it as the default runner on every start, so it is read-only under Connections > Runners. Ansible settings, roles and collections under data/ansible/, the SSH key, the libraries the pip install playbook adds, and the vars files and uploads (read-only, at their paths in the app) are mounted into every job (RTE_JOB_MOUNTS), not the app. When your playbooks need more, build an image FROM ansibleforms-rte-core or ansibleforms-rte-full and set it as RTE_IMAGE: ansibleforms/rte shows how.

Several nodes

scale/ runs AnsibleForms on several nodes: two controller nodes behind nginx, two workers (one waiting), a runner and a database. Its README says what the nodes share, how they behave and how to upgrade them.

Kubernetes

For Kubernetes, use the Helm chart in ansibleforms/helm-charts instead.

Contributing

Contributions are welcome. Start with these files:

License

GPL-3.0.

About

A Docker Compose setup for AnsibleForms

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

1 watching

Forks

Contributors

Languages