-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
116 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
- Added install script | ||
|
||
#### **Thread Safety** 🔒 | ||
- Jobs are now also being saved to disk | ||
- `/jobs` endpoint now pulls all infos from saved JSON files | ||
- (potentially **BREAKING**) saved jobs now only use their UUID as name (`jq` can be used to filter easily) | ||
|
||
#### **WSGI** 🌐 | ||
- Minor import refactor | ||
- WSGI default file | ||
- changed README for gunicorn | ||
#### General 🚀 | ||
- Install script now sets up a production-ready installation of ansible-link | ||
- Fetches the latest version of ansible-link from GitHub | ||
- Includes Gunicorn for handling requests | ||
- Configures Unix sockets for communication | ||
- Sets up a Python virtual environment (venv) | ||
- Updated README for install script instructions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,34 +28,33 @@ | |
Searched for a way to run our playbooks automated without the need of AWX or other big projects while still being more stable and less error-prone than custom bash scripts. So I made Ansible-Link. This projects aims to be a KISS way to run ansible jobs remotely. Essentially a RESTful API sitting on top of [ansible-runner](https://github.com/ansible/ansible-runner). | ||
|
||
## Prerequisites | ||
* Python 3.7+ | ||
* PIP | ||
* Your Ansible node | ||
|
||
## Installation | ||
* Clone the repository (on your ansible-node): | ||
```shell | ||
git clone [email protected]:lfkdev/ansible-link.git | ||
cd ansible-link | ||
``` | ||
The fastest way to set up Ansible-Link is by using the provided `install.sh` script: | ||
|
||
* Install the dependencies: | ||
```shell | ||
# use virtual env | ||
pip install -r requirements.txt | ||
``` | ||
1. **Download and run the install script:** | ||
```shell | ||
wget https://raw.githubusercontent.com/lfkdev/ansible-link/main/install.sh -O - | sudo bash | ||
``` | ||
|
||
This script will: | ||
- Check for necessary dependencies and install them if missing. | ||
- Download and install Ansible-Link. | ||
- Set up a Python virtual environment. | ||
- Configure a systemd service for Ansible-Link. | ||
|
||
After the installation, you can start using Ansible-Link immediately. You probably need to change some config values for your ansible environment `/opt/ansible-link/config.yml` | ||
|
||
* Set config values in `config.yml` | ||
```yaml | ||
playbook_dir: '/etc/ansible/' | ||
inventory_file: '/etc/ansible/environments/hosts' | ||
... | ||
``` | ||
|
||
* Start Ansible-Link | ||
```shell | ||
python3 ansible_link/ansible_link.py | ||
``` | ||
The API will be accessible at localhost:port (default 5001) or wherever you bind it to. | ||
To add more workers or change the user, modify `/etc/systemd/system/ansible-link.service` | ||
> ⚠️ **Note:** Currently, only Ubuntu versions 16.04 and higher, or Debian versions 9 and higher are officially supported. | ||
> Other operating systems might also work but have not been tested. You can clone the repository and perform a manual installation if you are using a different OS. | ||
|
||
## API Documentation | ||
The API documentation is available via the Swagger UI. | ||
|
@@ -128,20 +127,26 @@ Leave empty to allow all playbooks. This is for the backend, you could also use | |
|
||
## Prod environment | ||
|
||
**Use WSGI for prod ENV (gunicorn) + systemd service** | ||
You can use the install script `install.sh` to get a production-ready environment for Ansible-Link. | ||
|
||
The install script will: | ||
- Set up a Python VENV | ||
- Configure a systemd service to manage Ansible-Link | ||
- Utilize Gunicorn as the WSGI server. | ||
|
||
You can use a webserver like Caddy to add Basic Authentication and TLS to your Ansible-Link setup. | ||
|
||
### unitd example file | ||
### unitD example | ||
``` | ||
[Unit] | ||
Description=Ansible Link | ||
Description=Ansible Link Service | ||
After=network.target | ||
[Service] | ||
User=ansible | ||
Group=ansible | ||
WorkingDirectory=/opt/ansible-link | ||
ExecStart=/usr/local/bin/gunicorn -w 1 -k gthread -b localhost:5000 wsgi:app | ||
Restart=on-failure | ||
ExecStart=$VENV_DIR/bin/gunicorn --workers 1 --bind unix:$INSTALL_DIR/ansible_link.sock -m 007 wsgi:application | ||
WorkingDirectory=$INSTALL_DIR | ||
Restart=always | ||
User=root | ||
[Install] | ||
WantedBy=multi-user.target | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
VERSION = "2.1.1" | ||
VERSION = "2.1.2" | ||
|
||
def get_version(): | ||
return VERSION |