Skip to content

Commit 0c4bab4

Browse files
chore: Execution Environment container image is now built on version release #26
1 parent b7cd960 commit 0c4bab4

5 files changed

Lines changed: 113 additions & 2 deletions

File tree

.github/workflows/ee.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
name: CI
3+
4+
defaults:
5+
run:
6+
shell: bash
7+
8+
on:
9+
push:
10+
tags:
11+
- 'v[0-9]+.[0-9]+.[0-9]+' # Matches tags like v1.0.0, v2.1.5, etc. This CI gets triggered by Semantic release.
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
26+
with:
27+
python-version: 3.11
28+
29+
- name: Install Ansible Builder
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install ansible-builder
33+
34+
- name: Build docker context
35+
run: |
36+
ansible-builder create -f meta/execution-environment.yml --output-filename Dockerfile
37+
38+
- name: login to GHCR
39+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 #v3
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: List directories
46+
run: |
47+
ls -l ./context
48+
49+
# produce docker tags for semver if on a tag, otherwise take ref branch name
50+
# latest tag is only produced for semver operating on a tag
51+
- name: determine docker tags and labels
52+
id: meta
53+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5
54+
with: # labels and annotations are overwritten for image.title information
55+
context: git # git - this ensures to reference the current git context instead of workflow context (context info ref/sha)
56+
images: ghcr.io/paloaltonetworks/panos_policy_automation-rhel9
57+
tags: |
58+
type=semver,pattern=v{{version}}
59+
type=semver,pattern=v{{major}}.{{minor}}
60+
type=semver,pattern=v{{major}}
61+
type=ref,event=branch
62+
type=ref,event=tag
63+
labels: |
64+
org.opencontainers.image.title=panos_policy_automation-rhel9
65+
annotations: |
66+
org.opencontainers.image.title=panos_policy_automation-rhel9
67+
68+
- name: build and publish
69+
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
70+
with:
71+
context: "./context/"
72+
file: "./context/Dockerfile"
73+
push: true
74+
tags: ${{ steps.meta.outputs.tags }}
75+
labels: ${{ steps.meta.outputs.labels }}
76+
cache-from: type=gha
77+
cache-to: type=gha,mode=max
78+
provenance: ${{ inputs.release }}

.github/workflows/release_to_galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Release to Ansible repositories
44
on:
55
push:
66
tags:
7-
- 'v[0-9]+.[0-9]+.[0-9]+' # Matches tags like v1.0.0, v2.1.5, etc. Note currently is not triggered by semantic release
7+
- 'v[0-9]+.[0-9]+.[0-9]+' # Matches tags like v1.0.0, v2.1.5, etc. This CI gets triggered by Semantic release.
88
workflow_dispatch:
99
permissions:
1010
contents: write

docs/user_guide/demo_walkthrough.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ CCTV
1919

2020
Example Web to DB
2121

22+
Run the lookup first
2223
```shell
23-
ansible-playbook -i inventory_real.yml --extra-vars=@example_vars_file_web_to_db.yml example_playbook.yml
24+
ansible-playbook -i inventory_real.yml --extra-vars=@./example_vars_file_web_to_db.yml paloaltonetworks.panos_policy_automation.examples.lookup_policy
2425
```
2526

27+
Then, run creation
28+
29+
```shell
30+
ansible-playbook -i inventory_real.yml --extra-vars=@./example_vars_file_web_to_db.yml paloaltonetworks.panos_policy_automation.examples.create_policy
31+
```

meta/ee-requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
setuptools
2+
netaddr>=1.3.0
3+
dpath>=2.1.5,<3.0 ; python_version >= "3.10" and python_version < "4.0"
4+
pan-os-python>=1.8,<2.0 ; python_version >= "3.10" and python_version < "4.0"
5+
panos-upgrade-assurance>=1.4,<2.0 ; python_version >= "3.10" and python_version < "4.0"
6+
xmltodict>=0.12.0,<0.15.0 ; python_version >= "3.10" and python_version < "4.0"

meta/execution-environment.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
version: 3
3+
4+
images:
5+
base_image:
6+
name: registry.access.redhat.com/ubi10/ubi:latest
7+
8+
dependencies:
9+
python: ee-requirements.txt
10+
galaxy:
11+
collections:
12+
- community.general
13+
- name: ansible.posix
14+
- name: ansible.utils
15+
- name: paloaltonetworks.panos_policy_automation
16+
ansible_core:
17+
package_pip: ansible-core>=2.16.0,<2.17
18+
ansible_runner:
19+
package_pip: ansible-runner
20+
build_arg_defaults:
21+
ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: '--ignore-certs'

0 commit comments

Comments
 (0)