This project provides an ServiceNow-Airflow-PCD based workflow for requesting, approving, and provisioning OpenStack VMs using either ServiceNow or a simple Flask application as a frontend and admin approval process.
dags/: Contains Airflow DAGs (notablyvm_creator_notify.py).approval_server.py: Flask server for handling approval/denial of VM requests.frontend_portal.py: Flask frontend for users to request VMs.templates/form.html: HTML form that the frontend portal uses for VM request.clouds.yaml: OpenStack cloud configuration (seeclouds.yaml.templatefor format)..env: Environment variables for configuration..jwt_token: JWT token for Airflow API authentication.run_airflow.sh: Script to start all Airflow components.
-
Install Airflow in a virtual environment and configure it
1.1 Install airflow and clone this repo.
./setup.sh1.2 Add Fab auth manager if we want to authenticate to the airflow API using token.
vim airflow.cfg [...] auth_manager = airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager1.3 Add JWT token secret key, again only required when authenticating to airflow API using token(like from servicenow). For this first create two random keys and then add those keys in the
airflow.cfgas below.$ python3 -c "import secrets; print(secrets.token_urlsafe(32))" BJ4_k41L1FHGVfkEWACT_HvrmI_ZOkyxT4sNPIHqG_o $ python3 -c "import secrets; print(secrets.token_urlsafe(32))" qT_CoJ_Cwc7uJNZCys03y57SNhEs3y_Ch3rnEv-6gLw $ vim airflow.cfg [...] secret_key = qT_CoJ_Cwc7uJNZCys03y57SNhEs3y_Ch3rnEv-6gLw jwt_secret = BJ4_k41L1FHGVfkEWACT_HvrmI_ZOkyxT4sNPIHqG_o1.4 Setup airflow database
$ airflow db migrate1.5 Create a user
$ airflow users create \ --username niket \ --firstname Niket \ --lastname Chavan \ --role Admin \ --email niket@pf9.com [...] Password: Repeat for confirmation: [2025-07-30T06:43:49.343+0000] {override.py:1362} INFO - Added user niket User "niket" created with role "Admin" -
Configure environment
Copy.env.templateto.envand fill in the required values. -
Configure OpenStack clouds
Copyclouds.yaml.templatetoclouds.yamland fill in your OpenStack cloud details. -
Start Airflow, approval server and the frontend portal
$ sudo systemctl start airflow.service airflow-approval-server.service airflow-frontend-portal.service -
Access the airflow using (default: localhost-ip:8080), login with the user create above and Configured SMTP in Airflow for email notifications.
Admin --> Connections --> Add Connection
NOTE: Add your respective SMTP host, credentials and port details.
NOTE: In the 'From email' field add the respective emaid id as per configured SMTP. It will act as the source email id.
- Visit the frontend portal (default: http://localhost-IP:5050) to request a VM.
- Admin(ADMIN_EMAIL in .env file) receives an approval email and can approve/deny via provided links.
- Upon approval, the VM is provisioned and the user is notified by email.
- The Airflow DAG ID and other settings are controlled via the
.envfile. - The approval server and frontend portal ports can be customized in
.env. - When working with ServiceNow, the frontend portal will be replaced with servicenow form.
- Setting up ServiceNow is a completely different process and is out of scope for this airflow setup.