|
1 | 1 | ---
|
2 |
| -- name: validate Repo runners |
| 2 | +- name: Validate Repo runners |
3 | 3 | user: ansible
|
4 | 4 | hosts: all
|
5 | 5 | gather_facts: yes
|
6 | 6 | become: yes
|
7 | 7 | vars:
|
8 |
| - - runner_user: ansible |
9 |
| - - github_repo: ansible-github_actions_runner-testrepo |
10 |
| - - github_account: monolithprojects-testorg |
11 |
| - - github_api_url: "https://api.github.com" |
12 |
| - - access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}" |
13 |
| - - runner_name: ubuntu16-latest |
| 8 | + runner_user: ansible |
| 9 | + github_repo: ansible-github_actions_runner-testrepo |
| 10 | + github_account: monolithprojects-testorg |
| 11 | + github_api_url: "https://api.github.com" |
| 12 | + access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}" |
| 13 | + runner_name: ubuntu16-latest |
14 | 14 |
|
15 | 15 | tasks:
|
16 | 16 | - name: Check currently registered runners
|
17 |
| - uri: |
| 17 | + ansible.builtin.uri: |
18 | 18 | url: "{{ github_api_url }}/repos/{{ github_owner | default(github_account) }}/{{ github_repo }}/actions/runners"
|
19 | 19 | headers:
|
20 | 20 | Authorization: "token {{ access_token }}"
|
|
24 | 24 | force_basic_auth: yes
|
25 | 25 | register: registered_runners
|
26 | 26 |
|
27 |
| - - debug: |
| 27 | + - name: Debug | var registered_runners |
| 28 | + ansible.builtin.debug: |
28 | 29 | var: registered_runners.json.runners
|
29 | 30 |
|
30 | 31 | - name: Check Runner
|
31 |
| - assert: |
| 32 | + ansible.builtin.assert: |
32 | 33 | that:
|
33 | 34 | - runner_name in registered_runners.json.runners|map(attribute='name')|list
|
34 | 35 | - registered_runners.json.runners|map(attribute='status') == ["online"]
|
35 | 36 | quiet: true
|
36 | 37 |
|
37 | 38 | - name: Check Labels (skipped if labels are OK)
|
38 |
| - fail: |
| 39 | + ansible.builtin.fail: |
39 | 40 | msg: Woops some labels differ "{{ (registered_runners.json.runners.0 | json_query('labels[*].name') | difference(['self-hosted', 'Linux', 'X64', 'label1', 'repo-runner'])) }}"
|
40 | 41 | when: not (registered_runners.json.runners.0 | json_query('labels[*].name') | list ) == (['self-hosted', 'Linux', 'X64', 'label1', 'repo-runner'] | list)
|
41 | 42 |
|
42 | 43 | - name: Check custom env file is configured
|
43 |
| - lineinfile: |
| 44 | + ansible.builtin.lineinfile: |
44 | 45 | dest: /opt/actions-runner/.env
|
45 | 46 | line: "# HTTPS_PROXY=YOUR_URL_HERE"
|
46 | 47 | check_mode: yes
|
|
0 commit comments