-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathuninstall_runner_unix.yml
35 lines (31 loc) · 1.13 KB
/
uninstall_runner_unix.yml
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
---
- name: Check if runner service name file exist
ansible.builtin.stat:
path: "{{ runner_dir }}/.service"
register: runner_service_file_path
- name: Uninstall runner # noqa no-changed-when
ansible.builtin.command: "./svc.sh uninstall"
args:
chdir: "{{ runner_dir }}"
changed_when: true
become: "{{ 'false' if ansible_facts.system == 'Darwin' else 'true' }}"
when: runner_service_file_path.stat.exists
- name: Check GitHub Actions runner file
ansible.builtin.stat:
path: "{{ runner_dir }}/.runner"
register: runner_file
- name: Unregister runner from the GitHub # noqa no-changed-when
environment:
RUNNER_ALLOW_RUNASROOT: "1"
ansible.builtin.command: "./config.sh remove --token {{ registration.json.token }} --name '{{ runner_name }}' --unattended"
args:
chdir: "{{ runner_dir }}"
become: true
become_user: "{{ runner_user }}"
no_log: "{{ hide_sensitive_logs | bool }}"
changed_when: true
when: runner_name in registered_runners.json.runners|map(attribute='name')|list and runner_file.stat.exists
- name: Delete runner directory
ansible.builtin.file:
path: "{{ runner_dir }}"
state: absent