|
2 | 2 | - name: Info collections |
3 | 3 | check_mode: false |
4 | 4 | block: |
5 | | - - name: Set complete API url for repo runner |
6 | | - ansible.builtin.set_fact: |
7 | | - github_full_api_url: "{{ github_api_url }}/repos/{{ github_owner | default(github_account) }}/{{ github_repo }}/actions/runners" |
8 | | - when: not runner_org |
| 5 | + - name: Set complete API url for repo runner |
| 6 | + ansible.builtin.set_fact: |
| 7 | + github_full_api_url: "{{ github_api_url }}/repos/{{ github_owner | default(github_account) }}/{{ github_repo }}/actions/runners" |
| 8 | + when: not runner_org and not github_enterprise |
9 | 9 |
|
10 | | - - name: Set complete API url for org runner |
11 | | - ansible.builtin.set_fact: |
12 | | - github_full_api_url: "{{ github_api_url }}/orgs/{{ github_owner | default(github_account) }}/actions/runners" |
13 | | - when: runner_org | bool |
| 10 | + - name: Set complete API url for org runner |
| 11 | + ansible.builtin.set_fact: |
| 12 | + github_full_api_url: "{{ github_api_url }}/orgs/{{ github_owner | default(github_account) }}/actions/runners" |
| 13 | + when: runner_org | bool and not github_enterprise |
14 | 14 |
|
15 | | - - name: Get registration token (RUN ONCE) |
16 | | - ansible.builtin.uri: |
17 | | - url: "{{ github_full_api_url }}/registration-token" |
18 | | - headers: |
19 | | - Authorization: "token {{ access_token }}" |
20 | | - Accept: "application/vnd.github.v3+json" |
21 | | - method: POST |
22 | | - status_code: 201 |
23 | | - force_basic_auth: yes |
24 | | - register: registration |
25 | | - run_once: true |
| 15 | + - name: Set complete API url for enterprise runner |
| 16 | + ansible.builtin.set_fact: |
| 17 | + github_full_api_url: "{{ github_api_url }}/enterprises/{{ github_enterprise }}/actions/runners" |
| 18 | + when: github_enterprise |
26 | 19 |
|
27 | | - - name: Check currently registered runners for repo (RUN ONCE) |
28 | | - ansible.builtin.uri: |
29 | | - url: "{{ github_full_api_url }}" |
30 | | - headers: |
31 | | - Authorization: "token {{ access_token }}" |
32 | | - Accept: "application/vnd.github.v3+json" |
33 | | - method: GET |
34 | | - status_code: 200 |
35 | | - force_basic_auth: yes |
36 | | - register: registered_runners |
37 | | - run_once: true |
| 20 | + - name: Get registration token (RUN ONCE) |
| 21 | + ansible.builtin.uri: |
| 22 | + url: "{{ github_full_api_url }}/registration-token" |
| 23 | + headers: |
| 24 | + Authorization: "token {{ access_token }}" |
| 25 | + Accept: "application/vnd.github.v3+json" |
| 26 | + method: POST |
| 27 | + status_code: 201 |
| 28 | + force_basic_auth: true |
| 29 | + register: registration |
| 30 | + run_once: true |
38 | 31 |
|
39 | | - - name: Get Runner User IDs |
40 | | - ansible.builtin.command: id -u "{{ runner_user }}" |
41 | | - changed_when: false |
42 | | - register: runner_user_id |
| 32 | + - name: Check currently registered runners (RUN ONCE) |
| 33 | + ansible.builtin.uri: |
| 34 | + url: "{{ github_full_api_url }}" |
| 35 | + headers: |
| 36 | + Authorization: "token {{ access_token }}" |
| 37 | + Accept: "application/vnd.github.v3+json" |
| 38 | + method: GET |
| 39 | + status_code: 200 |
| 40 | + force_basic_auth: true |
| 41 | + register: registered_runners |
| 42 | + run_once: true |
43 | 43 |
|
44 | | - - name: Get Runner Group IDs |
45 | | - ansible.builtin.command: id -g "{{ runner_user }}" |
46 | | - changed_when: false |
47 | | - register: runner_user_group_id |
| 44 | + - name: Get Runner User IDs |
| 45 | + ansible.builtin.command: id -u "{{ runner_user }}" |
| 46 | + changed_when: false |
| 47 | + register: runner_user_id |
48 | 48 |
|
49 | | - - name: Set runner_system variable |
50 | | - ansible.builtin.set_fact: |
51 | | - runner_system: "{{ 'osx' if ansible_system == 'Darwin' else 'linux' }}" |
| 49 | + - name: Get Runner Group IDs |
| 50 | + ansible.builtin.command: id -g "{{ runner_user }}" |
| 51 | + changed_when: false |
| 52 | + register: runner_user_group_id |
52 | 53 |
|
53 | | - - name: Find the latest runner version (RUN ONCE) |
54 | | - ansible.builtin.uri: |
55 | | - url: "https://api.github.com/repos/{{ runner_download_repository }}/releases/latest" |
56 | | - headers: |
57 | | - Content-Type: "application/json" |
58 | | - method: GET |
59 | | - return_content: yes |
60 | | - status_code: 200 |
61 | | - body_format: json |
62 | | - check_mode: false |
63 | | - register: api_response |
64 | | - run_once: true |
65 | | - become: false |
66 | | - delegate_to: localhost |
67 | | - when: runner_version == "latest" |
| 54 | + - name: Set runner_system variable |
| 55 | + ansible.builtin.set_fact: |
| 56 | + runner_system: "{{ 'osx' if ansible_system == 'Darwin' else 'linux' }}" |
68 | 57 |
|
69 | | - - name: Get systemd service facts |
70 | | - ansible.builtin.service_facts: |
71 | | - register: service_facts |
72 | | - when: ansible_system == "Linux" |
| 58 | + - name: Find the latest runner version (RUN ONCE) |
| 59 | + ansible.builtin.uri: |
| 60 | + url: "https://api.github.com/repos/{{ runner_download_repository }}/releases/latest" |
| 61 | + headers: |
| 62 | + Content-Type: "application/json" |
| 63 | + method: GET |
| 64 | + return_content: true |
| 65 | + status_code: 200 |
| 66 | + body_format: json |
| 67 | + check_mode: false |
| 68 | + register: api_response |
| 69 | + run_once: true |
| 70 | + become: false |
| 71 | + delegate_to: localhost |
| 72 | + when: runner_version == "latest" |
| 73 | + |
| 74 | + - name: Get systemd service facts |
| 75 | + ansible.builtin.service_facts: |
| 76 | + register: service_facts |
| 77 | + when: ansible_system == "Linux" |
0 commit comments