33
44The ` ansible-creator init execution_env ` command scaffolds a complete
55Execution Environment (EE) project, including the EE definition file, a
6- GitHub Actions CI/CD workflow, and optional configuration for Ansible Galaxy
7- servers.
6+ CI/CD workflow for ** GitHub Actions ** (default) or ** GitLab CI ** , and optional
7+ configuration for Ansible Galaxy servers.
88
99## Quick start
1010
1111``` console
1212ansible-creator init execution_env my-ee-project
1313```
1414
15- This produces:
15+ This produces a GitHub Actions–based project :
1616
1717``` text
1818my-ee-project/
@@ -24,6 +24,38 @@ my-ee-project/
2424└── execution-environment.yml
2525```
2626
27+ ### GitLab instead of GitHub
28+
29+ Use ` --scm-provider gitlab ` to scaffold ` .gitlab-ci.yml ` instead of
30+ ` .github/workflows/ee-build.yml ` :
31+
32+ ``` console
33+ ansible-creator init execution_env --scm-provider gitlab my-ee-gitlab
34+ ```
35+
36+ ``` text
37+ my-ee-gitlab/
38+ ├── .gitlab-ci.yml
39+ ├── .gitignore
40+ ├── README.md
41+ └── execution-environment.yml
42+ ```
43+
44+ Galaxy and SCM tokens use the ** same variable names** as in the GitHub
45+ workflow (` ANSIBLE_GALAXY_SERVER_<ID>_TOKEN ` , plus each
46+ ` scm_servers[*].token_env_var ` ). Configure them under ** Settings →
47+ CI/CD → Variables** (mark secrets as masked/protected). For pushes to
48+ GitLab Container Registry you can rely on the predefined
49+ ` CI_REGISTRY_USER ` / ` CI_REGISTRY_PASSWORD ` , or set
50+ ` REGISTRY_USERNAME ` / ` REGISTRY_PASSWORD ` for another registry. See
51+ [ GitLab CI pipeline] ( #gitlab-ci-pipeline-gitlab-ciyml ) .
52+
53+ You can add the same CI files to an existing directory with:
54+
55+ ``` console
56+ ansible-creator add resource ee-ci --scm-provider gitlab /path/to/project
57+ ```
58+
2759## Configuration
2860
2961EE projects can be customized via CLI flags, inline JSON
@@ -153,12 +185,13 @@ If `galaxy_servers` is empty and no `ansible_cfg` is provided, no
153185
154186#### Token workflow integration
155187
156- For each server with ` token_required: true ` , the scaffolded
157- ` ee-build.yml ` workflow :
188+ For each server with ` token_required: true ` , the scaffolded workflow
189+ (GitHub Actions ` ee-build.yml ` or GitLab ` .gitlab-ci.yml ` ) :
158190
1591911 . Checks whether the corresponding ` ANSIBLE_GALAXY_SERVER_<ID>_TOKEN `
160- secret is configured.
161- 2 . Passes the token as a ` --build-arg ` to ` buildah bud ` .
192+ is configured (repository ** secret** on GitHub, ** CI/CD variable** on
193+ GitLab).
194+ 2 . Passes the token as a ` --build-arg ` to ` podman build ` / ` buildah bud ` .
1621953 . Declares a matching ` ARG ` directive in the EE definition's
163196 ` prepend_galaxy ` section.
164197
@@ -191,7 +224,7 @@ SCM provider or organization:
191224| -------| ----------| -------------|
192225| ` id ` | yes | Identifier (lowercase letters, numbers, underscores) |
193226| ` hostname ` | yes | Git server hostname (e.g. ` github.com ` ) |
194- | ` token_env_var ` | yes | Environment variable name for the token. Must start with an uppercase letter and contain only uppercase letters, digits, and underscores (e.g. ` GITHUB_ORG1_TOKEN ` ). This name is used as the GitHub Actions secret name. |
227+ | ` token_env_var ` | yes | Environment variable name for the token. Must start with an uppercase letter and contain only uppercase letters, digits, and underscores (e.g. ` GITHUB_ORG1_TOKEN ` ). This name is used as the GitHub Actions secret name or the GitLab CI/CD variable name . |
195228
196229#### Collection URL naming convention
197230
@@ -222,8 +255,9 @@ In the example above, `${GITHUB_ORG1_TOKEN}` in the collection URL
222255matches the ` token_env_var ` of the ` github_org1 ` SCM server entry.
223256The workflow will:
224257
225- 1 . Expect a GitHub Actions secret named ` GITHUB_ORG1_TOKEN `
226- 2 . Validate the secret is configured before building
258+ 1 . Expect a GitHub Actions secret or GitLab CI/CD variable named
259+ ` GITHUB_ORG1_TOKEN `
260+ 2 . Validate it is configured before building
2272613 . Resolve ` ${GITHUB_ORG1_TOKEN} ` in the generated requirements file
228262 via ` envsubst `
229263
@@ -343,18 +377,50 @@ This creates:
343377 ` ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_TOKEN ` secret and passes it as
344378 a build arg.
345379
380+ The same ` --ee-config ` with ` --scm-provider gitlab ` swaps the last item
381+ for ` .gitlab-ci.yml ` (and omits ` .github/workflows/ ` ):
382+
383+ ``` console
384+ ansible-creator init execution_env \
385+ --scm-provider gitlab \
386+ --ee-config '{
387+ "name": "ee-network",
388+ "base_image": "registry.redhat.io/ansible-automation-platform-25/ee-minimal-rhel8:latest",
389+ "collections": [
390+ {"name": "cisco.ios"},
391+ {"name": "ansible.netcommon"}
392+ ],
393+ "galaxy_servers": [
394+ {
395+ "id": "automation_hub",
396+ "url": "https://console.redhat.com/api/automation-hub/content/published/",
397+ "auth_url": "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token",
398+ "token_required": true
399+ },
400+ {
401+ "id": "galaxy",
402+ "url": "https://galaxy.ansible.com/"
403+ }
404+ ]
405+ }' \
406+ my-ee-gitlab
407+ ```
408+
346409## CI/CD workflow
347410
348- The scaffolded ` ee-build.yml ` workflow builds and publishes the EE image.
411+ Scaffolded pipelines build and publish the EE image using ** podman** (GitLab)
412+ or ** buildah** (GitHub), with the same token and ` envsubst ` model.
349413
350- ### Triggers
414+ ### GitHub Actions (` ee-build.yml ` )
415+
416+ #### Triggers
351417
352418- ** Pull requests** to ` main ` /` master ` — build only (no push).
353419- ** Push** to ` main ` /` master ` — build, push with ` latest ` and SHA tags.
354420- ** Release** — tag with the release version and ` prd ` .
355421- ** Manual** (` workflow_dispatch ` ) — with optional skip-validation toggle.
356422
357- ### Required secrets
423+ #### Required secrets
358424
359425Galaxy server tokens follow the Ansible naming convention:
360426
@@ -376,11 +442,53 @@ Additional secrets:
376442| ` REGISTRY_USERNAME ` / ` REGISTRY_PASSWORD ` | Container registry credentials |
377443| ` REDHAT_REGISTRY_PASSWORD ` | Red Hat registry authentication for base images |
378444
445+ ### GitLab CI pipeline (` .gitlab-ci.yml ` )
446+
447+ #### Triggers
448+
449+ The pipeline runs when:
450+
451+ - A ** Git tag** is pushed, or
452+ - The pipeline is started from the ** web UI** , ** API** , or an ** upstream trigger** .
453+
454+ (There is no default “every push to ` main ` ” rule; adjust ` workflow: rules `
455+ in ` .gitlab-ci.yml ` if you want branch pipelines.)
456+
457+ #### Required CI/CD variables
458+
459+ Use the ** same names** as GitHub secrets. Galaxy tokens:
460+
461+ ``` text
462+ ANSIBLE_GALAXY_SERVER_<ID>_TOKEN
463+ ```
464+
465+ Set each under ** Settings → CI/CD → Variables** . SCM ` token_env_var `
466+ values from ` scm_servers ` are listed in the header comments of
467+ ` .gitlab-ci.yml ` .
468+
469+ Registry-related variables:
470+
471+ | Variable | Purpose |
472+ | ----------| ---------|
473+ | ` REGISTRY_USERNAME ` / ` REGISTRY_PASSWORD ` | Push target registry. If unset, the job uses ` CI_REGISTRY_USER ` / ` CI_REGISTRY_PASSWORD ` (GitLab Container Registry). |
474+ | ` REDHAT_REGISTRY_USERNAME ` / ` REDHAT_REGISTRY_PASSWORD ` | Login to ` registry.redhat.io ` for Red Hat base images |
475+
476+ Optional: ` SKIP_BASE_IMAGE_VALIDATION ` , ` STORAGE_DRIVER ` (e.g. ` vfs ` for
477+ some runners). The template expects a ** podman** -capable image (e.g.
478+ ` quay.io/podman/stable ` ) and ** podman 4+** so build ` ARG ` s are not stored
479+ in image history.
480+
481+ The pipeline uses a single ` REGISTRY_AUTHFILE ` under the project directory
482+ for ` podman login ` , ` podman build ` , and ` podman push ` , so registries that
483+ require authentication on layer/blob checks (e.g. Quay.io) succeed.
484+ ` IMAGE_NAME ` is lowercased before tagging and pushing because many OCI
485+ registries reject mixed-case repository paths.
486+
379487### Token security
380488
381489- ** Galaxy server tokens** are passed as ` --build-arg ` values. With
382- ` buildah >= 1.24 ` , ` ARG ` values do not appear in image history or
383- metadata.
490+ ` buildah >= 1.24 ` / ** podman 4+ ** , ` ARG ` values do not appear in image
491+ history or metadata.
384492- ** SCM tokens** are resolved via ` envsubst ` into the build context
385493 after ` ansible-builder create ` . The multi-stage build ensures tokens
386494 only exist in intermediate stages, never in the final image.
0 commit comments