Docker Compose

Install AnsibleForms and MySQL together with docker-compose or podman-compose

  1. Prerequisites
  2. Choose a location to install
  3. Clone the docker-compose project
  4. Set proper permissions
  5. Install a container engine
  6. Customize
  7. Start docker-compose project
  8. Test the application
  9. File structure

The docker-compose project (its v6 branch, for AnsibleForms 6) contains both containers, their settings and sample forms, so the only other requirement is Docker or Podman with its compose tool.


Prerequisites

Before you start, you need:

  • Linux machine : any distribution, with modest CPU and memory
  • GitHub access : to download or clone the docker-compose project from GitHub
  • Docker or Podman : a container engine, installed below
  • A compose tool : Docker Compose or podman-compose, to start AnsibleForms and MySQL from a few configuration files

New to containers? Using Docker and docker-compose for the first time requires some basic Linux skills and some knowledge about containers. Download this document to get started with containers and Docker.

VIDEO: How to install AnsibleForms


Choose a location to install

Create a folder for the project; the examples use /srv/apps:

sudo mkdir /srv/apps
cd /srv/apps

Clone the docker-compose project

Install Git:

sudo apt-get install -y git

Then clone the v6 branch of the docker-compose project into that folder:

sudo git clone -b v6 https://github.com/ansibleforms/docker.git ansibleforms-docker
cd ansibleforms-docker

Set proper permissions

Give the application write access to the data folder:

# write access will be needed on the datafolder
sudo chmod -R u+rwX,g+rwX ./data

Install a container engine

Install Docker or Podman, each with its compose tool:

Install Docker Engine with the Compose plugin from Docker’s repository (see the Docker installation manuals):

# Docker's own apt repository
sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
  https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
  | sudo tee /etc/apt/sources.list.d/docker.list

sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Then let names resolve inside the containers, and start Docker as a service:

sudo mkdir -p /etc/docker
echo "{\"dns-opts\":[\"ndots:15\"]}" | sudo tee /etc/docker/daemon.json
sudo systemctl enable --now docker

Customize

Review the variables in the .env and docker-compose.yml files and adjust them as needed. Learn more about the environment variables


Start docker-compose project

Start MySQL and AnsibleForms in the background:

sudo docker compose up -d
# with the older standalone tool : sudo docker-compose up -d

Test the application

Once the containers are up, open AnsibleForms in a browser:

  • Open https://your_ip (port 443, see WEBAPP_LOCAL_PORT in the .env file)
  • Log in as admin / AnsibleForms!123 (or with the password you chose in the .env file)
  • Next steps:
    • Create forms by adding YAML files to the data/forms/ folder or by using the built-in designer
    • Add your playbooks to the data/playbooks/ folder
    • Add an LDAP connection
    • Add users and groups
    • Add an AWX connection
    • Add credentials for external connections, such as other MySQL servers or REST APIs, or to pass to Ansible playbooks
    • Connect Git repositories and choose whether your forms and/or playbooks sync with a repository

File structure

The docker-compose project has the following folder structure:

.
├── docker-compose.yml # the AnsibleForms and MySQL containers
├── .env # the settings, see the variables below
└── data # everything that must survive an upgrade
    ├── ansible # ansible.cfg, plus roles and collections you install
    ├── forms # 1 or more yaml files with forms
    ├── functions # custom javascript functions
    ├── git # .gitconfig for repository connections
    ├── mysql
    │   ├── my.cnf # MySQL settings
    │   └── db # the database files (created at first start)
    ├── playbooks # your ansible playbooks
    ├── repositories # local clones of your git repositories
    ├── ssh # the client sshkey (created at first start)
    ├── config.yaml # categories, roles and constants
    ├── certificates # self-signed certificates (created at first start) - replace with your own
    ├── logs # the logfiles (created at first start)
    ├── backups # database backups (created when needed)
    └── forms_backups # form backups (created when needed)