Skip to content

Commit b7da270

Browse files
Merge branch 'develop' into runner-name
2 parents 880ca5e + 61c25d7 commit b7da270

File tree

17 files changed

+191
-115
lines changed

17 files changed

+191
-115
lines changed

.github/workflows/galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
release:
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-18.04
1212
steps:
1313
- name: galaxy
1414
uses: robertdebock/[email protected]

.github/workflows/lifecycle.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: molecule lint
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- feature/*
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-18.04
11+
strategy:
12+
fail-fast: true
13+
steps:
14+
- name: checkout
15+
uses: actions/checkout@v2
16+
with:
17+
path: "${{ github.repository }}"
18+
- name: Molecule for Ansible - lint
19+
uses: MonolithProjects/[email protected]
20+
with:
21+
molecule_command: lint

.github/workflows/main.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,30 @@ on:
44
push:
55
branches:
66
- master
7+
pull_request:
8+
types: [opened, synchronize, reopened]
79
schedule:
810
- cron: '0 6 * * 0'
911
jobs:
1012
test:
11-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-18.04
1214
strategy:
13-
fail-fast: false
15+
fail-fast: true
1416
steps:
1517
- name: checkout
1618
uses: actions/checkout@v2
1719
with:
1820
path: "${{ github.repository }}"
19-
- name: Molecule for Ansible
20-
uses: MonolithProjects/action-molecule@v1.3.0
21+
- name: Molecule for Ansible - GHR Repository
22+
uses: MonolithProjects/action-molecule@v1.4.0
2123
env:
22-
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
24+
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
25+
with:
26+
molecule_command: test
27+
- name: Molecule for Ansible - GHR Organization
28+
uses: MonolithProjects/[email protected]
29+
env:
30+
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
31+
with:
32+
molecule_command: test
33+
scenario: organization

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,10 +27,10 @@ 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

32-
**Note:** Fedora 32 and Ubuntu 20 must use Ansible 2.9.8+. Other distros/releases will work also with older 2.8.0+ Ansible.
33+
**Note:** Fedora 32+ and Ubuntu 20 must use Ansible 2.9.8+. Other distros/releases will work also with older 2.8.0+ Ansible.
3334

3435
## Role Variables
3536

@@ -45,22 +46,22 @@ 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

6667
# Name to assign to this runner in GitHub
@@ -78,12 +79,12 @@ runner_name: "{{ lookup('pipe', 'hostname') }}"
7879

7980
## Example Playbook
8081

81-
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.
82-
Runner service will run under the same user as the Ansible is using for ssh connection (*ansible*).
82+
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.
83+
Runner service will be stated and will run under the same user as the Ansible is using for ssh connection (*ansible*).
8384

8485
```yaml
8586
---
86-
- name: GitHub Actions Runner
87+
- name: Install GitHub Actions Runner
8788
hosts: all
8889
user: ansible
8990
become: yes
@@ -94,11 +95,11 @@ Runner service will run under the same user as the Ansible is using for ssh conn
9495
- role: monolithprojects.github_actions_runner
9596
```
9697
97-
Same example, but runner will be added to an organization
98+
Same example as above, but runner will be added to an organization.
9899
99100
```yaml
100101
---
101-
- name: GitHub Actions Runner
102+
- name: Install GitHub Actions Runner
102103
hosts: all
103104
user: ansible
104105
become: yes
@@ -109,26 +110,37 @@ Same example, but runner will be added to an organization
109110
- role: monolithprojects.github_actions_runner
110111
```
111112
112-
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`.
113+
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`.
114+
The runner service will be *stopped*.
113115

114116
```yaml
115117
---
116-
- name: GitHub Actions Runner
118+
- name: Stop GitHub Actions Runner
117119
hosts: all
118120
become: yes
119121
vars:
120122
- runner_version: "2.165.2"
121123
- runner_user: runner-user
122124
- github_account: github-access-user
123125
- github_repo: my_awesome_repo
126+
- runner_state: "stopped"
124127
roles:
125128
- role: monolithprojects.github_actions_runner
126129
```
127130

128-
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.
131+
In this example the Ansible role will uninstall the runner service and unregister it from the GitHub Repository.
129132

130-
```bash
131-
ansible-playbook playbook.yml --tags uninstall -e "uninstall_runner=yes"
133+
```yaml
134+
---
135+
- name: Uninstall GitHub Actions Runner
136+
hosts: all
137+
become: yes
138+
vars:
139+
- github_account: github-access-user
140+
- github_repo: my_awesome_repo
141+
- runner_state: "absent"
142+
roles:
143+
- role: monolithprojects.github_actions_runner
132144
```
133145

134146
## License

defaults/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ runner_dir: /opt/actions-runner
88
# Version of the GitHub Actions Runner
99
runner_version: "latest"
1010

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

14-
# If found, delete already existed runner before install
15-
uninstall_runner: no
14+
# If found on the server, delete already existed runner service before install
15+
reinstall_runner: no
1616

1717
# Do not show Ansible logs which may contain sensitive data (registration token)
1818
hide_sensitive_logs: yes
@@ -23,7 +23,7 @@ github_server: "https://github.com"
2323
# Personal Access Token for your GitHub account
2424
access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
2525

26-
# Is it runner for organization or not
26+
# Is it the runner for organization or not
2727
runner_org: no
2828

2929
# Name to assign to this runner in GitHub

molecule/default/cleanup.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Cleanup
3+
user: ansible
4+
hosts: all
5+
become: yes
6+
vars:
7+
- runner_user: ansible
8+
- github_repo: ansible-github_actions_runner-testrepo
9+
- github_account: monolithprojects
10+
- runner_state: absent
11+
roles:
12+
- ansible-github_actions_runner

molecule/default/converge.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
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_version: "latest"
11+
roles:
12+
- robertdebock.epel
13+
- ansible-github_actions_runner
14+
15+
- name: Reinstall
16+
user: ansible
17+
hosts: all
18+
become: yes
19+
vars:
20+
- runner_user: ansible
21+
- github_repo: ansible-github_actions_runner-testrepo
22+
- github_account: monolithprojects
23+
- reinstall_runner: yes
24+
- runner_version: "latest"
1025
roles:
1126
- robertdebock.epel
1227
- ansible-github_actions_runner

molecule/default/molecule.yml

Lines changed: 13 additions & 4 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:
@@ -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
@@ -105,7 +114,8 @@ provisioner:
105114
Ubuntu20:
106115
ansible_python_interpreter: /usr/bin/python3
107116
verifier:
108-
name: ansible
117+
name: testinfra
118+
directory: tests
109119
dependency:
110120
name: galaxy
111121
options:
@@ -116,11 +126,10 @@ scenario:
116126
test_sequence:
117127
- dependency
118128
- lint
119-
- cleanup
120129
- destroy
121130
- syntax
122131
- create
123-
- prepare
132+
# - prepare
124133
- converge
125134
# - idempotence
126135
- cleanup
Binary file not shown.

0 commit comments

Comments
 (0)