-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure-runners.yaml
97 lines (94 loc) · 3.42 KB
/
configure-runners.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
- name: Configure action runners.
hosts: action_runners
vars:
# TODO: determine latest actions version automatically
actions_version: 2.321.0
actions_path: /home/exouser/actions-runner
vars_prompt:
- name: token
prompt: "Enter the token (may be empty if not provisioning new runners)"
tasks:
- name: Configure user account
become: yes
block:
- name: Add the user to the docker group
ansible.builtin.user:
name: "exouser"
state: present
groups: docker
append: yes
- name: Check if actions-runner exists
ansible.builtin.stat:
path: "{{ actions_path }}"
register: check_path
- name: Install the Github Actions runner
when: not check_path.stat.exists
block:
- name: Create the actions-runner directory
ansible.builtin.file:
path: "{{ actions_path }}"
state: directory
- name: Download the actions runner
ansible.builtin.unarchive:
src: https://github.com/actions/runner/releases/download/v{{ actions_version }}/actions-runner-linux-x64-{{ actions_version }}.tar.gz
dest: "{{ actions_path }}"
remote_src: yes
- name: Configure the actions runner
ansible.builtin.command: ./config.sh --url https://github.com/glotzerlab --token {{ token }} --unattended --name {{ inventory_hostname }} --labels jetstream2,{{ labels }} --replace
args:
chdir: "{{ actions_path }}"
- name: Install the service
ansible.builtin.command: ./svc.sh install
become: yes
args:
chdir: "{{ actions_path }}"
- name: Start the service
ansible.builtin.command: ./svc.sh start
become: yes
args:
chdir: "{{ actions_path }}"
rescue:
- name: Error, removing actions-runner directory
ansible.builtin.file:
path: "{{ actions_path }}"
state: absent
- name: Configure auto-shutdown and logger
block:
- name: Copy shutdown script
ansible.builtin.copy:
src: auto-shutdown.sh
dest: /home/exouser/auto-shutdown.sh
owner: exouser
mode: '0755'
- name: Configure auto-shutdown cron job
ansible.builtin.cron:
name: auto-shutdown
minute: "*/5"
job: "/home/exouser/auto-shutdown.sh >> /home/exouser/auto-shutdown.log 2>&1"
user: root
become: yes
- name: Copy log-activity script
ansible.builtin.copy:
src: log-activity.sh
dest: /home/exouser/log-activity.sh
owner: exouser
mode: '0755'
- name: Configure log-activity cron job
ansible.builtin.cron:
name: log-activity
minute: "2,32"
job: /home/exouser/log-activity.sh
user: exouser
- name: Copy free space script
ansible.builtin.copy:
src: manage-free-space.sh
dest: /home/exouser/manage-free-space.sh
owner: exouser
mode: '0755'
- name: Configure manage-free-space cron job
ansible.builtin.cron:
name: manage-free-space
minute: "*/10"
job: "/home/exouser/manage-free-space.sh >> /home/exouser/manage-free-space.log 2>&1"
user: root
become: yes