Skip to content

Commit 8daf86e

Browse files
tpaulusCopilot
andcommitted
Automate AWX EE builds
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 81fc670 commit 8daf86e

File tree

6 files changed

+122
-1
lines changed

6 files changed

+122
-1
lines changed

.github/workflows/build-awx-ee.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: Build AWX Execution Environment
3+
on:
4+
workflow_dispatch: {}
5+
push:
6+
branches: [main]
7+
paths:
8+
- awx/ee/**
9+
- .github/workflows/build-awx-ee.yml
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- awx/ee/**
14+
- .github/workflows/build-awx-ee.yml
15+
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
env:
21+
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/ansible-ee
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
31+
32+
- name: Log in to GHCR
33+
if: github.event_name != 'pull_request'
34+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract image metadata
41+
id: meta
42+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
43+
with:
44+
images: ${{ env.IMAGE_NAME }}
45+
tags: |
46+
type=raw,value=latest,enable={{is_default_branch}}
47+
type=sha,prefix=sha-
48+
49+
- name: Build and push image
50+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
51+
with:
52+
context: awx/ee
53+
platforms: linux/amd64
54+
pull: true
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

awx/bootstrap.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ data:
2424
ORGANIZATION_NAME = os.environ.get("AWX_ORGANIZATION_NAME", "Whitestar Systems")
2525
PROJECT_NAME = os.environ.get("AWX_PROJECT_NAME", "tpaulus/ansible")
2626
PROJECT_URL = os.environ.get("AWX_PROJECT_URL", "https://github.com/tpaulus/ansible.git")
27+
EXECUTION_ENVIRONMENT_NAME = os.environ.get("AWX_EXECUTION_ENVIRONMENT_NAME", "tpaulus/ansible-ee")
28+
EXECUTION_ENVIRONMENT_IMAGE = os.environ.get("AWX_EXECUTION_ENVIRONMENT_IMAGE", "ghcr.io/tpaulus/ansible-ee:latest")
2729
INVENTORY_NAME = os.environ.get("AWX_INVENTORY_NAME", "NetBox")
2830
INVENTORY_SOURCE_NAME = os.environ.get("AWX_INVENTORY_SOURCE_NAME", "NetBox inventory")
2931
JOB_TEMPLATE_NAME = os.environ.get("AWX_JOB_TEMPLATE_NAME", "Provision all")
@@ -249,6 +251,17 @@ data:
249251
250252
wait_for_project_update(project["id"], "provision/all.yaml")
251253
254+
execution_environment = upsert(
255+
"execution_environments/",
256+
EXECUTION_ENVIRONMENT_NAME,
257+
{
258+
"name": EXECUTION_ENVIRONMENT_NAME,
259+
"description": "Custom EE for tpaulus/ansible and NetBox inventory.",
260+
"image": EXECUTION_ENVIRONMENT_IMAGE,
261+
"pull": "always",
262+
},
263+
)
264+
252265
inventory = upsert(
253266
"inventories/",
254267
INVENTORY_NAME,
@@ -275,6 +288,7 @@ data:
275288
"overwrite_vars": True,
276289
"update_on_project_update": True,
277290
"update_cache_timeout": 0,
291+
"execution_environment": execution_environment["id"],
278292
},
279293
matcher=lambda item: item.get("name") == INVENTORY_SOURCE_NAME and item.get("inventory") == inventory["id"],
280294
)
@@ -290,6 +304,7 @@ data:
290304
"playbook": "provision/all.yaml",
291305
"job_type": "run",
292306
"limit": LIMIT,
307+
"execution_environment": execution_environment["id"],
293308
"ask_limit_on_launch": True,
294309
"ask_inventory_on_launch": False,
295310
"ask_credential_on_launch": True,
@@ -341,6 +356,10 @@ spec:
341356
value: tpaulus/ansible
342357
- name: AWX_PROJECT_URL
343358
value: https://github.com/tpaulus/ansible.git
359+
- name: AWX_EXECUTION_ENVIRONMENT_NAME
360+
value: tpaulus/ansible-ee
361+
- name: AWX_EXECUTION_ENVIRONMENT_IMAGE
362+
value: ghcr.io/tpaulus/ansible-ee:latest
344363
- name: AWX_INVENTORY_NAME
345364
value: NetBox
346365
- name: AWX_INVENTORY_SOURCE_NAME

awx/ee/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM quay.io/ansible/awx-ee:24.6.1
2+
3+
USER root
4+
5+
COPY requirements.yml /tmp/requirements.yml
6+
COPY requirements.txt /tmp/requirements.txt
7+
8+
RUN python3 -m pip install --no-cache-dir -r /tmp/requirements.txt && \
9+
ansible-galaxy collection install -r /tmp/requirements.yml && \
10+
ansible-galaxy role install -r /tmp/requirements.yml && \
11+
rm -f /tmp/requirements.yml /tmp/requirements.txt

awx/ee/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pynetbox

awx/ee/requirements.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
collections:
3+
- name: community.general
4+
version: 12.4.0
5+
- name: ansible.posix
6+
version: 2.1.0
7+
- name: ansible.utils
8+
version: 6.0.1
9+
- name: arensb.truenas
10+
version: 1.14.4
11+
- name: netbox.netbox
12+
version: 3.22.0
13+
- name: prometheus.prometheus
14+
version: 0.28.0
15+
16+
roles:
17+
- name: xanmanning.k3s
18+
version: v3.6.2

renovate.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,27 @@
1616
"/argocd/applications/.+\\.yaml$/"
1717
]
1818
},
19+
"ansible-galaxy": {
20+
"managerFilePatterns": [
21+
"/awx/ee/requirements\\.yml$/"
22+
]
23+
},
24+
"pip_requirements": {
25+
"managerFilePatterns": [
26+
"/awx/ee/requirements\\.txt$/"
27+
]
28+
},
1929
"platformAutomerge": true,
2030
"automergeType": "branch",
2131
"ignoreTests": true,
2232
"packageRules": [
2333
{
2434
"matchManagers": [
2535
"kubernetes",
26-
"argocd"
36+
"argocd",
37+
"ansible-galaxy",
38+
"pip_requirements",
39+
"dockerfile"
2740
],
2841
"major": {
2942
"automerge": false

0 commit comments

Comments
 (0)