Skip to content

Commit 7052ff8

Browse files
First release
1 parent 5632f6c commit 7052ff8

File tree

5 files changed

+161
-19
lines changed

5 files changed

+161
-19
lines changed

README.md

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,80 @@
1-
WIP
1+
GitHub Actions Runner
22
=========
3+
4+
<a href="https://galaxy.ansible.com/monolithprojects/system_update"><img src="https://img.shields.io/ansible/quality/46110?style=flat&logo=ansible"/></a>
5+
<a href="https://galaxy.ansible.com/monolithprojects/system_update"><img src="https://img.shields.io/ansible/role/d/46110"/></a>
6+
<a href="https://github.com/MonolithProjects/ansible-github_actions_runner/blob/master/LICENSE"><img src="https://img.shields.io/github/license/MonolithProjects/ansible-github_actions_runner"/></a>
7+
8+
This role will deploy local GitHub Actions Runner.
9+
10+
**Note:**
11+
The role is in early development stage.
12+
Role is able to:
13+
- install and cofigure local runner
14+
- register the runner to GitHub
15+
16+
Currently is missing:
17+
- idempotency
18+
- runner unregistration
19+
- automated testing
20+
21+
Requirements
22+
------------
23+
24+
System must have access to the packages repository (Internet, Red Hat Satellite, etc.).
25+
26+
CentOS/Fedora systems require EPEL repository.
27+
28+
29+
Role Variables
30+
--------------
31+
32+
This is a copy from `defaults/main.yml`
33+
34+
```yaml
35+
# Directory where the local runner will be installed
36+
runner_dir: "/opt/actions-runner"
37+
38+
# Version of the GitHub Actions Runner
39+
runner_version: "2.165.2"
40+
41+
# GitHub Access token for the repository
42+
access_token: "{{ lookup('env', 'GITHUB_ACCESS_TOKEN') }}"
43+
44+
# GitHub address
45+
github_server: "https://github.com"
46+
47+
# GitHub account name
48+
# github_account: "yourgithubname"
49+
50+
# Github repository name
51+
# github_repo: "yourreponame"
52+
```
53+
54+
Example Playbook
55+
----------------
56+
57+
Simple example.
58+
59+
```yaml
60+
---
61+
- name: Converge
62+
hosts: all
63+
become: yes
64+
vars:
65+
- runner_user: runner
66+
- github_account: example
67+
- github_repo: example"
68+
roles:
69+
- role: ansible-github_actions_runner
70+
```
71+
72+
License
73+
-------
74+
75+
MIT
76+
77+
Author Information
78+
------------------
79+
80+
Created in 2020 by Michal Muransky

defaults/main.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
---
2+
# Directory where the local runner will be installed
23
runner_dir: "/opt/actions-runner"
4+
5+
# Version of the GitHub Actions Runner
36
runner_version: "2.165.2"
4-
access_token: "{{ GITHUB_ACCESS_TOKEN }}"
7+
8+
# GitHub Access token for the repository
9+
access_token: "{{ lookup('env', 'GITHUB_ACCESS_TOKEN') }}"
10+
11+
# GitHub address
512
github_server: "https://github.com"
13+
14+
# GitHub account name
615
github_account: "monolithprojects"
16+
17+
# Github repository name
718
github_repo: "ansible-home_cluster"

meta/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
description: Deploy Github Actions private runner
66
company: MonolithProjects
77
license: "license (MIT)"
8-
min_ansible_version: 2.4
8+
min_ansible_version: 2.8
99
platforms:
1010
- name: EL
1111
versions:
@@ -20,7 +20,6 @@
2020
- stretch
2121
- name: Ubuntu
2222
versions:
23-
- trusty
2423
- xenial
2524
- bionic
2625
galaxy_tags:

tasks/install_deps.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
---
2-
- name: Install dependencies on Debian/Ubuntu systems
2+
- name: Install dependencies on Debian Stretch / Ubuntu Xenial systems
33
package:
4-
name:
4+
pkg:
5+
- liblttng-ust0
6+
- libkrb5-3
7+
- zlib1g
8+
- libssl1.0.0
9+
- libicu55
10+
state: present
11+
update_cache: yes
12+
when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "9") or
13+
(ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "16")
14+
tags:
15+
- install
16+
17+
- name: Install dependencies on Debian Buster / Ubuntu Bionic systems
18+
package:
19+
pkg:
520
- liblttng-ust0
621
- libkrb5-3
722
- zlib1g
823
- libssl1.1
9-
- libicu63
24+
- libicu60
1025
state: present
11-
when: (ansible_facts['distribution'] == "Debian") or
12-
(ansible_facts['distribution'] == "Ubuntu")
13-
become: yes
26+
update_cache: yes
27+
when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "10") or
28+
(ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "18")
29+
tags:
30+
- install
1431

1532
- name: Install dependencies on RHEL/CentOS/Fedora systems
1633
package:
@@ -21,7 +38,8 @@
2138
- zlib
2239
- libicu
2340
state: present
24-
when: (ansible_facts['distribution'] == "RedHat") or
25-
(ansible_facts['distribution'] == "CentOS") or
26-
(ansible_facts['distribution'] == "Fedora")
27-
become: yes
41+
when: (ansible_distribution == "RedHat") or
42+
(ansible_distribution == "CentOS") or
43+
(ansible_distribution == "Fedora")
44+
tags:
45+
- install

tasks/install_runner.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,58 @@
44
path: "{{ runner_dir }}"
55
state: directory
66
mode: "0755"
7-
owner: "{{ ansible_user }}"
8-
group: "{{ ansible_user }}"
7+
owner: "{{ runner_user }}"
8+
group: "{{ runner_user }}"
99
recurse: yes
10-
become: yes
10+
tags:
11+
- install
1112

1213
- name: Download runner package
1314
local_action:
1415
module: get_url
1516
url: "https://github.com/actions/runner/releases/download/v{{ runner_version }}/actions-runner-linux-x64-{{ runner_version }}.tar.gz"
1617
dest: ./actions-runner-linux.tar.gz
1718
run_once: yes
19+
tags:
20+
- install
1821

1922
- name: Unarchive package
2023
unarchive:
2124
src: ./actions-runner-linux.tar.gz
2225
dest: "{{ runner_dir }}/"
26+
owner: "{{ runner_user }}"
27+
tags:
28+
- install
2329

24-
- name: Run
25-
command: "{{ runner_dir }}/config.sh --url {{ github_server }}/{{ github_account }}/{{ github_repo }} --token {{ lookup('env', 'GITHUB_ACCESS_TOKEN') }}"
30+
# - name: Sstop and disable Github Actions Runner service if it is running
31+
# systemd:
32+
# name: "actions.runner.{{ github_account }}-{{ github_repo }}.{{ ansible_hostname }}"
33+
# state: stopped
34+
# enabled: no
35+
# tags:
36+
# - uninstall
37+
38+
# - name: Unregister runner
39+
# command: "{{ runner_dir }}/./config.sh remove --token {{ access_token }} --unattended"
40+
# become_user: "{{ runner_user }}"
41+
# tags:
42+
# - uninstall
43+
44+
- name: Register runner
45+
command: "{{ runner_dir }}/config.sh --url {{ github_server }}/{{ github_account }}/{{ github_repo }} --token {{ access_token }} --unattended"
46+
become_user: "{{ runner_user }}"
47+
tags:
48+
- install
49+
50+
- name: Install service
51+
shell: "cd {{ runner_dir }} && ./svc.sh install"
52+
tags:
53+
- install
54+
55+
- name: Start and enable Github Actions Runner service
56+
systemd:
57+
name: "actions.runner.{{ github_account }}-{{ github_repo }}.{{ ansible_hostname }}"
58+
state: started
59+
enabled: yes
60+
tags:
61+
- install

0 commit comments

Comments
 (0)