|
11 | 11 | - install
|
12 | 12 |
|
13 | 13 | - name: Download runner package version - "{{ runner_version }}"
|
14 |
| - local_action: |
15 |
| - module: get_url |
| 14 | + get_url: |
16 | 15 | url: "https://github.com/actions/runner/releases/download/v{{ runner_version }}/actions-runner-linux-x64-{{ runner_version }}.tar.gz"
|
17 |
| - dest: ./actions-runner-linux.tar.gz |
| 16 | + dest: "./actions-runner-linux-{{ runner_version }}.tar.gz" |
| 17 | + force: no |
18 | 18 | run_once: yes
|
| 19 | + delegate_to: localhost |
19 | 20 | when: runner_version != "latest"
|
20 | 21 | tags:
|
21 | 22 | - install
|
22 | 23 |
|
23 | 24 | - name: Unarchive package
|
24 | 25 | unarchive:
|
25 |
| - src: ./actions-runner-linux.tar.gz |
| 26 | + src: "./actions-runner-linux-{{ runner_version }}.tar.gz" |
26 | 27 | dest: "{{ runner_dir }}/"
|
27 | 28 | owner: "{{ runner_user }}"
|
28 | 29 | tags:
|
|
58 | 59 |
|
59 | 60 | - name: Check service facts
|
60 | 61 | service_facts:
|
| 62 | + tags: |
| 63 | + - install |
| 64 | + - uninstall |
| 65 | + |
| 66 | +- name: Combine Github account and repo names |
| 67 | + set_fact: |
| 68 | + svc_name: "{{ github_account }}-{{ github_repo }}" |
61 | 69 |
|
62 | 70 | - name: Build service name
|
63 | 71 | set_fact:
|
64 |
| - runner_service: "actions.runner.{{ github_account }}-{{ github_repo }}.{{ ansible_hostname }}" |
| 72 | + runner_service: "actions.runner.{{ svc_name[:45] }}.{{ ansible_hostname }}.service" |
| 73 | + |
| 74 | +- debug: |
| 75 | + var: services |
65 | 76 |
|
66 | 77 | - name: Stop and disable GitHub Actions Runner service
|
67 | 78 | systemd:
|
68 |
| - name: "actions.runner.{{ github_account }}-{{ github_repo }}.{{ ansible_hostname }}" |
| 79 | + name: "{{ runner_service }}" |
69 | 80 | state: stopped
|
70 | 81 | enabled: no
|
71 | 82 | when: runner_service in services
|
|
75 | 86 | - name: Unregister runner from the GitHub
|
76 | 87 | command: "{{ runner_dir }}/./config.sh remove --token {{ registration.json.token }} --unattended"
|
77 | 88 | become_user: "{{ runner_user }}"
|
78 |
| - when: ansible_hostname in registered_runners.json.name |
| 89 | + no_log: "{{ hide_sensitive_logs }}" |
| 90 | + when: ansible_hostname in registered_runners.json.runners|map(attribute='name')|list |
79 | 91 | tags:
|
80 | 92 | - uninstall
|
81 | 93 |
|
82 | 94 | - name: Register runner
|
83 | 95 | command: "{{ runner_dir }}/config.sh --url {{ github_server }}/{{ github_account }}/{{ github_repo }} --token {{ registration.json.token }} --unattended"
|
84 | 96 | become_user: "{{ runner_user }}"
|
| 97 | + no_log: "{{ hide_sensitive_logs }}" |
| 98 | + when: ansible_hostname not in registered_runners.json.runners|map(attribute='name')|list |
| 99 | + tags: |
| 100 | + - install |
| 101 | + |
| 102 | +- name: Replace registered runner |
| 103 | + command: "{{ runner_dir }}/config.sh --url {{ github_server }}/{{ github_account }}/{{ github_repo }} --token {{ registration.json.token }} --unattended --replace" |
| 104 | + become_user: "{{ runner_user }}" |
| 105 | + no_log: "{{ hide_sensitive_logs }}" |
| 106 | + when: replace_runner and ansible_hostname in registered_runners.json.runners|map(attribute='name')|list |
85 | 107 | tags:
|
86 | 108 | - install
|
87 | 109 |
|
|
92 | 114 |
|
93 | 115 | - name: Start and enable Github Actions Runner service
|
94 | 116 | systemd:
|
95 |
| - name: "actions.runner.{{ github_account }}-{{ github_repo }}.{{ ansible_hostname }}" |
| 117 | + name: "{{ runner_service }}" |
96 | 118 | state: started
|
97 | 119 | enabled: yes
|
98 | 120 | tags:
|
|
0 commit comments