Code Monkey home page Code Monkey logo

ansible-github-actions-runner's Introduction

GitHub Actions self-hosted Runner Ansible role

An Ansible role that installs and configures GitHub Actions self-hosted Runners inside one or multiple hosts, you can re-use it for many different URLs (repositories or organizations) inside the same host in order to re-use it as much as possible.

Main goals of this role:

  • avoid waste: re-use the same host to provide a build environment for multiple repositories or organizations;
  • idempotence: executing the role many times won't make anything break, steps have checks that validate whether or not they should be executed;

Variables

For an exhaustive list of variables check the defaults file. Ideally, all values will have commentaries describing what are their purposes and by the default value you can tell the type.

Required variables

Following values are required since there is no way to register the self-hosted Runner without them

Name Description
gh_runner_config_url GitHub Repository or Organization URL
gh_runner_config_token GitHub Registration token to authenticate the host

Example Playbook

Simplest use case: Single repository configuration on one host.

- hosts: foo
  roles:
    - role: macunha1.github_actions_runner
      vars:
        gh_runner_config_labels:
          - linux
          - self-hosted

        gh_runner_config_url: https://github.com/macunha1/ansible-github-actions-runner
        gh_runner_config_token: AC5TNLJP9SBAFNEKKLLBLF264J8XO

Complex use case to which this role was created for

- hosts: foo
  roles:
    - role: macunha1.github_actions_runner
      vars:
        gh_runner_config_labels:
          - linux
          - self-hosted

        gh_runner_config_url: https://github.com/macunha1/ansible-github-actions-runner
        gh_runner_config_token: AC5TNLJP9SBAFNEKKLLBLF264J8XO

    - role: macunha1.github_actions_runner
      vars:
        gh_runner_config_url: https://github.com/macunha1/another-repository
        gh_runner_config_token: AC5CQV3IJRR2OAFGEFCPJ0WJPJQXO

    - role: macunha1.github_actions_runner
      vars:
        gh_runner_config_url: https://github.com/macunha-acme-corp
        gh_runner_config_token: ACYWUR9MHGR9U58C34W9ZK00UNBF

Note that despite using the same host, each one of these GitHub Actions Runner configuration will have its own path and credentials. Therefore, they can live well in harmony without killing each other.

Contribute

PRs Welcome

Feel free to fill an issue containing feature request(s), or (even better) to send me a Pull request, I would be happy to collaborate with you.

If this role didn't work for you, or if you found some bug during the execution, let me know.

ansible-github-actions-runner's People

Contributors

chrisavl avatar john-jam avatar macunha1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ansible-github-actions-runner's Issues

Cannot register multiple runners for the same org.

I was trying to create multiple github runnner for an Org, using indididual repo keys,

- name: Install Runner1 on github-runners-ubuntu
  hosts: github-runners-ubuntu

  roles:
    - role: ansible-github-actions-runner
      vars:
        gh_runner_config_labels:
          - ubuntu22
          - linux
          - self-hosted
        gh_runner_config_url: https://github.com/acme.net
        gh_runner_config_token: APERFECTLYFINETOKEN
        gh_runner_config_name: ubuntu-runner1
        gh_runner_allow_runasroot: "Refuse"

    - role: ansible-github-actions-runner
      vars:
        gh_runner_config_labels:
          - ubuntu22
          - linux
          - self-hosted
        gh_runner_config_url: https://github.com/acme.net
        gh_runner_config_token: ANOTHERPERFECTLYFINETOKEN
        gh_runner_config_name: ubuntu-runner2
        gh_runner_allow_runasroot: "Refuse"

I expected this to create two runners for on the host and that they both would be online.
Instead it replaced the first runner with the second one.
image

Ive been looking at the code to understand why its replacing the existing one instead of generating a separate one, but Im not able to figure it out as of yet so figured Id put in an Issue.

De-register runner: must not run with sudo

Hi, thanks for this runner. I was able to create and register the runner but when I want to uninstall it, it says "must not run with sudo"

which config should I change so this step wont return error?
this is what I put into my yml

- hosts: all
  roles:
    - role: roles/macunha1.github_actions_runner
      vars:
        gh_runner_config_labels:
          - linux
          - self-hosted
        gh_runner_remove_host: true
        gh_runner_allow_runasroot: "0"
        gh_runner_config_url: some_repo
        gh_runner_config_token: some_token

Multiple operating systems

Hi,
This looks like a great ansible role!
I occasionally need to install a set of runners across multiple platforms: Linux, MacOS, Windows. There are multiple ways to add Windows, perhaps the easiest one would be in main.yml where there are three includes, add three more includes such as "../includes-win/install.yaml". Conditionally check on the operating system for all the includes. Would you be interested in a pull request which adds such functionality? Another option is less integrated. Clone the role, modify everything to support (only) windows. Then there are two separate Ansible roles.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.