Installing Ansible Forms on my Windows 11 Laptop

It is possible to install AnsibleForms on a Windows 11 laptop. Here's how we do it.

Part 1) Running Ubuntu

1.1) For the purposes of this walkthrough, confirm your Windows version is 11 - 22H2 (or better):

The best/easiest way to do this is to look in: System > About

Note: The following from PowerShell seemed to indicate my system was Windows 10, but clearly from the above it is not.

[System.Environment]::OSVersion.Version

slmgr /ldv

1.2) Install Microsoft Windows Subsystem Linux:

If you're using the version above (or better) this install is super simple. From Windows PowerShell running as an Administrator:

wsl --install

At the time of writing there are many distributions that can be installed (see Appendix), I went for:

wsl --install -d Ubuntu-22.04

1.3) Open up Ubuntu:

Search for Ubuntu and run (you can add it to your taskbar).


Note: I am using Ubuntu 22.04.13 LTS.

Part 2) Installing Ansible Forms on Ubuntu

Here we follow the steps from: AnsibleForms Docs - Installation

1) Choose a location to install:

sudo mkdir /srv/apps

cd /srv/apps

2) Clone the docker-compose project:

sudo apt-get install -y git

‌sudo ‌git init

sudo git clone https://github.com/ansibleguy76/ansibleforms-docker.git

cd ansibleforms-docker

3) Set proper permissions:

sudo chmod -R 664 ./data

sudo chmod -R +x ./data/mysql/init/

4) Install Docker and docker-compose

Note: This bit is different to the documentation, I hit the following errors running the command:

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

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package docker-ce is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'docker-ce' has no installation candidate
E: Unable to locate package docker-ce-cli
E: Unable to locate package containerd.io
E: Couldn't find any package by glob 'containerd.io'
E: Couldn't find any package by regex 'containerd.io'
E: Unable to locate package docker-buildx-plugin
E: Unable to locate package docker-compose-plugin

- so I found this on the internet: How to Install Docker Compose on Ubuntu 20.04

sudo apt update

sudo apt upgrade

sudo apt install docker-compose

The following additional packages will be installed: bridge-utils containerd dns-root-data dnsmasq-base docker.io pigz python3-attr python3-docker python3-dockerpty python3-docopt python3-dotenv python3-jsonschema python3-pyrsistent python3-texttable python3-websocket runc ubuntu-fan

Then we continue with the instructions from AnsibleForms Docs - Installation.

sudo mkdir -p /etc/docker

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

sudo systemctl start docker

sudo systemctl enable docker

An additional command to check if docker is running:

sudo systemctl show --property ActiveState docker

5) Customize

View (or customize)  docker-compose.yml:

user@PC:/srv/apps/ansibleforms-docker$ cat docker-compose.yml

6) Start docker-compose project

sudo docker-compose up -d

7) Test the application

To check the IP address of your Windows Subsystem for Linux VM from Windows PowerShell:

wsl hostname -I

To get the IP of the Windows machine as seen from WSL 2:

cat /etc/resolv.conf

Connect to https://SERVERIP:8443 and use the default login: admin / AnsibleForms!123


APPENDIX A: Current Windows Subsystem for Linux Distros

The following is a list of valid distributions that can be installed.
Install using 'wsl --install -d DISTRO'.

NAME
Ubuntu
Debian
kali-linux
Ubuntu-18.04
Ubuntu-20.04
Ubuntu-22.04
OracleLinux_7_9
OracleLinux_8_7
OracleLinux_9_1
openSUSE-Leap-15.5
SUSE-Linux-Enterprise-Server-15-SP4
SUSE-Linux-Enterprise-15-SP5
openSUSE-Tumbleweed

APPENDIX B: docker-compose.yml post install

user@PC:/srv/apps/ansibleforms-docker$ cat docker-compose.yml
version: '3.0'

services:
  # MySql Server
  mysqldb:
    image: mysql:8.1
    container_name: af_db
    restart: unless-stopped
    # load extra environment variables from file
    env_file: ./.env
    # Set manual environment variables
    environment:
      - MYSQL_ROOT_PASSWORD=$MYSQLDB_PASSWORD
      - MYSQL_DATABASE=AnsibleForms
    ports:
      # Mount host port to docker internal port
      - $MYSQLDB_LOCAL_PORT:$MYSQLDB_DOCKER_PORT
    volumes:
      # Map database location (to maintain persistency)
      - ./data/mysql/db:/var/lib/mysql
      # Map my.cnf file (to maintain persistency)
      - ./data/mysql/my.cnf:/etc/mysql/my.cnf
      # Map init sql scripts
      - ./data/mysql/init:/docker-entrypoint-initdb.d
  # AnsibleForms application
  app:
    # Only start after MySql
    depends_on:
      - mysqldb
    image: ansibleguy/ansibleforms:latest
    container_name: af_app
    restart: unless-stopped
    ports:
      # Mount host port to docker internal port
      - $WEBAPP_LOCAL_PORT:$WEBAPP_DOCKER_PORT
    # Load extra environment variables from file
    env_file:
      - ./.env
    # Set environment variables
    environment:
      - DB_HOST=mysqldb
      - DB_USER=$MYSQLDB_USER
      - DB_PASSWORD=$MYSQLDB_PASSWORD
      - DB_PORT=$MYSQLDB_DOCKER_PORT
      - PORT=$WEBAPP_DOCKER_PORT
      # adding python path to add our custom persistent lib location
      - PYTHONPATH=/usr/lib/python311.zip:/usr/lib/python3.11:/usr/lib/python3.11/lib-dynload:/usr/lib/python3.11/site-packages:/app/dist/persistent/python/lib
    # allow interactive shell
    stdin_open: true
    # allow terminal
    tty: true
    volumes:
      # Mount application folder to host folder (to maintain persistency)
      - ./data:/app/dist/persistent
      # Mount images folder to host folder (to have custom images)
      - ./data/images:/app/dist/views/assets/images
      # Mount logo (to have custom logo)
      #- ./data/images/mylogo.svg:/app/dist/views/assets/img/logo_ansible_forms_full_white.svg
      # Mount background image (to have custom background)
      #- ./data/bg.jpg:/app/dist/views/assets/img/bg.jpg
      # Map custom functions for js expressions and jq
      - ./data/functions/custom.js:/app/dist/src/functions/custom.js
      - ./data/functions/jq.custom.definitions.js:/app/dist/src/functions/jq.custom.definitions.js
      # Map custom sshkey to local node .ssh location
      - ./data/ssh:$HOME_DIR/.ssh
      - ./data/git/.gitconfig:$HOME_DIR/.gitconfig
      # Map custom ansible.cfg
      - ./data/ansible/ansible.cfg:/etc/ansible/ansible.cfg
      - ./data/ansible/roles:/etc/ansible/roles
      - ./data/ansible/collections:/etc/ansible/collections

Comments