feat: implement new role layout

This commit is contained in:
Simon Cornet 2025-11-01 13:29:04 +01:00
commit f791e1d307
5 changed files with 6 additions and 45 deletions

View file

@ -2,19 +2,14 @@
# gitLab ci stages # gitLab ci stages
stages: stages:
# deployment
- "gitleaks" - "gitleaks"
- "linting" - "linting"
- "deployment"
# include jobs # include jobs
include: include:
# deployment # code plumbing
- local: ".gitlab/gitleaks.yaml" - local: ".gitlab/gitleaks.yaml"
- local: ".gitlab/deployment.yaml"
# linting # linting
- component: "$CI_SERVER_FQDN/components/ansible/linting@v3.0.3" - component: "$CI_SERVER_FQDN/components/ansible/linting@v3.0.3"

View file

@ -1,32 +0,0 @@
---
# deploy ansible/roles/common code
deployment:
stage: "deployment"
image:
name: "registry.gitlab.simoncor.net/oci/ssh-client:v25.06.03"
entrypoint: ["/bin/sh", "-c"]
rules:
# run only on push to default branch
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- when: "never"
# prepare ssh
before_script:
# prepare ssh
- |
# prepare ssh
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "$SSH_CONFIG" > ~/.ssh/config
echo "$SSH_DEPLOYMENT_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
# deployment commands
script:
- |
# install ansible roles dependancies
ssh $SSH_DEPLOYMENT_USER@$ANSIBLE_SERVER \
"sudo /usr/local/bin/ansible-galaxy install -r /etc/ansible/roles/requirements.yaml --force"

View file

@ -4,7 +4,7 @@
- name: "install and configure the Zabbix Agent" - name: "install and configure the Zabbix Agent"
hosts: "all" hosts: "all"
become: true become: true
pre_tasks: tasks:
# due to semaphore bug we need to do this ourselves # due to semaphore bug we need to do this ourselves
- name: "force-update requirements" - name: "force-update requirements"
@ -15,6 +15,7 @@
changed_when: false changed_when: false
failed_when: false failed_when: false
roles: # execute the role
- role: "zabbix_prereq" - name: "execute role: zabbix_agent"
- role: "zabbix_agent" ansible.builtin.include_role:
name: "zabbix_agent"

View file

@ -1,9 +1,6 @@
--- ---
roles: roles:
- name: "zabbix_prereq"
src: "https://gitlab.simoncor.net/ansible/ans-zabbix-prereq.git"
scm: "git"
- name: "zabbix_agent" - name: "zabbix_agent"
src: "https://gitlab.simoncor.net/ansible/ans-zabbix-agent.git" src: "https://gitlab.simoncor.net/ansible/ans-zabbix-agent.git"
scm: "git" scm: "git"