**Purpose**: Once AWX is deployed, you will want to connect Gitea at https://git.bunny-lab.io.  The reason for this is so we can pull in our playbooks, inventories, and templates automatically into AWX, making it more stateless overall and more resilient to potential failures of either AWX or the underlying Kubernetes Cluster hosting it.

## Obtain Gitea Token
You already have this documented in Vaultwarden's password notes for awx.bunny-lab.io, but in case it gets lost, go to the [Gitea Token Page](https://git.bunny-lab.io/user/settings/applications) to set up an application token with read-only access for AWX, with a descriptive name.

## Create Gitea Credentials
Before you make move on and make the project, you need to associate the Gitea token with an AWX "Credential".  Navigate to **Resources > Credentials > Add**

| **Field** | **Value** |
| :--- | :--- |
| Credential Name | `git.bunny-lab.io` |
| Description | `Gitea` |
| Organization | `Default` *(Click the Magnifying Lens)* |
| Credential Type | `Source Control` |
| Username | `Gitea Username` *(e.g. `nicole`)* |
| Password | `<Gitea Token>` |

## Create an AWX Project
In order to link AWX to Gitea, you have to connect the two of them together with an AWX "Project".  Navigate to **Resources > Projects > Add**

**Project Variables**:

| **Field** | **Value** |
| :--- | :--- |
| Project Name | `Bunny-Lab` |
| Description | `Homelab Environment` |
| Organization | `Default` |
| Execution Environment | `AWX EE (latest)` *(Click the Magnifying Lens)* |
| Source Control Type | `Git` |

**Gitea-specific Variables**:

| **Field** | **Value** |
| :--- | :--- |
| Source Control URL | `https://git.bunny-lab.io/GitOps/awx.bunny-lab.io.git` |
| Source Control Branch/Tag/Commit | `main` |
| Source Control Credential | `git.bunny-lab.io` *(Click the Magnifying Lens)* |

## Add Playbooks
AWX automatically imports any playbooks it finds from the project, and makes them available for templates operating within the same project-space.  (e.g. "Bunny-Lab").  This means no special configuration is needed for the playbooks.

## Create an Inventory
You will want to associate an inventory with the Gitea project now.  Navigate to **Resources > Inventories > Add**

| **Field** | **Value** |
| :--- | :--- |
| Inventory Name | `Homelab` |
| Description | `Homelab Inventory` |
| Organization | `Default` |

### Add Gitea Inventory Source
Now you will want to connect this inventory to the inventory file(s) hosted in the aforementioned Gitea repository.  Navigate to **Resources > Inventories > Homelab > Sources > Add**

| **Field** | **Value** |
| :--- | :--- |
| Source Name | `git.bunny-lab.io` |
| Description | `Gitea` |
| Execution Environment | `AWX EE (latest)` *(Click the Magnifying Lens)* |
| Source | `Sourced from a Project` |
| Project | `Bunny-Lab` |
| Inventory File | `inventories/homelab.ini` |

Check the box at the bottom named "**Update on Launch**".  This will pull the latest inventory each time a job is run.  It may slightly slow down jobs, but it ensures that everything is updated every time a job is ran.



## Webhooks
Optionally, set up webhooks in Gitea to trigger inventory updates in AWX upon changes in the repository.  This section is not documented yet, but will eventually be documented.