Commit 879be825 authored by Simon Cornet's avatar Simon Cornet
Browse files

feat: implement new role layout

parent b7524240
Loading
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -2,25 +2,16 @@

# gitLab ci stages
stages:

  # deployment
  - "gitleaks"
  - "linting"
  - "testing"
  - "deployment"


# include jobs
include:

  # deployment
  # code plumbing
  - local: ".gitlab/gitleaks.yaml"
  - local: ".gitlab/deployment.yaml"

  # linting
  - component: "$CI_SERVER_FQDN/components/ansible/linting@v3.0.3"
  - component: "$CI_SERVER_FQDN/components/markdownlint/markdownlint@1.0.0"
  - component: "$CI_SERVER_FQDN/components/yamllint/yamllint@1.0.2"

  # testing
  - component: "$CI_SERVER_FQDN/components/ansible/testing@v3.0.3"

.gitlab/deployment.yaml

deleted100644 → 0
+0 −32
Original line number Diff line number Diff line
---
# 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"

molecule/default/converge.yml

deleted100644 → 0
+0 −8
Original line number Diff line number Diff line
---

- name: "converge"
  hosts: "all"
  become: true
  gather_facts: true
  roles:
    - role: "siempie.atuin"

molecule/default/molecule.yml

deleted100644 → 0
+0 −44
Original line number Diff line number Diff line
---

dependency:
  name: "galaxy"

driver:
  name: "docker"

provisioner:
  name: "ansible"
  env:
    MOLECULE_TESTING: "true"

verifier:
  name: "ansible"

platforms:

  # debian 12
  - name: "debian-12"
    image: "geerlingguy/docker-debian12-ansible:latest"
    pre_build_image: true
    privileged: true
    volumes:
      - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
    command: "/lib/systemd/systemd"

  # ubuntu 22
  - name: "ubuntu-22"
    image: "geerlingguy/docker-ubuntu2204-ansible:latest"
    pre_build_image: true
    privileged: true
    volumes:
      - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
    command: "/lib/systemd/systemd"

  # ubuntu 24
  - name: "ubuntu-24"
    image: "geerlingguy/docker-ubuntu2404-ansible:latest"
    pre_build_image: true
    privileged: true
    volumes:
      - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
    command: "/lib/systemd/systemd"

molecule/default/verify.yml

deleted100644 → 0
+0 −37
Original line number Diff line number Diff line
---

# verify
- name: "verify"
  hosts: "all"
  become: true
  gather_facts: true
  vars:
    # renovate: datasource=github-releases depName=atuinsh/atuin versioning=pep440
    atuin_version: "18.10.0"
    atuin_binary_path: "/usr/local/bin/atuin"

  tasks:

    # check if atuin binary is installed
    - name: "check if atuin binary exists"
      ansible.builtin.stat:
        path: "{{ atuin_binary_path }}"
      register: "atuin_binary_stat"

    - name: "fail if atuin binary does not exist"
      ansible.builtin.fail:
        msg: "Atuin binary not found at {{ atuin_binary_path }}"
      when: "not atuin_binary_stat.stat.exists"

    # check atuin version
    - name: "check current atuin version"
      ansible.builtin.command: "{{ atuin_binary_path }} -V"
      register: "atuin_version_check"
      changed_when: false
      failed_when: "atuin_version_check.rc != 0"

    - name: "assert atuin version matches expected"
      ansible.builtin.assert:
        that: "'{{ atuin_version }}' in atuin_version_check.stdout"
        fail_msg: "Atuin version ({{ atuin_version_check.stdout }}) does not match ({{ atuin_version }})"
        success_msg: "Atuin version matches expected ({{ atuin_version }})"
Loading