62 Commits

Author SHA1 Message Date
Jon
6694986367 feat(mkdocs): add black for mkdocstrings to format signature
ref: https://github.com/nofusscomputing/centurion_erp/pull/776
2025-05-29 08:08:40 +09:30
Jon
224ef83157 feat(ansible_playbook): prior to running playbook display env vars
ref: nofusscomputing/projects/gitlab-ci#49
2025-02-26 22:18:04 +09:30
Jon
034a153ba0 fix(mkdocs): lock mkdocs-autorefs to 1.3.1
!82
2025-02-26 03:26:38 +09:30
Jon
6f8dfcba0b fix(mkdocs): lock griffe to 0.49.0
!82
2024-08-19 16:49:58 +09:30
Jon
58ffcabbfb feat(docker): add required artifacthub image labels
!82
2024-08-01 15:35:02 +09:30
Jon
673441f83a Merge branch 'fix-ansible-playbook' into 'development'
fix: ansible playbook

See merge request nofusscomputing/projects/gitlab-ci!84
2024-06-30 17:42:50 +00:00
Jon
b9f65bf908 fix(ansible): add localhost to PB hosts var
!84 nofusscomputing/projects/ansible/execution_environment!258 nofusscomputing/projects/ansible/ansible_playbooks!104
2024-07-01 02:05:28 +09:30
Jon
02422c55b8 Merge branch 'feat-mkdocstrings' into 'development'
feat: add plugin mkdocstrings to mkdocs

See merge request nofusscomputing/projects/gitlab-ci!83
2024-06-15 14:19:47 +00:00
Jon
e9b5925be3 feat(mkdocs): add plugin mkdocstrings to mkdocs pip requirements
!83 nofusscomputing/infrastructure/website-template!16 nofusscomputing/projects/django_template#57 nofusscomputing/projects/django_template!27
2024-06-15 23:47:49 +09:30
Jon
a24f352ca3 Merge branch 'nfc_firewall_collection' into 'development'
feat: Nfc firewall collection

See merge request nofusscomputing/projects/gitlab-ci!82
2024-03-16 11:31:58 +00:00
Jon
9492699abd refactor: updated nfc_firewall role to collection
!82 nofusscomputing/projects/ansible/firewall!19
2024-03-16 21:00:26 +09:30
Jon
9afa68d1f3 Merge branch 'collection_kubernetes' into 'development'
feat: Collection kubernetes repo update

See merge request nofusscomputing/projects/gitlab-ci!81
2024-03-14 12:43:09 +00:00
Jon
bd5c300d9d feat: add phpipam collection project
!81
2024-03-13 21:18:58 +09:30
Jon
582fa67ea5 feat: update kubernetes collection path
!81 nofusscomputing/projects/ansible/collections/kubernetes!37
2024-03-13 21:18:29 +09:30
Jon
41eeb7badd fix(ansible_collection): custom release actions to be shell script
use a shell script for the custom commands to prevent the var from expansion/parsing

!80 nofusscomputing/projects/ansible/collections/phpipam_scan_agent#14 nofusscomputing/projects/ansible/collections/phpipam_scan_agent!13
2024-02-25 18:58:44 +09:30
Jon
6f80ea3af7 feat(ansible_collection): custom release actions
enables commands to be ran before the git commit and git tag

!80
2024-02-24 15:57:25 +09:30
Jon
4f65bc1367 feat(ansible_collection): allow trigger from web interface
!80
2024-02-23 18:33:49 +09:30
Jon
8094694d43 feat(deploy): add itil runbooks
fixes #47
2024-02-23 12:17:56 +09:30
Jon
f987f9e4f0 feat(ansible_collection): for package use galaxy link
!80
2024-02-23 12:17:39 +09:30
Jon
b329eedd00 feat(ansible_collection): add dockerhub link
!80
2024-02-23 12:11:31 +09:30
Jon
34c81c9849 Merge branch 'ansible-collectio-specify-bump-increment' into 'development'
fix(ansible_collection): specify version for changelog

See merge request nofusscomputing/projects/gitlab-ci!80
2024-02-22 09:50:23 +00:00
Jon
8265977c7f fix(ansible_collection): version project label description
!80
2024-02-22 19:19:00 +09:30
Jon
d30abfdb73 fix(ansible_collection): specify version for changelog
!80
2024-02-22 19:17:44 +09:30
Jon
c7c966bbee Merge branch 'ansible-collectio-specify-bump-increment' into 'development'
fix(ansible_collection): syntax error in label command

See merge request nofusscomputing/projects/gitlab-ci!79
2024-02-22 08:31:30 +00:00
Jon
e6ba068b68 fix(ansible_collection): syntax error in label command
!79
2024-02-22 18:00:02 +09:30
Jon
74ac15925c Merge branch 'ansible-collectio-specify-bump-increment' into 'development'
feat(ansible_collection): Create project label matching version on release create

See merge request nofusscomputing/projects/gitlab-ci!78
2024-02-22 08:01:10 +00:00
Jon
21db41bae1 feat(ansible_collection): Create project label matching version on release create
!78
2024-02-22 17:29:48 +09:30
Jon
e046f9ea49 Merge branch 'ansible-collectio-specify-bump-increment' into 'development'
feat: Ansible collection specify bump increment

See merge request nofusscomputing/projects/gitlab-ci!77
2024-02-22 06:27:38 +00:00
Jon
4a0fa49b3f feat(project): add ansible collection ci test
!77
2024-02-22 15:56:09 +09:30
Jon
03609e2c9d feat(ansible_collection): specify version increment
!77
2024-02-22 15:55:42 +09:30
Jon
d29064f149 Merge branch 'ansible-collections' into 'development'
feat: Ansible collections

See merge request nofusscomputing/projects/gitlab-ci!75
2024-02-17 04:46:46 +00:00
Jon
6bcd588da8 docs(ansible_collection): added.
!75
2024-02-17 14:13:47 +09:30
Jon
5eb34f87e5 fix: merging changes to master on full release
!75 nofusscomputing/projects/ansible/collections/ci-test!14
2024-02-17 12:42:27 +09:30
Jon
fe1fc844d5 fix: don't jam pipeline success for MR to master
!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-17 00:52:36 +09:30
Jon
d77fefd095 refactor(ansible_collection): git tag must be created after the change commit
!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-17 00:20:47 +09:30
Jon
d4c534b95a fix(ansible_collection): build change to git tag only on git tag
!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-17 00:13:11 +09:30
Jon
9841eebb9d feat(ansible_collection): rename job 'merge check' to 'create release'
!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-17 00:07:38 +09:30
Jon
c05c421425 fix(ansible_collection): build change to git tag only on git tag
!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-17 00:03:01 +09:30
Jon
be612d905c fix(ansible_collection): ensure before building git is on the tagged commit
!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-16 23:28:12 +09:30
Jon
1d67a0aa45 fix(ansible_collection): create git tag before changelog
required so that cz can properly generate changelog.

!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-16 22:46:17 +09:30
Jon
1716032215 fix(ansible_collection): use last commit message to locate merge request id
on merge the last commit on the branch is the merge request commit. use it to obtain the MR id for the bump commit message

!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-16 22:04:19 +09:30
Jon
82e7be6849 feat(ansible_collection): remove testing rule
rule removed as it was used for developing the ci file and job should only run on dev

!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-16 21:11:35 +09:30
Jon
dee50b4ba0 feat(ansible_collection): complete ci jobs for full workflow
!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-16 20:55:57 +09:30
Jon
5d333e994f feat(ansible_lint): enable option to force failure
will allow user to enforce a unit test if they wish

!75 nofusscomputing/projects/ansible/collections/ci-test!1
2024-02-16 20:53:47 +09:30
Jon
64f08b5d3d feat(ansible_collection): initial incomplete test jobs
not yet tested or finished.

!75
2024-02-16 20:49:10 +09:30
Jon
4b6c0ac9f7 feat(ansible_collection): initial incomplete ci jobs
not yet tested or finished.

!75
2024-02-16 03:43:49 +09:30
Jon
80a9e7f183 chore: add vscode defaults
!75
2024-02-16 03:42:26 +09:30
Jon
02252db664 Merge branch 'test-rules' into 'development'
feat(test): add ci jobs to test gitlab rules

See merge request nofusscomputing/projects/gitlab-ci!76
2024-02-15 13:45:45 +00:00
Jon
8f25d1a09e feat(test): add ci jobs to test gitlab rules
!76
2024-02-15 23:14:33 +09:30
Jon
bea398200f ci: add docker-glpi and kube_monitoring
!74
2024-02-02 22:38:55 +09:30
Jon
e1a7f60401 ci: use matrix job to update parent repos
!74
2024-02-02 22:01:00 +09:30
9b57371358 build(version): bump version 0.6.1 → 0.7.0rc0 2024-02-02 08:22:51 +00:00
Jon
fc9f37617c feat(sub_module_update): wbsite-template
!44
2024-02-02 17:47:38 +09:30
Jon
3fa71fe91a fix(mkdocs): correct mkdocs image name
!73
2024-02-02 17:04:34 +09:30
Jon
6700cdbc90 Merge branch 'mkdocs-update' into 'development'
feat: Mkdocs update

Closes #43

See merge request nofusscomputing/projects/gitlab-ci!73
2024-02-02 07:28:55 +00:00
Jon
955ce37520 refactor(mkdocs): set env name to gitlab pages
!73 fixes #43
2024-02-02 16:57:20 +09:30
Jon
3fbd4317c0 feat(mkdocs): update requirements.txt to current versions
!73 nofusscomputing/infrastructure/website-template!13 nofusscomputing/infrastructure/website!44
2024-02-02 16:45:19 +09:30
Jon
c4087c7069 feat(mkdocs): update python to 3.11.2
!73 nofusscomputing/infrastructure/website-template!13 nofusscomputing/infrastructure/website!44
2024-02-02 16:19:44 +09:30
Jon
bd22ff566c Merge branch '44-fix-commit-footer-refs' into 'development'
fix(commit_footer_refs): enable automated jobs without MR to succeed.

Closes #44

See merge request nofusscomputing/projects/gitlab-ci!72
2023-11-18 06:42:22 +00:00
Jon
0f6e06c50f fix(commit_footer_refs): enable automated jobs without MR to succeed.
automated jobs use !not for MR

fixes #44 !72
2023-11-18 16:11:26 +09:30
Jon
67199ccc55 Merge branch '42-fix-commit-foot-refs' into 'development'
fix(commit_footer_refs): dont update git submodules

Closes #42

See merge request nofusscomputing/projects/gitlab-ci!71
2023-11-12 05:03:22 +00:00
Jon
b8199586b4 fix(commit_footer_refs): dont update git submodules
this ci job requires only the gitlab-ci submodule with other submodules being not applicable.

!71 fixes #42 nofusscomputing/infrastructure/configuration-management/project-production!2
2023-11-12 14:30:53 +09:30
20 changed files with 1320 additions and 95 deletions

View File

@ -4,4 +4,4 @@ commitizen:
name: cz_conventional_commits
tag_format: $major.$minor.$patch$prerelease
update_changelog_on_bump: true
version: 0.6.1
version: 0.7.0rc0

View File

@ -19,6 +19,8 @@ include:
- local: $JOB_ROOT_DIR/gitlab_release/.gitlab-ci.yml
- local: $JOB_ROOT_DIR/lint/markdown.gitlab-ci.yaml
- local: $JOB_ROOT_DIR/python/.gitlab-ci.yml
# - local: $JOB_ROOT_DIR/test/.gitlab-ci.yml
- local: $JOB_ROOT_DIR/ansible/collection/ci-test.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml
#- template: Security/License-Scanning.gitlab-ci.yml
@ -119,79 +121,29 @@ gilab-ci.yml Lint (python 3.11):
image: python:3.11-slim
Ansible_docker_os.Submodule.Deploy:
Update Sub Repo:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible_docker_os
Ansible_playbooks.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible_playbooks
Ansible-roles.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible-roles
config.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/config
Docker_Mail.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-mail
docker-buildx-qemu.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-buildx-qemu
docker-glpi.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-glpi
docker_management.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/docker_management
execution_environment.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/execution_environment
git_configuration.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/git_configuration
nodered_ldap_self_service.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/nodered_ldap_self_service
Ops.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/ops
Website.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/website
parallel:
matrix:
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/ops
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/configuration-management/itil_runbooks
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/website
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible_playbooks
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible-roles
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible_docker_os
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible_test
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/collections/ci-test
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/collections/firewall
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/collections/kubernetes
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/collections/phpipam_scan_agent
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/common
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/docker_management
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/execution_environment
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/git_configuration
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/homeassistant
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/nfc_glpi
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-bind
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-mail
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-buildx-qemu
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-glpi
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/kubernetes_monitoring

9
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,9 @@
{
"recommendations": [
"gitlab.gitlab-workflow",
"jebbs.markdown-extended",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker",
"streetsidesoftware.code-spell-checker-australian-english"
]
}

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"gitlab.aiAssistedCodeSuggestions.enabled": false,
"gitlab.duoChat.enabled": false,
"cSpell.language": "en-AU,en"
}

View File

@ -1,3 +1,21 @@
## 0.7.0rc0 (2024-02-02)
### Bug Fixes
- **mkdocs**: [3fa71fe9](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/3fa71fe91ad1e874b76fab7323e02496ac757f5d) - correct mkdocs image name [ [!73](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/73) ]
- **commit_footer_refs**: [0f6e06c5](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/0f6e06c50f7cae602cdc2ca00bbce7fe1fd72c32) - enable automated jobs without MR to succeed. [ [#44](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/44) [!72](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/72) ]
- **commit_footer_refs**: [b8199586](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/b8199586b4fe4c9f93efe68a908eaa8582f064c3) - dont update git submodules [ [!71](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/71) [#42](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/42) [!2](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/2) ]
### Code Refactor
- **mkdocs**: [955ce375](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/955ce3752050e78085c2037fe66714db41114c9e) - set env name to gitlab pages [ [!73](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/73) [#43](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/43) ]
### Features
- **sub_module_update**: [fc9f3761](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/fc9f37617cd26b3e44326161ba10183eb13444dd) - wbsite-template [ [!44](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/44) ]
- **mkdocs**: [3fbd4317](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/3fbd4317c0388fb8e406eb78614e3943375496ed) - update requirements.txt to current versions [ [!73](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/73) [!13](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/13) [!44](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/44) ]
- **mkdocs**: [c4087c70](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/c4087c7069524df573a43db29c399940600ddba7) - update python to 3.11.2 [ [!73](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/73) [!13](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/13) [!44](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/44) ]
## 0.6.1 (2023-11-06)
### Bug Fixes

View File

@ -0,0 +1,662 @@
---
variables:
ANSIBLE_GALAXY_UPLOAD_TOKEN: "" # Mandatory, String. The token to upload to ansible galaxy. DONT SET HERE, USE PIPELINE VARIABLES.
ANSIBLE_GALAXY_SERVER_URL: https://galaxy.ansible.com # Optional, default=(as displayed)String. URL to the Galaxy server for uploads
ANSIBLE_GALAXY_NAMESPACE: "" # Mandatory, String. The ansible galaxy upload namespace
ANSIBLE_GALAXY_PACKAGE_NAME: "" # Mandatory, String. The Ansible Galaxy package name
.ansible_collection_merge:
stage: chores
image: python:3.11-bookworm
before_script:
- | # Create artifact directory
mkdir -p artifacts
- | # Install Pre-req packages
apt update;
apt install -y --no-install-recommends \
curl \
git;
# ToDo: Install python deps
- |
pip install \
commitizen==3.14.1
- | # setup git user
git config --global user.email "helpdesk@nofusscomputing.com";
git config --global user.name "nfc_bot";
- | # Update origin using gitlab token
echo "Current git origin";
git remote -v;
git remote remove origin;
echo "Removed origin";
git remote add origin https://gitlab-ci-token:$GIT_COMMIT_TOKEN@gitlab.com/$CI_PROJECT_PATH.git;
echo "Add origin with auth";
git remote -v;
- | # fetch repo details
git fetch -fpv;
- | # switch to dev branch
git switch development;
- | # pull dev branch
git pull origin development --rebase
- | # Init git sub-modules
git submodule update --init
script:
- | # Store old version number
export OLD_VERSION=$(cz version --project);
echo "Trace - OLD_VERSION[$OLD_VERSION]"
# rc codes https://commitizen-tools.github.io/commitizen/exit_codes/
- | # Bump the version
if [ "0${VERSION_BUMP_INCREMENT}" != '0' ]; then
export BUMP_INCREMENT="--increment ${VERSION_BUMP_INCREMENT}";
fi;
if [ $CI_COMMIT_BRANCH == "development" ]; then
cz bump \
--files-only \
--yes \
${BUMP_INCREMENT} \
--prerelease alpha \
export VERSION_BUMPED=$?
elif [ $CI_COMMIT_BRANCH == "master" ]; then
cz bump \
--files-only \
${BUMP_INCREMENT} \
--yes
export VERSION_BUMPED=$?
else
echo "Something went wrong with creating the release";
exit 1;
fi;
echo "Trace - VERSION_BUMPED[$VERSION_BUMPED]"
- | # Store new version number
if [ "0$VERSION_BUMPED" == "00" ]; then
export NEW_VERSION=$(cz version --project)
echo "Trace - NEW_VERSION[$NEW_VERSION]"
fi;
- | # git stage .cz.yaml
if [ "0$VERSION_BUMPED" == "00" ]; then
git add .cz.yaml;
echo "git staged .cz.yaml";
git status;
fi;
- | # Update version in galaxy file
if [ "0$VERSION_BUMPED" == "00" ]; then
sed -E "s/version: (.+)/version: ${NEW_VERSION}/g" -i galaxy.yml
fi;
- | # git stage galaxy.yml
if [ "0$VERSION_BUMPED" == "00" ]; then
git add galaxy.yml
echo "git staged galaxy.yml";
git status;
fi;
- | # changelog since last version - for development branch
echo "changelog since last version - for development branch";
if [ "0$VERSION_BUMPED" == "00" ]; then
cz changelog --incremental --dry-run --unreleased-version "${NEW_VERSION}" > artifacts/incremental_changelog.txt
ls -lR artifacts/
fi;
- | # store incremental changelog since last version
echo "store incremental changelog since last version";
if [ "0$VERSION_BUMPED" == "00" ]; then
curl \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file artifacts/incremental_changelog.txt \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${NEW_VERSION}/incremental_changelog.txt"
fi;
- | # complete changelog since last normal release - for master branch
echo "complete changelog since last normal release - for master branch";
if [ "0$VERSION_BUMPED" == "00" ]; then
cz changelog --merge-prerelease --dry-run --unreleased-version "${NEW_VERSION}" > artifacts/full_changelog.txt
fi;
- | # store full changelog (merge-prerelease)
if [ "0$VERSION_BUMPED" == "00" ]; then
curl \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file artifacts/full_changelog.txt \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${NEW_VERSION}/full_changelog.txt"
fi;
- | # Update CHANGELOG.md
if [ "0$VERSION_BUMPED" == "00" ]; then
if [ $CI_COMMIT_BRANCH == "development" ]; then
cz changelog --incremental --unreleased-version "${NEW_VERSION}";
elif [ $CI_COMMIT_BRANCH == "master" ]; then
cz changelog --merge-prerelease --unreleased-version "${NEW_VERSION}";
else
echo "This job should only run on 'development' and 'master' branches";
exit 1;
fi;
fi;
- | # Create release notes
if [ "0$VERSION_BUMPED" == "00" ]; then
if [ $CI_COMMIT_BRANCH == "development" ]; then
cp artifacts/incremental_changelog.txt artifacts/release_notes.md
elif [ $CI_COMMIT_BRANCH == "master" ]; then
cp artifacts/full_changelog.txt artifacts/release_notes.md
else
echo "This job should only run on 'development' and 'master' branches";
exit 1;
fi;
fi;
- | # Store Release notes
curl \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file artifacts/release_notes.md \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${NEW_VERSION}/release_notes.md";
- | # git stage CHANGELOG.md
if [ "0$VERSION_BUMPED" == "00" ]; then
git add CHANGELOG.md;
echo "git staged CHANGELOG.md";
git status;
fi;
- | # Custom commands from RELEASE_ADDITIONAL_ACTIONS_BUMP
if [ -f ${RELEASE_ADDITIONAL_ACTIONS_BUMP} ]; then
echo "Custom commands found in variable RELEASE_ADDITIONAL_ACTIONS_BUMP";
chmod +x ${RELEASE_ADDITIONAL_ACTIONS_BUMP};
echo '------------------------------ TRACE SoF ------------------------------';
echo "File: RELEASE_ADDITIONAL_ACTIONS_BUMP[${RELEASE_ADDITIONAL_ACTIONS_BUMP}]";
echo '------ contents ------';
echo "";
cat ${RELEASE_ADDITIONAL_ACTIONS_BUMP};
echo "";
echo '------ contents ------';
echo "";
${RELEASE_ADDITIONAL_ACTIONS_BUMP};
echo "";
echo "git reset edited file: ${RELEASE_ADDITIONAL_ACTIONS_BUMP}";
git restore ${RELEASE_ADDITIONAL_ACTIONS_BUMP};
git status
echo '------------------------------ TRACE EoF ------------------------------'
fi;
# - | # Find merge request ID
# echo "Trace CI_OPEN_MERGE_REQUESTS[${CI_OPEN_MERGE_REQUESTS}]";
# if grep -q "," <<< "$CI_OPEN_MERGE_REQUESTS"; then
# export MERGE_REQUEST_FOUND=$(echo "${CI_OPEN_MERGE_REQUESTS}" | cut -d "," -f 1 | cut -d '!' -f 2);
# else
# export MERGE_REQUEST_FOUND=$(echo "${CI_OPEN_MERGE_REQUESTS}" | cut -d '!' -f 2);
# fi
# echo "Trace MERGE_REQUEST_FOUND[${MERGE_REQUEST_FOUND}]";
# if [ "$CI_MERGE_REQUEST_IID" ]; then
# export MERGE_REQUEST_FOUND=${CI_MERGE_REQUEST_IID}
# echo "Using CI_MERGE_REQUEST_IID[${CI_MERGE_REQUEST_IID}] as value for MERGE_REQUEST_FOUND";
# fi
- | # Find merge request ID
echo "Trace CI_OPEN_MERGE_REQUESTS[${CI_OPEN_MERGE_REQUESTS}]";
echo "Trace CI_MERGE_REQUEST_IID[${CI_MERGE_REQUEST_IID}]";
export MERGE_REQUEST_FOUND=$(git log -1 | grep -E '\!(.+)' | cut -d '!' -f 2);
echo "Trace MERGE_REQUEST_FOUND[${MERGE_REQUEST_FOUND}]";
- | # commit any changes
if [ "0$VERSION_BUMPED" == "00" ]; then
git status;
echo "commit changes to repo"
cat <<EOF | git commit -F-
build: bump version ${OLD_VERSION} -> ${NEW_VERSION}
!${MERGE_REQUEST_FOUND}
EOF
fi;
- | # Store the changes commit for the tag
export CHANGE_COMMIT=$(git log -n1 --format=format:"%H")
echo "Trace - CHANGE_COMMIT[$CHANGE_COMMIT]"
if [ "${CI_COMMIT_SHA}" == "${CHANGE_COMMIT}" ]; then
echo "No changes appear to have been commited!"
exit 1;
fi;
git log -3;
- | # create git tag, if changed
if [ "0$VERSION_BUMPED" == "00" ]; then
git tag -m "$(cat artifacts/incremental_changelog.txt)" ${NEW_VERSION} ${CHANGE_COMMIT};
fi;
- | # push development to origin
if [ "0$VERSION_BUMPED" == "00" ]; then
git push --set-upstream origin development
fi;
- | # merge bump changes to master
if [ "0$VERSION_BUMPED" == "00" ]; then
if [ $CI_COMMIT_BRANCH == "master" ]; then
echo "Trace Checkout master branch";
git checkout master;
echo "Trace merge changes from development branch";
git merge --no-ff development;
echo "Trace push changes to origin";
git push origin master;
fi;
fi;
- | # store metadata for use in later stages
if [ "0$VERSION_BUMPED" == "00" ]; then
cat <<EOF > artifacts/metadata.env
export CHANGE_COMMIT=${CHANGE_COMMIT}
export MERGE_REQUEST_FOUND=${MERGE_REQUEST_FOUND}
export NEW_VERSION=${NEW_VERSION}
export OLD_VERSION=${CURRENT_VERSION}
export VERSION_BUMPED=${VERSION_BUMPED}
EOF
chmod +x artifacts/metadata.env;
curl \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file artifacts/metadata.env \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${NEW_VERSION}/metadata.env";
fi;
- | # Create Version Label
if [ "$CREATE_VERSION_LABEL" != "false" ]; then
curl \
--data "name=v${NEW_VERSION}&color=#eee600&description=Version%20that%20is%20affected" \
--header "PRIVATE-TOKEN: $GIT_COMMIT_TOKEN" \
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/labels"
fi;
- | # push git tag to origin
if [ "0$VERSION_BUMPED" == "00" ]; then
git push --tags
fi;
artifacts:
untracked: false
when: always
expire_in: "3 days"
paths:
- "artifacts/*"
rules:
- if: "$CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'"
when: never
- if: # Occur on merge
$CI_COMMIT_BRANCH == "development"
&&
$CI_PIPELINE_SOURCE == "push"
allow_failure: true
when: manual
- if: # Occur on merge
$CI_COMMIT_BRANCH == "master"
&&
(
$CI_PIPELINE_SOURCE == "push"
||
$CI_PIPELINE_SOURCE == "web"
)
when: always
- when: never
# Feature Branch / git tag
.ansible_collection_build:
stage: build
image: python:3.11-bookworm
before_script:
- | # Exit if mandatory variables not defined. On the first job in the pipeline for release.
if [ "$CI_COMMIT_TAG" ]; then
if [ "0$ANSIBLE_GALAXY_UPLOAD_TOKEN" == "0" ]; then
echo variable ANSIBLE_GALAXY_UPLOAD_TOKEN must be set;
exit 1;
fi;
if [ "0$ANSIBLE_GALAXY_NAMESPACE" == "0" ]; then
echo variable ANSIBLE_GALAXY_NAMESPACE must be set;
exit 1;
fi;
if [ "0$ANSIBLE_GALAXY_PACKAGE_NAME" == "0" ]; then
echo variable ANSIBLE_GALAXY_PACKAGE_NAME must be set;
exit 1;
fi;
fi
- | # Install python deps
pip install \
ansible==9.2.0
- | # Setup git to be on the tagged commit
if [ "${CI_COMMIT_TAG}" ]; then
echo "setting up git to be on revision ${CI_COMMIT_TAG}";
git log -2;
git fetch -fpvt;
git pull origin development --rebase;
git checkout tags/${CI_COMMIT_TAG} -b development;
git log -2;
fi;
script:
- | # Build the collection
ansible-galaxy collection build . --verbose --force --output-path artifacts/galaxy/
artifacts:
untracked: false
when: on_success
expire_in: "3 days"
paths:
- "artifacts/*"
rules:
- if: $CI_COMMIT_TAG
when: on_success
- if: "$CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'"
when: never
- if: # Occur on merge
$CI_COMMIT_BRANCH == "development"
&&
$CI_PIPELINE_SOURCE == "push"
when: always
- if:
$CI_COMMIT_BRANCH != "development"
&&
$CI_COMMIT_BRANCH != "master"
&&
$CI_PIPELINE_SOURCE == "push"
when: always
- when: never
# store built package in generic package registry
.ansible_collection_stage_package:
stage: prepare
image: curlimages/curl:latest
variables:
GIT_STRATEGY: none
environment:
name: Gitlab Package Registry
url: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}/
script:
- | # Store collection
curl \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file artifacts/galaxy/${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}/${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz"
- | # Fetch Release Notes
mkdir -p artifacts;
curl \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
-o artifacts/release_notes.md \
${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}/release_notes.md
echo "Release notes fetched";
ls -lR artifacts/
artifacts:
untracked: false
when: on_success
expire_in: "3 days"
paths:
- "artifacts/*"
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never
# Only on git tag
.ansible_collection_release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
variables:
GIT_STRATEGY: none
script:
- ls -lR artifacts/
release:
tag_name: $CI_COMMIT_TAG
description: ./artifacts/release_notes.md
name: $CI_COMMIT_TAG
assets:
links:
- name: 'Ansible Galaxy'
url: https://galaxy.ansible.com/ui/repo/published/${ANSIBLE_GALAXY_NAMESPACE}/${ANSIBLE_GALAXY_PACKAGE_NAME}/?version=${CI_COMMIT_TAG}
- name: ${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz
url: https://galaxy.ansible.com/api/v3/plugin/ansible/content/published/collections/artifacts/${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz
link_type: package
- name: 'Docker Image: ${DOCKER_IMAGE_PUBLISH_REGISTRY}/${DOCKER_IMAGE_PUBLISH_NAME}:${CI_COMMIT_TAG}'
url: ${DOCKER_IMAGE_PUBLISH_URL}
link_type: package
- name: Documentation
url: https://nofusscomputing.com/${PAGES_ENVIRONMENT_PATH}
milestones:
- $CI_MERGE_REQUEST_MILESTONE
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never
# Only on git tag
.ansible_collection_publish_galaxy:
stage: publish
image: python:3.11-bookworm
variables:
GIT_STRATEGY: none
ANSIBLE_GALAXY_SERVER_URL: https://galaxy.ansible.com
environment:
name: Ansible Galaxy
url: https://galaxy.ansible.com/ui/repo/published/${ANSIBLE_GALAXY_NAMESPACE}/${ANSIBLE_GALAXY_PACKAGE_NAME}/
before_script:
- | # Install python deps
pip install \
ansible
pip list;
- | # Prepare filename for package
# mkdir -p artifacts/galaxy;
# mv collection.tar.gz artifacts/galaxy/${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz
# echo "Prepare filename to be in the correct format";
ls -lR artifacts;
script:
- | # Publish package to Ansible Galaxy
ansible-galaxy collection publish \
--server ${ANSIBLE_GALAXY_SERVER_URL} \
--token ${ANSIBLE_GALAXY_UPLOAD_TOKEN} \
--verbose artifacts/galaxy/${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz
artifacts:
untracked: false
when: on_success
expire_in: "3 days"
paths:
- "artifacts/*"
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never

View File

@ -0,0 +1,63 @@
# Ansible Collection Unit Test: # what would the unit tests be??
# stage: test
# before_script:
# - echo. #install deps
# script:
# - echo. # what????
Ansible Collection Functional Test:
stage: test
# ToDo: refactor lint jobs to be individual so that pipeline linking can occur
# needs:
# - Ansible Collection CI Lint
parallel:
matrix:
- NFC_CI_FUNCTIONAL_TEST: "push"
NFC_CI_FUNCTIONAL_TEST_BRANCH: feature
- NFC_CI_FUNCTIONAL_TEST: "merge"
NFC_CI_FUNCTIONAL_TEST_BRANCH: development
- NFC_CI_FUNCTIONAL_TEST: "release"
NFC_CI_FUNCTIONAL_TEST_BRANCH: development
- NFC_CI_FUNCTIONAL_TEST: "push"
NFC_CI_FUNCTIONAL_TEST_BRANCH: development
- NFC_CI_FUNCTIONAL_TEST: "merge"
NFC_CI_FUNCTIONAL_TEST_BRANCH: master
script:
- echo "to be created";
# ToDo: run ansible playbook to setup, run and wait for each stage
# ToDo: create build artifact for use with creating a badge for tests, per branch
artifacts:
untracked: true
when: on_success
expire_in: "90 days"
resource_group: ansible_collection_functional_test
rules:
# turn off until created
- when: never
- if: # development/feature branch
$CI_COMMIT_BRANCH != "master" &&
$CI_PIPELINE_SOURCE == "push"
changes:
paths:
- 'ansible/collection/*.yml'
compare_to: 'development'
when: always
- if: # master branch
$CI_COMMIT_BRANCH == "master" &&
$CI_PIPELINE_SOURCE == "push"
when: always

View File

@ -6,7 +6,7 @@ include:
.ansible_playbook:
image:
image:
name: nofusscomputing/ansible-ee:dev
pull_policy: always
stage: chores
@ -21,7 +21,10 @@ include:
- echo "[DEBUG] ansible_inventory=$ansible_inventory"
- echo "[DEBUG] ansible_playbook=$ansible_playbook"
- echo "[DEBUG] ansible_tags=$ansible_tags"
- ansible-playbook $ansible_inventory $ANSIBLE_PLAYBOOK_DIR/$ansible_playbook $ansible_tags -vvv
- echo "[TRACE] ********************************** start ******************************************"
- export
- echo "[TRACE] *********************************** end *******************************************"
- ansible-playbook $ansible_inventory $ANSIBLE_PLAYBOOK_DIR/$ansible_playbook $ansible_tags --extra-vars "nfc_pb_host=localhost" -vvv
rules:
# ToDo: at some stage redefine these rules so that the job can run if specified.
# - if: '$NFC_AUTO_JOBS == "false"'

View File

@ -56,15 +56,20 @@ variables:
- update-binfmts --display
- |
if [ "0$NFC_IMAGE_DESCRIPTION" != "0" ]; then NFC_IMAGE_DESCRIPTION=${NFC_IMAGE_DESCRIPTION}; else NFC_IMAGE_DESCRIPTION="No Fuss Computing Image"; fi;
if [ "0$DOCKER_IMAGE_BUILD_TARGET_PLATFORMS" != "0" ]; then
echo "[DEBUG] building multiarch/specified arch image";
docker buildx build --platform=$DOCKER_IMAGE_BUILD_TARGET_PLATFORMS . \
--label org.opencontainers.image.created="$(date '+%Y-%m-%d %H:%M:%S%:z')" \
--label org.opencontainers.image.created="$(date '+%Y-%m-%dT%H:%M:%S%:z')" \
--label org.opencontainers.image.description="$NFC_IMAGE_DESCRIPTION" \
--label org.opencontainers.image.documentation="$CI_PROJECT_URL" \
--label org.opencontainers.image.source="$CI_PROJECT_URL" \
--label org.opencontainers.image.revision="$CI_COMMIT_SHA" \
--label io.artifacthub.package.readme-url="$CI_PROJECT_URL/-/raw/development/README.md?ref_type=heads" \
--label io.artifacthub.package.maintainers='[{"name":"No Fuss Computing","email":"helpdesk@nofusscomputing.com"}]' \
--push \
--build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN --build-arg CI_PROJECT_ID=$CI_PROJECT_ID --build-arg CI_API_V4_URL=$CI_API_V4_URL \
--file $DOCKER_DOCKERFILE \
@ -73,7 +78,7 @@ variables:
docker buildx imagetools inspect $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
# during docker multi platform build there are >=3 additional unknown images added to gitlab container registry. cleanup
DOCKER_MULTI_ARCH_IMAGES=$(docker buildx imagetools inspect "$DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG" --format "{{ range .Manifest.Manifests }}{{ if ne (print .Platform) \"&{unknown unknown [] }\" }}$DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG@{{ println .Digest }}{{end}} {{end}}");
docker buildx imagetools create $DOCKER_MULTI_ARCH_IMAGES --tag $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
@ -85,16 +90,19 @@ variables:
echo "[DEBUG] building image";
docker build . \
--label org.opencontainers.image.created="$(date '+%Y-%m-%d %H:%M:%S%:z')" \
--label org.opencontainers.image.created="$(date '+%Y-%m-%dT%H:%M:%S%:z')" \
--label org.opencontainers.image.description="$NFC_IMAGE_DESCRIPTION" \
--label org.opencontainers.image.documentation="$CI_PROJECT_URL" \
--label org.opencontainers.image.source="$CI_PROJECT_URL" \
--label org.opencontainers.image.url="$CI_PROJECT_URL/-/releases/$(cz -n cz_nfc version --project)" \
--label org.opencontainers.image.version="$(cz -n cz_nfc version --project)" \
--label org.opencontainers.image.revision="$CI_COMMIT_SHA" \
--label io.artifacthub.package.readme-url="$CI_PROJECT_URL/-/raw/development/README.md?ref_type=heads" \
--label io.artifacthub.package.maintainers='[{"name":"No Fuss Computing","email":"helpdesk@nofusscomputing.com"}]' \
--build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN --build-arg CI_PROJECT_ID=$CI_PROJECT_ID --build-arg CI_API_V4_URL=$CI_API_V4_URL \
--file $DOCKER_DOCKERFILE \
--tag $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
docker push $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
fi

View File

@ -0,0 +1,284 @@
---
title: Ansible Collection
description: How to use No Fuss Computings gitlab-ci job for running Ansible Collection CI/CD Pipelines
date: 2024-02-16
template: project.html
about: https://gitlab.com/nofusscomputing/projects/gitlab-ci
---
This CI/CD template contains all of the CI jobs required for a pipeline for an Ansible Collection Project.
## Requirements
The following requirements are needed to run these CI/CD jobs. As we use [commitizen](https://commitizen-tools.github.io/commitizen/) for the versioning system, your commits will be required to be in [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/). The configuration for commitizen is within a `.cz.yaml` file which you will need to add to your repository root directory.
### Gitlab Features
| Feature | Setting | Notes |
|:---|:---:|:---|
| Package Registry | On | Storage of pipeline artifacts and the built package. |
| Releases | On | Gitlab releases are created as part of the pipeline. |
### Variables
To be able to upload to Ansible Galaxy, you will be required to provide the jobs, the following Variables That should be set as CI/CD variables (`<Project> -> Settings -> CI/CD Settings -> Variables`).
| Variable | Settings | Notes |
|:---|:---:|:---|
| `ANSIBLE_GALAXY_UPLOAD_TOKEN` | `masked`, `protected` | |
| `VERSION_BUMP_INCREMENT` | `major`, `minor`, `patch` | Used for manual run of the job. After setting the variable, that type of version bump will occur. |
Within your `.gitlab-ci.yml` file there are varibales to be set, please see below.
### .gitlab-ci.yaml Changes
To include these jobs in your CI/CD Project add our gitlab-ci project as a submodule to your project `git submodule add https://gitlab.com/nofusscomputing/projects/gitlab-ci/`. Then update your projects `.gitlab-ci.yml` file to include the following:
``` yaml
variables:
ANSIBLE_GALAXY_SERVER_URL: https://galaxy.ansible.com # Optional, default=(as displayed)String. URL to the Galaxy server for uploads
ANSIBLE_GALAXY_NAMESPACE: "" # Mandatory, String. The ansible galaxy upload namespace
ANSIBLE_GALAXY_PACKAGE_NAME: "" # Mandatory, String. The Ansible Galaxy package name
include:
- project: nofusscomputing/projects/gitlab-ci
ref: <git ref> # branch, git tag, commit etc
file:
- .gitlab-ci_common.yaml
- template/ansible-collection.gitlab-ci.yaml
```
## CI/CD Jobs
This template contains the following CI/CD Jobs
- `Create Release`
- `Ansible Lint`
- `Ansible Lint (galaxy.yml)`
- `Build Collection`
- `Stage Collection`
- `Gitlab Release`
- `Ansible Galaxy`
for a detail description of each job, please see below.
### Create Release
Triggered:
- **Feature branch**:
- **push**: `never`
- **merge to**: `never`
- **development branch**:
- **push**: `manual`
- **merge to**: `manual`
- **master branch**:
- **push**: `always`
- **merge to**: `always`
- **git tag**: `never`
Create a release. It's only triggered on merge to the `development` and `master` branches. The last stage of this job is to create a git tag which matches the version to be released. The creation of the git tag, starts the remainder of the release cycle. On the `development` branch (when the job is triggered as it's a manual job) an `alpha` release is created and on the `master` branch, a full release is created.
### Ansible Lint
Triggered:
- **Feature branch**:
- **push**: `never`
- **merge to**: `never`
- **development branch**:
- **push**: `manual`
- **merge to**: `manual`
- **master branch**:
- **push**: `never`
- **merge to**: `never`
- **git tag**: `never`
Lints the yaml files in directories `meta`, `playbooks` and `roles`. This job will not fail the pipeline. There are XUnit test reports created for thyis job so you can see any liniting errors.
### Ansible Lint (galaxy.yml)
Triggered:
- **Feature branch**:
- **push**: `always`
- **merge to**: `always`
- **development branch**:
- **push**: `always`
- **merge to**: `always`
- **master branch**:
- **push**: `never`
- **merge to**: `never`
- **git tag**: `always`
Lints the `galaxy.yml` file. This job is designed to fail the pipeline, as an incorrectly formated `galaxy.yml` file can prevent an upload of the collection to Ansible Galaxy. There is a XUnit test report created for thyis job so you can see any liniting errors.
### Build Collection
Triggered:
- **Feature branch**:
- **push**: `always`
- **merge to**: `always`
- **development branch**:
- **push**: `always`
- **merge to**: `always`
- **master branch**:
- **push**: `never`
- **merge to**: `never`
- **git tag**: `always`
Builds the collection.
### Stage Collection
Triggered:
- **Feature branch**:
- **push**: `never`
- **merge to**: `never`
- **development branch**:
- **push**: `never`
- **merge to**: `never`
- **master branch**:
- **push**: `never`
- **merge to**: `never`
- **git tag**: `always`
Adds the collection to Gitlab Packages Regsitry as a generic package. This location is used to store the package.
### Gitlab Release
Triggered:
- **Feature branch**:
- **push**: `never`
- **merge to**: `never`
- **development branch**:
- **push**: `never`
- **merge to**: `never`
- **master branch**:
- **push**: `never`
- **merge to**: `never`
- **git tag**: `always`
Creates a Gitlab release.
### Ansible Galaxy
Triggered:
- **Feature branch**:
- **push**: `never`
- **merge to**: `never`
- **development branch**:
- **push**: `never`
- **merge to**: `never`
- **master branch**:
- **push**: `never`
- **merge to**: `never`
- **git tag**: `always`
Uploads the package to Ansible Galaxy.
## CI Tests
Still to be developed
## Definition
``` yaml title="template/ansible-collection.gitlab-ci.yaml" linenums="1"
--8<-- "template/ansible-collection.gitlab-ci.yaml"
```
----
``` yaml title=".gitlab-ci_common.yaml" linenums="1"
--8<-- ".gitlab-ci_common.yaml"
```

View File

@ -88,7 +88,6 @@ commit footer refs:
- git remote add origin $CI_REPOSITORY_URL
- git fetch --all
- git checkout --track origin/$CI_COMMIT_BRANCH
- git submodule update --init
script:
- commit_footer > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME.junit.xml"
artifacts:

View File

@ -57,7 +57,7 @@ class Commits:
footer_line = git_message.split("\n")
footer_line = footer_line[(len(footer_line)-1)]
commit_footer = re.findall(r"([\!|\#][0-9]+)", str(git_message))
commit_footer = re.findall(r"([\!|\#][\d|not]+)", str(git_message))
if len(commit_footer) > 0:
footer = commit_footer

View File

@ -22,6 +22,17 @@
- ls -la $PYTHON_VERSION
- if [ $ANSIBLE_LINT_JUNIT > 0 ]; then echo "Error ANSIBLE_LINT_JUNIT failed with $ANSIBLE_LINT_JUNIT"; fi
- if [ $ANSIBLE_LINT -ge 3 ]; then echo "ansible lint failed with $ANSIBLE_LINT"; exit $ANSIBLE_LINT; fi # don't fail the job?? 1=failed test, 2=failed command i.e. switch/flag
- | # Force failure if test must pass set TEST_MUST_PASS=yes
if [ "0$TEST_MUST_PASS" == "0yes" ]; then
echo "Trace TEST_MUST_PASS[${TEST_MUST_PASS}]";
echo "ansible lint failed with $ANSIBLE_LINT";
exit $ANSIBLE_LINT;
fi
after_script:
- echo deactivate
artifacts:

View File

@ -17,7 +17,11 @@ nav:
- projects/index.md
- Gitlab CI:
- Gitlab CI:
- Ansible:
- projects/gitlab-ci/ansible/collection.md
- Build:

View File

@ -1,5 +1,5 @@
.MKDocs_Build:
image: python:3.7.5-buster
image: python:3.11.2-bullseye
stage: build
variables:
GIT_DEPTH: 0

View File

@ -1,9 +1,16 @@
mkdocs==1.2.3
mkdocs-minify-plugin==0.5.0
mkdocs-material-extensions==1.0.3
# MkDocs: show_signature_annotations=True
black==25.1.0
mkdocs==1.5.3
mkdocstrings==0.25.1
mkdocstrings-python==1.10.3
mkdocs-autorefs==1.3.1
mkdocs-minify-plugin==0.8.0
mkdocs-material-extensions==1.3.1
wheel
mkdocs-material==8.1.7
mkdocs-material==9.5.6
./website-template/custom-plugins/mkdocs-plugin-tags
mkdocs-git-revision-date-localized-plugin==0.11.1
pymdown-extensions==9.1
Jinja2==3.0.3
mkdocs-git-revision-date-localized-plugin==1.2.2
pymdown-extensions==10.7
Jinja2==3.1.3
griffe==0.49.0

View File

@ -0,0 +1,101 @@
include:
- local: $JOB_ROOT_DIR/ansible/collection/.gitlab-ci.yml
- local: $JOB_ROOT_DIR/lint/ansible.gitlab-ci.yaml
Create Release:
extends: .ansible_collection_merge
needs: []
Ansible Lint:
extends: .ansible_linter_defaults
image: python:3.11-slim
variables:
ANSIBLE_LINT_PATH: meta/ playbooks/ roles/
needs: []
rules:
- if: $CI_COMMIT_TAG
when: always
- if: "$CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'"
when: never
- if: # Occur on merge
$CI_COMMIT_BRANCH == "development"
&&
$CI_PIPELINE_SOURCE == "push"
when: always
- if:
$CI_COMMIT_BRANCH != "development"
&&
$CI_COMMIT_BRANCH != "master"
&&
$CI_PIPELINE_SOURCE == "push"
when: always
- when: never
# ToDo: add lint for README.md as ansible Galaxy doesn't seem to like html in the md document. 16 Feb 24.
Ansible Lint (galaxy.yml):
extends: .ansible_linter_defaults
image: python:3.11-slim
variables:
ANSIBLE_LINT_PATH: galaxy.yml
TEST_MUST_PASS: 'yes'
needs: []
rules:
- if: $CI_COMMIT_TAG
when: always
- if: "$CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'"
when: never
- if: # Occur on merge
$CI_COMMIT_BRANCH == "development"
&&
$CI_PIPELINE_SOURCE == "push"
when: always
- if:
$CI_COMMIT_BRANCH != "development"
&&
$CI_COMMIT_BRANCH != "master"
&&
$CI_PIPELINE_SOURCE == "push"
when: always
- when: never
Build Collection:
extends: .ansible_collection_build
needs:
- Ansible Lint
- Ansible Lint (galaxy.yml)
Stage Collection:
extends: .ansible_collection_stage_package
needs:
- Build Collection
Gitlab Release:
extends: .ansible_collection_release
needs:
- Stage Collection
Ansible Galaxy:
extends: .ansible_collection_publish_galaxy
needs:
- Stage Collection
- Gitlab Release

View File

@ -27,7 +27,7 @@ pages:
- mv "$CI_PROJECT_DIR/artifacts/build/Documentation.Build/build" public
needs: [ 'Documentation.Build' ]
environment:
name: staging
name: Gitlab Pages
url: $CI_PAGES_URL/$PAGES_ENVIRONMENT_PATH
artifacts:
paths:

99
test/.gitlab-ci.yml Normal file
View File

@ -0,0 +1,99 @@
# This gitlab-ci file is for testing job rules
API Only:
stage: test
needs: []
script:
- echo should only run on
rules:
- if:
$CI_PIPELINE_SOURCE == "api"
when: always
- when: never
Push Only:
stage: test
needs: []
script:
- echo testing rules
rules:
- if:
$CI_COMMIT_BRANCH != ""
&&
$CI_PIPELINE_SOURCE == "push"
when: always
- when: never
MR-On Merging Only:
stage: test
needs: []
script:
- echo should only run on merging a MR
rules:
- if:
$CI_MERGE_REQUEST_IID == ""
&&
$CI_PIPELINE_SOURCE == "merge_request_event"
when: always
- when: never
MR-Not On Merging:
stage: test
needs: []
script:
- echo should never run on merging a MR
rules:
- if:
$CI_MERGE_REQUEST_IID != ""
&&
$CI_PIPELINE_SOURCE == "merge_request_event"
when: always
- when: never
MR-Merge Request Event:
stage: test
needs: []
script:
- echo should only run on merge event
rules:
- if:
$CI_PIPELINE_SOURCE == "merge_request_event"
when: always
- when: never
Trigger Only:
stage: test
needs: []
script:
- echo should only run on trigger event
rules:
- if:
$CI_PIPELINE_SOURCE == "trigger"
when: always
- when: never
Web Only:
stage: test
needs: []
script:
- echo should only run on web only trigger
rules:
- if:
$CI_PIPELINE_SOURCE == "web"
when: always
- when: never