Skip to content

Commit f298ad6

Browse files
Add uninstall variable
1 parent 7f71da0 commit f298ad6

File tree

6 files changed

+182
-109
lines changed

6 files changed

+182
-109
lines changed

README.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
[![GitHub Actions](https://github.com/MonolithProjects/ansible-github_actions_runner/workflows/molecule%20test/badge.svg?branch=master)](https://github.com/MonolithProjects/ansible-github_actions_runner/actions)
77
[![License](https://img.shields.io/github/license/MonolithProjects/ansible-github_actions_runner)](https://github.com/MonolithProjects/ansible-github_actions_runner/blob/master/LICENSE)
88

9-
This role will deploy/redeploy/uninstall and register/unregister local GitHub Actions Runner.
9+
This role will deploy/redeploy/uninstall and register/unregister local GitHub Actions Runner.
10+
It supports both, Organization and Repository Runners.
1011

1112
## Requirements
1213

@@ -26,7 +27,7 @@ Personal Access Token for GitHub account can be created [here](https://github.co
2627
* Weekly tested on:
2728
* CentOS/RHEL 7,8
2829
* Debian 9,10
29-
* Fedora 31,32
30+
* Fedora 32,33
3031
* Ubuntu 16,18,20
3132

3233
**Note:** Fedora 32 and Ubuntu 20 must use Ansible 2.9.8+. Other distros/releases will work also with older 2.8.0+ Ansible.
@@ -45,25 +46,25 @@ runner_dir: /opt/actions-runner
4546
# Version of the GitHub Actions Runner
4647
runner_version: "latest"
4748

48-
# If found, replace already registered runner
49-
replace_runner: yes
49+
# State in which the runner service will be after the role is done (started, stopped, absent)
50+
runner_state: "started"
5051

51-
# If found, delete already existed runner before install
52-
uninstall_runner: no
52+
# If found on the server, delete already existed runner service before install
53+
reinstall_runner: no
5354

54-
# Do not show Ansible logs which may contain sensitive data (registration token)
55+
# Do not show Ansible error logs which may contain sensitive data (registration token)
5556
hide_sensitive_logs: yes
5657

5758
# GitHub address
5859
github_server: "https://github.com"
5960

60-
# Personal Access Token
61+
# Personal Access Token for your GitHub account
6162
access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
6263

63-
# Is it runner for organization or not
64+
# Is it the runner for organization or not
6465
runner_org: no
6566

66-
# Account used for Runner registration (GitHub Repository user with admin rights or Organization owner)
67+
# GitHub Repository user or Organization owner used for Runner registration
6768
# github_account: "youruser"
6869

6970
# Github repository name
@@ -72,12 +73,12 @@ runner_org: no
7273

7374
## Example Playbook
7475

75-
In this example the Ansible role will deploy (or redeploy) the GitHub Actions runner service (latest available version) and register the runner for the GitHub repo.
76-
Runner service will run under the same user as the Ansible is using for ssh connection (*ansible*).
76+
In 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.
77+
Runner service will be stated and will run under the same user as the Ansible is using for ssh connection (*ansible*).
7778

7879
```yaml
7980
---
80-
- name: GitHub Actions Runner
81+
- name: Install GitHub Actions Runner
8182
hosts: all
8283
user: ansible
8384
become: yes
@@ -88,11 +89,11 @@ Runner service will run under the same user as the Ansible is using for ssh conn
8889
- role: monolithprojects.github_actions_runner
8990
```
9091
91-
Same example, but runner will be added to an organization
92+
Same example as above, but runner will be added to an organization.
9293
9394
```yaml
9495
---
95-
- name: GitHub Actions Runner
96+
- name: Install GitHub Actions Runner
9697
hosts: all
9798
user: ansible
9899
become: yes
@@ -103,26 +104,37 @@ Same example, but runner will be added to an organization
103104
- role: monolithprojects.github_actions_runner
104105
```
105106
106-
In this example the Ansible role will deploy (or redeploy) 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`.
107+
In 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`.
108+
The runner service will be *stopped*.
107109

108110
```yaml
109111
---
110-
- name: GitHub Actions Runner
112+
- name: Stop GitHub Actions Runner
111113
hosts: all
112114
become: yes
113115
vars:
114116
- runner_version: "2.165.2"
115117
- runner_user: runner-user
116118
- github_account: github-access-user
117119
- github_repo: my_awesome_repo
120+
- runner_state: "stopped"
118121
roles:
119122
- role: monolithprojects.github_actions_runner
120123
```
121124

122-
By using tag `uninstall` with combination of variable `uninstall_runner: yes`, GitHub Actions runner will be removed from the host and unregistered from the GitHub repository.
125+
In this example the Ansible role will uninstall the runner service and unregister it from the GitHub Repository.
123126

124-
```bash
125-
ansible-playbook playbook.yml --tags uninstall -e "uninstall_runner=yes"
127+
```yaml
128+
---
129+
- name: Uninstall GitHub Actions Runner
130+
hosts: all
131+
become: yes
132+
vars:
133+
- github_account: github-access-user
134+
- github_repo: my_awesome_repo
135+
- runner_state: "absent"
136+
roles:
137+
- role: monolithprojects.github_actions_runner
126138
```
127139

128140
## License

molecule/default/converge.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
---
2-
- name: Converge
2+
- name: Install
33
user: ansible
44
hosts: all
55
become: yes
66
vars:
77
- runner_user: ansible
88
- github_repo: ansible-github_actions_runner-testrepo
99
- github_account: monolithprojects
10+
- runner_state: "stopped"
11+
- runner_version: "2.274.1"
12+
roles:
13+
- robertdebock.epel
14+
- ansible-github_actions_runner
15+
16+
- name: Reinstall
17+
user: ansible
18+
hosts: all
19+
become: yes
20+
vars:
21+
- runner_user: ansible
22+
- github_repo: ansible-github_actions_runner-testrepo
23+
- github_account: monolithprojects
24+
- reinstall_runner: yes
25+
- runner_version: "latest"
1026
roles:
1127
- robertdebock.epel
1228
- ansible-github_actions_runner

molecule/default/molecule.yml

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
driver:
33
name: docker
44
lint: |
5-
set -e
65
yamllint .
76
ansible-lint
87
platforms:
@@ -16,16 +15,16 @@ platforms:
1615
- /sys/fs/cgroup:/sys/fs/cgroup:ro
1716
privileged: yes
1817
pre_build_image: yes
19-
- name: CentOS8
20-
image: monolithprojects/systemd-centos8:latest
21-
command: /sbin/init
22-
tmpfs:
23-
- /run
24-
- /tmp
25-
volumes:
26-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
27-
privileged: yes
28-
pre_build_image: yes
18+
# - name: CentOS8
19+
# image: monolithprojects/systemd-centos8:latest
20+
# command: /sbin/init
21+
# tmpfs:
22+
# - /run
23+
# - /tmp
24+
# volumes:
25+
# - /sys/fs/cgroup:/sys/fs/cgroup:ro
26+
# privileged: yes
27+
# pre_build_image: yes
2928
- name: Fedora32
3029
image: monolithprojects/systemd-fedora32:latest
3130
command: /sbin/init
@@ -36,6 +35,16 @@ platforms:
3635
- /sys/fs/cgroup:/sys/fs/cgroup:ro
3736
privileged: yes
3837
pre_build_image: yes
38+
# - name: Fedora33
39+
# image: monolithprojects/systemd-fedora33:latest
40+
# command: /sbin/init
41+
# tmpfs:
42+
# - /run
43+
# - /tmp
44+
# volumes:
45+
# - /sys/fs/cgroup:/sys/fs/cgroup:ro
46+
# privileged: yes
47+
# pre_build_image: yes
3948
- name: Ubuntu16
4049
image: monolithprojects/systemd-ubuntu16:latest
4150
command: /sbin/init
@@ -46,26 +55,26 @@ platforms:
4655
- /sys/fs/cgroup:/sys/fs/cgroup:ro
4756
privileged: yes
4857
pre_build_image: yes
49-
- name: Ubuntu18
50-
image: monolithprojects/systemd-ubuntu18:latest
51-
command: /sbin/init
52-
tmpfs:
53-
- /run
54-
- /tmp
55-
volumes:
56-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
57-
privileged: yes
58-
pre_build_image: yes
59-
- name: Ubuntu20
60-
image: monolithprojects/systemd-ubuntu20:latest
61-
command: /sbin/init
62-
tmpfs:
63-
- /run
64-
- /tmp
65-
volumes:
66-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
67-
privileged: yes
68-
pre_build_image: yes
58+
# - name: Ubuntu18
59+
# image: monolithprojects/systemd-ubuntu18:latest
60+
# command: /sbin/init
61+
# tmpfs:
62+
# - /run
63+
# - /tmp
64+
# volumes:
65+
# - /sys/fs/cgroup:/sys/fs/cgroup:ro
66+
# privileged: yes
67+
# pre_build_image: yes
68+
# - name: Ubuntu20
69+
# image: monolithprojects/systemd-ubuntu20:latest
70+
# command: /sbin/init
71+
# tmpfs:
72+
# - /run
73+
# - /tmp
74+
# volumes:
75+
# - /sys/fs/cgroup:/sys/fs/cgroup:ro
76+
# privileged: yes
77+
# pre_build_image: yes
6978
- name: Debian9
7079
image: monolithprojects/systemd-debian9:latest
7180
command: /sbin/init
@@ -76,16 +85,16 @@ platforms:
7685
- /sys/fs/cgroup:/sys/fs/cgroup:ro
7786
privileged: yes
7887
pre_build_image: yes
79-
- name: Debian10
80-
image: monolithprojects/systemd-debian10:latest
81-
command: /sbin/init
82-
tmpfs:
83-
- /run
84-
- /tmp
85-
volumes:
86-
- /sys/fs/cgroup:/sys/fs/cgroup:ro
87-
privileged: yes
88-
pre_build_image: yes
88+
# - name: Debian10
89+
# image: monolithprojects/systemd-debian10:latest
90+
# command: /sbin/init
91+
# tmpfs:
92+
# - /run
93+
# - /tmp
94+
# volumes:
95+
# - /sys/fs/cgroup:/sys/fs/cgroup:ro
96+
# privileged: yes
97+
# pre_build_image: yes
8998
provisioner:
9099
name: ansible
91100
playbooks:
@@ -120,7 +129,7 @@ scenario:
120129
- destroy
121130
- syntax
122131
- create
123-
- prepare
132+
# - prepare
124133
- converge
125134
# - idempotence
126135
- cleanup

molecule/organization/converge.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Converge
2+
- name: Install
33
user: ansible
44
hosts: all
55
become: yes
@@ -8,6 +8,23 @@
88
- github_repo: ansible-github_actions_runner-testrepo
99
- github_account: monolithprojects-testorg
1010
- runner_org: yes
11+
- runner_state: "stopped"
12+
- runner_version: "2.274.1"
13+
roles:
14+
- robertdebock.epel
15+
- ansible-github_actions_runner
16+
17+
- name: Reinstall
18+
user: ansible
19+
hosts: all
20+
become: yes
21+
vars:
22+
- runner_user: ansible
23+
- github_repo: ansible-github_actions_runner-testrepo
24+
- github_account: monolithprojects-testorg
25+
- runner_org: yes
26+
# - reinstall_runner: yes
27+
- runner_version: "latest"
1128
roles:
1229
- robertdebock.epel
1330
- ansible-github_actions_runner

0 commit comments

Comments
 (0)