{"id":14984438,"url":"https://github.com/monolithprojects/ansible-github_actions_runner","last_synced_at":"2025-05-16T11:04:13.521Z","repository":{"id":38083731,"uuid":"240944701","full_name":"MonolithProjects/ansible-github_actions_runner","owner":"MonolithProjects","description":"Ansible Role to deploy GitHub Actions self-hosted runner","archived":false,"fork":false,"pushed_at":"2025-03-11T19:50:08.000Z","size":413,"stargazers_count":203,"open_issues_count":13,"forks_count":82,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-16T11:04:11.994Z","etag":null,"topics":["actions","ansible","ansible-role","cicd","github","github-actions-runner","local","local-runner","private","runner","runner-service","self-hosted"],"latest_commit_sha":null,"homepage":"https://galaxy.ansible.com/ui/standalone/roles/monolithprojects/github_actions_runner/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MonolithProjects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["monolithprojects"]}},"created_at":"2020-02-16T18:39:19.000Z","updated_at":"2025-05-15T22:31:15.000Z","dependencies_parsed_at":"2023-10-05T11:57:02.431Z","dependency_job_id":"42276561-5d34-41a1-9dae-371f896fc69f","html_url":"https://github.com/MonolithProjects/ansible-github_actions_runner","commit_stats":{"total_commits":448,"total_committers":39,"mean_commits":"11.487179487179487","dds":0.1941964285714286,"last_synced_commit":"68d961c304a1cc58512c0403ff9d50f044cee1fa"},"previous_names":[],"tags_count":83,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MonolithProjects%2Fansible-github_actions_runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MonolithProjects%2Fansible-github_actions_runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MonolithProjects%2Fansible-github_actions_runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MonolithProjects%2Fansible-github_actions_runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MonolithProjects","download_url":"https://codeload.github.com/MonolithProjects/ansible-github_actions_runner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518384,"owners_count":22084374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","ansible","ansible-role","cicd","github","github-actions-runner","local","local-runner","private","runner","runner-service","self-hosted"],"created_at":"2024-09-24T14:09:03.389Z","updated_at":"2025-05-16T11:04:13.498Z","avatar_url":"https://github.com/MonolithProjects.png","language":null,"readme":"# GitHub Actions Runner\n\n[![awesome-runners](https://img.shields.io/badge/listed%20on-awesome--runners-blue.svg)](https://github.com/jonico/awesome-runners)\n[![Role version](https://img.shields.io/github/v/release/MonolithProjects/ansible-github_actions_runner)](https://galaxy.ansible.com/ui/standalone/roles/monolithprojects/github_actions_runner/)\n[![Role downloads](https://img.shields.io/ansible/role/d/MonolithProjects/github_actions_runner\n)](https://galaxy.ansible.com/ui/standalone/roles/monolithprojects/github_actions_runner/)\n[![Molecule test](https://github.com/MonolithProjects/ansible-github_actions_runner/actions/workflows/tests.yml/badge.svg)](https://github.com/MonolithProjects/ansible-github_actions_runner/actions/workflows/tests.yml)\n[![License](https://img.shields.io/github/license/MonolithProjects/ansible-github_actions_runner)](https://github.com/MonolithProjects/ansible-github_actions_runner/blob/main/LICENSE)\n\nThis role will deploy/redeploy/uninstall and register/unregister local GitHub Actions Runner on Linux and macOS Systems (see [compatibility list](#supported-operating-systems) ).\nIt supports Enterprise, Organization and Repository Runners.\n\n\u003e [!IMPORTANT]  \n\u003e My Galaxy account is currently broken. Please use Github for installation source.  \n\u003e\n\u003e **CLI:**\n\u003e\n\u003e```yml\n\u003eansible-galaxy role install git+https://github.com/MonolithProjects/ansible-github_actions_runner.git,1.21.1\n\u003e```\n\u003e\n\u003e**requirements.yml:**  \n\u003e\n\u003e```yml\n\u003eroles:\n\u003e  - name: monolithprojects.github_actions_runner\n\u003e    version: 1.21.1\n\u003e    src: https://github.com/MonolithProjects/ansible-github_actions_runner\n\u003e```\n\n## Requirements\n\n* System must have access to the GitHub API.\n\n* The role require Personal Access Token to access the GitHub. The token can be set as `PERSONAL_ACCESS_TOKEN` environment variable.\n\n\u003e **Note**  \n\u003e The token must have the `repo` scope (when creating a repo runner), the `admin:org` scope (when creating a runner for an organization),\n\u003e the `manage_runners:enterprise` scope (when creating a enterprise runner).\nPersonal Access Token for GitHub account can be created [here](https://github.com/settings/tokens).\n\n\u003e **Warning**  \n\u003e Never store you personal access token in the GitHub repository. Use [GitHub Secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) or some different secrets service.\n\n* Runner user has to be pre-created.\n  Recommended role: `monolithprojects.user_management`\n\n* CentOS systems require EPEL repository.\n  Recommended role: `robertdebock.epel`\n\n## Supported CPU architecture\n\n* ARM, ARM64 (dependencies installation is not covered by this role)\n* AMD64, x86_64\n\n## Supported Operating Systems\n\n* Red Hat Enterprise Linux 7+\n* CentOS 7+\n* Rocky Linux 8+\n* Fedora 29+\n* Debian 9+\n* Ubuntu 18.04+\n* MacOS High Sierra +\n* Windows\n\n## Weekly tested on:\n\n* Debian 11\n* Fedora 39\n* Rocky Linux 9\n* Ubuntu 20,22\n\n## Role Variables\n\nThis is a copy from `defaults/main.yml`\n\n```yaml\n---\n# Runner user - user under which is the local runner service running\nrunner_user: \"{{ lookup('env', 'USER') }}\"\n\n# Directory where the local runner will be installed\nrunner_dir: \"{{ 'C:\\\\actions-runner' if ansible_facts.system == 'Win32NT' else '/opt/actions-runner' }}\"\n\n# Version of the GitHub Actions Runner\nrunner_version: \"latest\"\n\n# State in which the runner service will be after the role is done (started, stopped, absent)\nrunner_state: \"started\"\n\n# If found on the server, delete already existing runner service and install it again\nreinstall_runner: false\n\n# Do not show Ansible logs which may contain sensitive data (registration token)\nhide_sensitive_logs: true\n\n# GitHub address\ngithub_url: \"https://github.com\"\n\n# GitHub API\ngithub_api_url: \"https://api.github.com\"\n\n# Number of runners to list per page\ngithub_api_runners_per_page: 100\n\n# Personal Access Token for your GitHub account\naccess_token: \"{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}\"\n\n# Is it the runner for organization or not?\nrunner_org: false\n\n# Labels to apply to the runner\nrunner_labels: []\n\n# Group to add organization runner to\nrunner_group: \"\"\n\n# GitHub Actions Runner repository (change it if you want to use custom Actions Runner fork)\nrunner_download_repository: \"actions/runner\"\n\n# Extra arguments to pass to `config.sh`.\n# Several arguments must be set as one string (i.e. \"--ephemeral --my_special_fork\")\nrunner_extra_config_args: \"\"\n\n# Name to assign to this runner in GitHub (System hostname as default)\nrunner_name: \"{{ ansible_facts.hostname }}\"\n\n# Set to false when provisioning runners for more than one repository within single play\nall_runners_in_same_repo: true\n\n# GitHub Repository user or Organization owner used for Runner registration\n# github_account: \"youruser\"\n\n# GitHub repository owner name (if other than github_account)\n# github_owner: \"yourorg\"\n\n# Github repository name\n# github_repo: \"yourrepo\"\n\n# GitHub Enterprise name\n# github_enterprise: \"yourenterprise\"\n\n# Runner user Windows password - the logon password for the service user when running on windows.\n# runner_user_win_password: \"{{ lookup('env', 'PASS') }}\"\n\n# Configuring a custom .env file\n# custom_env: |\n# http_proxy=YOUR_URL_HERE\n# ftp_proxy=YOUR_URL_HERE\n# HTTPS_PROXY=YOUR_URL_HERE\n# https_proxy=YOUR_URL_HERE\n# no_proxy=localhost,127.0.0.1,127.0.0.2\n# HTTP_PROXY=\n```\n\n## Example Playbooks\n\nIn this example the Ansible role will install (or update) the GitHub Actions Runner service (latest available version). The runner will be registered for *my_awesome_repo* GitHub repo.\nRunner service will be stated and will run under the same user as the Ansible is using for ssh connection (*ansible*).\n\n```yaml\n---\n- name: Install GitHub Actions Runner\n  hosts: all\n  user: ansible\n  become: yes\n  vars:\n    - github_account: github-access-user\n    - github_repo: my_awesome_repo\n  roles:\n    - role: monolithprojects.github_actions_runner\n```\n\nSame example as above, but runner will be added to an organization and deployed on GitHub Enterprise Server.\n\n```yaml\n---\n- name: Install GitHub Actions Runner\n  hosts: all\n  user: ansible\n  become: yes\n  vars:\n    - github_account: my_awesome_org\n    - runner_org: yes\n    - runner_on_ghes: yes\n  roles:\n    - role: monolithprojects.github_actions_runner\n```\n\nIf you have a Github Enterprise Cloud license and you want to manage all the self-hosted runners from the enterprise:\n\n```yaml\n---\n- name: Install GitHub Actions Runner\n  hosts: all\n  user: automation\n  become: yes\n  vars:\n    - github_enterprise: my_awesome_enterprise\n    - runner_org: no\n  roles:\n    - role: monolithprojects.github_actions_runner\n```\n\nIn this example the Ansible role will deploy (or update) the GitHub Actions runner service (version 2.165.2) and register the runner for the GitHub repo. Runner service will run under the user `runner-user`. Runner will be registered with two labels.\nThe runner service will be *stopped* and disabled. Runner will use custom environment variables (from file named `.env` in the self-hosted runner application directory).\n\n```yaml\n---\n- name: Stop GitHub Actions Runner\n  hosts: all\n  become: yes\n  vars:\n    - runner_version: \"2.165.2\"\n    - runner_user: runner-user\n    - github_account: github-access-user\n    - github_repo: my_awesome_repo\n    - runner_state: \"stopped\"\n    - runner_labels:\n        - production\n        - west\n    - custom_env: |\n        HTTP_PROXY=http://proxy.local:8080\n        http_proxy=http://proxy.local:8080\n        HTTPS_PROXY=http://proxy.local:8080\n        https_proxy=http://proxy.local:8080\n        no_proxy=localhost,127.0.0.1,127.0.0.2\n\n  roles:\n    - role: monolithprojects.github_actions_runner\n```\n\nIn this example the Ansible role will uninstall the runner service and unregister it from the GitHub Repository.\n\n```yaml\n---\n- name: Uninstall GitHub Actions Runner\n  hosts: all\n  become: yes\n  vars:\n    - github_account: github-access-user\n    - github_repo: my_awesome_repo\n    - runner_state: \"absent\"\n  roles:\n    - role: monolithprojects.github_actions_runner\n```\n\n## Testing with Molecule\n\n[Molecule](https://molecule.readthedocs.io/) is a testing framework for Ansible. This section is for code contributors.\n\n### Prerequisites\n\n* Python\n* Docker\n* Ansible\n* Molecule\n\n### Installation\n\n1. Install Python, Docker, and Ansible if you haven't already.\n2. Install Molecule and its Docker driver with pip:\n\n```bash\npip install \"molecule-plugins[docker]\"\n```\nSure, here's a basic example of how you might structure a README to explain how to test the `monolithprojects.github_actions_runner` Ansible role with Molecule:\n\n```markdown\n# monolithprojects.github_actions_runner\n\nThis is an Ansible role for setting up GitHub Actions runners.\n\n## Testing with Molecule\n\n[Molecule](https://molecule.readthedocs.io/) is a testing framework for Ansible that we use to test the `monolithprojects.github_actions_runner` role.\n\n### Prerequisites\n\n- Python\n- Docker\n- Ansible\n- Molecule\n\n### Installation\n\n1. Install Python, Docker, and Ansible if you haven't already.\n2. Install Molecule and its Docker driver with pip:\n\n```bash\npip install molecule[docker]\n```\n\n### Running Tests\n\n1. Navigate to the role's directory:\n\n```bash\ncd path/to/monolithprojects.github_actions_runner\n```\n\n2. Set Environment variables\n\n```bash\nexport PERSONAL_ACCESS_TOKEN=your_github_pat # Your Personal Access Token to Github\nexport GITHUB_ACCOUNT=your_account # Your Github Account\nexport GITHUB_REPO=your_repository # Github Repository where you want to setup the Runner\n```\n\n3. Run Molecule:\n\n```bash\nmolecule test\n```\n\nThis will run the molecule test, create a Docker container, run the role against it, run any associated `default` tests (see [molecule/default](./molecule/default) directory), and then destroy the container.\n\nFor more information on using Molecule, see the [Molecule documentation](https://molecule.readthedocs.io/).\n\n## License\n\nMIT\n\n## Author Information\n\nCreated in 2020 by Michal Muransky\n","funding_links":["https://github.com/sponsors/monolithprojects"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonolithprojects%2Fansible-github_actions_runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonolithprojects%2Fansible-github_actions_runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonolithprojects%2Fansible-github_actions_runner/lists"}