Skip to content

Commit

Permalink
improv: update variables and common role style (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
antmelekhin committed Jun 5, 2024
1 parent 4b6b71e commit e7514e9
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 102 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@ name: 'Molecule'
on:
pull_request:
push:
branches:
- main
branches: ['main']

jobs:
lint:
name: 'Lint'
runs-on: ubuntu-latest
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout the codebase'
uses: actions/checkout@v4
uses: 'actions/checkout@v4'

- name: 'Set up Python 3'
uses: actions/setup-python@v5
uses: 'actions/setup-python@v5'
with:
python-version: '3.x'

- name: 'Install linters'
run: pip3 install ansible-lint yamllint
run: pip3 install ansible-core==2.16.7 ansible-lint==24.5.0 yamllint==1.35.1

- name: 'Run linters'
run: |
Expand All @@ -29,23 +28,26 @@ jobs:
molecule:
name: 'Molecule'
needs: lint
runs-on: ubuntu-latest
needs: 'lint'
runs-on: 'ubuntu-latest'
strategy:
matrix:
include:
- distro: 'debian-11'
- distro: 'debian-12'
- distro: 'rockylinux-8'
- distro: 'rockylinux-9'
- distro: 'ubuntu-20.04'
- distro: 'ubuntu-22.04'

steps:
- name: 'Checkout the codebase'
uses: actions/checkout@v4
uses: 'actions/checkout@v4'

- name: 'Testing an Ansible role with Molecule'
uses: gofrolist/molecule-action@v2
uses: 'gofrolist/molecule-action@v2'
with:
molecule_command: test
molecule_command: 'test'
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
name: 'Publish'
on:
release:
types:
- published
types: ['published']

jobs:
publish:
name: 'Publish'
runs-on: ubuntu-latest
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout the codebase'
uses: actions/checkout@v4
uses: 'actions/checkout@v4'

- name: 'Set up Python 3'
uses: actions/setup-python@v5
uses: 'actions/setup-python@v5'
with:
python-version: '3.x'

- name: 'Install ansible-core package'
run: pip3 install ansible-core

- name: 'Get an Ansible role name'
id: get_role_name
id: 'get_role_name'
run: echo "ROLE_NAME=$(yq '.galaxy_info.role_name' meta/main.yml)" >> $GITHUB_OUTPUT

- name: 'Publish the role to the Ansible Galaxy'
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@ name: 'Release'
on:
workflow_run:
workflows: ['Molecule']
types: [completed]
branches:
- main
types: ['completed']
branches: ['main']

jobs:
release:
name: 'Release'
runs-on: ubuntu-latest
runs-on: 'ubuntu-latest'
if: ${{ github.repository_owner == 'antmelekhin' && github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 'Checkout the codebase'
uses: actions/checkout@v4
uses: 'actions/checkout@v4'
with:
fetch-depth: 0
persist-credentials: false

- name: 'Semantic Release'
uses: cycjimmy/semantic-release-action@v4
uses: 'cycjimmy/semantic-release-action@v4'
with:
semantic_version: 23.0.8
semantic_version: '23.0.8'
extra_plugins: |
@semantic-release/git@10.0.1
@semantic-release/changelog@6.0.3
Expand Down
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Requirements
------------
- Supported version of Ansible: 2.12 and highter.
- `pywinrm` is a python library for connection Ansible to Windows hosts via [WinRM](https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html).
- Supported platforms:
- Debian
- 10
Expand All @@ -43,24 +44,19 @@ Requirements
- 20.04
- 22.04
- Windows
- 2016
- 2019
- all

Role Variables
--------------

Variables for installing GitLab Runner using the GitLab repository (Debian and RedHat based distributions):
- `gitlab_runner_package_version` The version of the GitLab Runner package. By default, GitLab Runner is installed with the latest available version.
- `gitlab_runner_repository_mirror_url` GitLab repository mirror (default: `https://packages.gitlab.com/runner/gitlab-runner`).
- `gitlab_runner_repository_mirror_url` The GitLab repository mirror (default: `https://packages.gitlab.com/runner/gitlab-runner`).
- `gitlab_runner_repository_gpgkey_url` URL to GitLab repository GPG key file (default: `https://packages.gitlab.com/runner/gitlab-runner/gpgkey`).

Variables for installing GitLab Runner using a binary file (Windows):

- `gitlab_runner_binary_version` The version of the GitLab Runner binary (default: `16.11.1`).
- `gitlab_runner_binary_name` GitLab Runner binary name (default: `gitlab-runner-windows-amd64`).
- `gitlab_runner_binary_download_url` URL to download the GitLab Runner binary (default: `https://gitlab-runner-downloads.s3.amazonaws.com/v16.11.1/binaries`).
- `gitlab_runner_binary_install_path` GitLab Runner installation folder (default: `C:\Program Files\gitlab-runner`).
- `gitlab_runner_binary_name` The GitLab Runner binary name (default: `gitlab-runner-windows-amd64`).
- `gitlab_runner_download_url` URL to download the GitLab Runner binary (default: `https://gitlab-runner-downloads.s3.amazonaws.com/v16.11.1/binaries`).
- `gitlab_runner_download_path` Local path to download and extract the binary (default: `/tmp`).
- `gitlab_runner_install_path` GitLab Runner installation folder (default: `C:\Program Files\gitlab-runner`).

Dependencies
------------
Expand Down
9 changes: 5 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
# Install GitLab Runner using the Gitlab repository (Debian and RedHat based distributions)
# Install GitLab Runner from the GitLab repository (Debian and RedHat based distributions)
gitlab_runner_package_version: ''
gitlab_runner_repository_mirror_url: 'https://packages.gitlab.com/runner/gitlab-runner'
gitlab_runner_repository_gpgkey_url: '{{ gitlab_runner_repository_mirror_url }}/gpgkey'

# Install GitLab Runner using a binary file (Windows)
# Install GitLab Runner using the binary file (Windows)
## See available releases: https://gitlab.com/gitlab-org/gitlab-runner/-/releases
gitlab_runner_binary_version: '16.11.1'
gitlab_runner_binary_name: 'gitlab-runner-{{ _gitlab_runner_os }}-{{ _gitlab_runner_architecture }}'
gitlab_runner_binary_download_url: 'https://gitlab-runner-downloads.s3.amazonaws.com/v{{ gitlab_runner_binary_version }}/binaries'
gitlab_runner_binary_install_path: '{{ _gitlab_runner_binary_install_path }}'
gitlab_runner_download_url: 'https://gitlab-runner-downloads.s3.amazonaws.com/v{{ gitlab_runner_binary_version }}/binaries'
gitlab_runner_download_path: '/tmp'
gitlab_runner_install_path: '{{ _gitlab_runner_install_path }}'
31 changes: 15 additions & 16 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
---
galaxy_info:
author: antmelekhin
role_name: gitlab_runner
description: An Ansible role to install GitLab Runner.
author: 'antmelekhin'
role_name: 'gitlab_runner'
description: 'An Ansible role to install GitLab Runner.'

license: MIT
license: 'MIT'

min_ansible_version: '2.12'

platforms:
- name: Debian
- name: 'Debian'
versions:
- 'buster'
- 'bullseye'
- 'bookworm'
- name: EL
- name: 'EL'
versions:
- '7'
- '8'
- '9'
- name: Ubuntu
- name: 'Ubuntu'
versions:
- 'bionic'
- 'focal'
- 'jammy'
- name: Windows
- name: 'Windows'
versions:
- '2016'
- '2019'
- 'all'

galaxy_tags:
- gitlab
- runner
- git
- ci
- linux
- windows
- 'ci'
- 'git'
- 'gitlab'
- 'linux'
- 'runner'
- 'windows'

dependencies: []
14 changes: 7 additions & 7 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
role_name_check: 2
dependency:
name: galaxy
name: 'galaxy'
enabled: true
driver:
name: docker
name: 'docker'
platforms:
- name: 'gitlab_runner-${IMAGE:-docker-systemd}-${TAG:-ubuntu-22.04}${TOX_ENVNAME}'
image: '${NAMESPACE:-antmelekhin}/${IMAGE:-docker-systemd}:${TAG:-ubuntu-22.04}'
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- /var/lib/containerd
cgroupns_mode: host
- '/sys/fs/cgroup:/sys/fs/cgroup:rw'
- '/var/lib/containerd'
cgroupns_mode: 'host'
privileged: true
pre_build_image: true
provisioner:
name: ansible
name: 'ansible'
verifier:
name: ansible
name: 'ansible'
6 changes: 3 additions & 3 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
- name: 'Gathering Service Facts'
ansible.builtin.service_facts:

- name: 'Assert that gitlab-runner service is enabled and running'
- name: 'Assert that GitLab Runner service is enabled and running'
ansible.builtin.assert:
that:
- ansible_facts.services['gitlab-runner.service'].state == 'running' or
ansible_facts.services['gitlab-runner.service'].state == 'active'
- ansible_facts.services['gitlab-runner.service'].status == 'enabled' or
ansible_facts.services['gitlab-runner.service'].status == 'enabled'

- name: 'Check current Gitlab Runner version'
- name: 'Check the current GitLab Runner version'
ansible.builtin.command:
cmd: '/usr/bin/gitlab-runner --version'
changed_when: false
register: __gitlab_runner_version_check

- name: 'Version output'
- name: 'The GitLab Runner version output'
ansible.builtin.debug:
var: __gitlab_runner_version_check.stdout_lines[0].split()[1]
29 changes: 13 additions & 16 deletions molecule/vagrant-windows/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
---
role_name_check: 2
dependency:
name: galaxy
name: 'galaxy'
enabled: true
driver:
name: vagrant
name: 'vagrant'
platforms:
- name: instance
- name: 'instance'
box: 'jborean93/WindowsServer2019'
interfaces:
- network_name: private_network
ip: 192.168.56.4
provisioner:
name: ansible
name: 'ansible'
inventory:
host_vars:
instance:
ansible_host: 192.168.56.4
ansible_port: 5986
ansible_user: vagrant
ansible_password: vagrant
ansible_connection: winrm
ansible_winrm_scheme: https
ansible_winrm_transport: ntlm
ansible_winrm_server_cert_validation: ignore
ansible_host: 127.0.0.1
ansible_port: 55986
ansible_user: 'vagrant'
ansible_password: 'vagrant'
ansible_connection: 'winrm'
ansible_winrm_scheme: 'https'
ansible_winrm_transport: 'ntlm'
ansible_winrm_server_cert_validation: 'ignore'
ansible_become: false
verifier:
name: ansible
name: 'ansible'
8 changes: 4 additions & 4 deletions molecule/vagrant-windows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
gather_facts: false

tasks:
- name: 'Check if a gitlab-runner service is installed'
- name: 'Check if GitLab Runner service is installed'
ansible.windows.win_service:
name: 'gitlab-runner'
register: __gitlab_runner_service

- name: 'Assert that windows_exporter service is enabled and running'
- name: 'Assert that GitLab Runner service is enabled and running'
ansible.builtin.assert:
that: "'running' in __gitlab_runner_service.state"

- name: 'Check current Gitlab Runner version'
- name: 'Check the current GitLab Runner version'
ansible.windows.win_command:
cmd: '"C:\Program Files\gitlab-runner\gitlab-runner.exe" --version'
changed_when: false
register: __gitlab_runner_version_check

- name: 'Version output'
- name: 'The GitLab Runner version output'
ansible.builtin.debug:
var: __gitlab_runner_version_check.stdout_lines[0].split()[1]
2 changes: 1 addition & 1 deletion tasks/install-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: 'Debian | Configure the repository and install the GitLab Runner package'
become: true
block:
- name: 'Debian | Ensure dependencies are installed'
- name: 'Debian | Ensure the dependencies are installed'
ansible.builtin.apt:
name:
- 'apt-transport-https'
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: 'RedHat | Configure the repository and install the GitLab Runner package'
become: true
block:
- name: 'RedHat | Ensure dependencies are installed'
- name: 'RedHat | Ensure the dependencies are installed'
ansible.builtin.package:
name: 'yum-utils'
state: 'present'
Expand Down
Loading

0 comments on commit e7514e9

Please sign in to comment.