generated from roles-ansible/ansible_role_template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
- name: "Restart forgejo-runner" | ||
listen: "systemctl restart forgejo-runner" | ||
become: true | ||
ansible.builtin.systemd: | ||
name: 'forgejo-runner' | ||
state: 'restarted' | ||
when: ansible_service_mgr == "systemd" | ||
|
||
- name: "Reload systemd" | ||
listen: 'systemctl daemon-reload' | ||
become: true | ||
ansible.builtin.systemd: | ||
daemon_reload: true | ||
when: ansible_service_mgr == "systemd" | ||
notify: 'systemctl restart forgejo-runner' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Make Sure Forgejo runner instace address is set | ||
ansible.builtin.fail: | ||
msg: "Please set forgejo_runner__instance_address" | ||
when: forgejo_runner__instance_address == '' | ||
|
||
- name: Make Sure Forgejo runner token is set | ||
ansible.builtin.fail: | ||
msg: "Please set forgejo_runner__token" | ||
when: forgejo_runner__token == '' | ||
|
||
- name: Register Forgejo runner | ||
ansible.builtin.command: | ||
chdir: "{{ forgejo_runner__user_home }}" | ||
cmd: | | ||
{{ forgejo_runner__full_executable_path }} register --no-interactive \ | ||
--token '{{ forgejo_runner__token }}' \ | ||
--instance '{{ forgejo_runner__instance_address }}' \ | ||
--name '{{ inventory_hostname }}@ansible' | ||
creates: "{{ forgejo_runner__user_home }}/.runner" | ||
become: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- name: "Setup systemd service" | ||
become: true | ||
when: ansible_os_family == "Debian" | ||
ansible.builtin.template: | ||
src: 'forgejo_runner.service.j2' | ||
dest: '/lib/systemd/system/forgejo-runner.service' | ||
owner: 'root' | ||
group: 'root' | ||
mode: '0644' | ||
notify: | ||
- 'systemctl restart forgejo-runner' | ||
- 'systemctl daemon-reload' | ||
|
||
- name: "Reload systemd" | ||
become: true | ||
ansible.builtin.systemd: | ||
daemon_reload: true | ||
notify: 'systemctl restart forgejo-runner' | ||
|
||
- name: "Start and enable forgejo-runner" | ||
become: true | ||
ansible.builtin.systemd: | ||
name: 'forgejo-runner' | ||
state: started | ||
enabled: true | ||
when: ansible_service_mgr == "systemd" | ||
notify: 'systemctl restart forgejo-runner' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{ ansible_managed | comment }} | ||
[Unit] | ||
Description=Forgejo runner | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
User={{ forgejo_runner__user }} | ||
Group={{ forgejo_runner__group }} | ||
WorkingDirectory={{ forgejo_runner__user_home }} | ||
ExecStart={{ forgejo_runner__full_executable_path }} {{ forgejo_runner__mode }} | ||
Restart=always | ||
RestartSec=10s | ||
|
||
[Install] | ||
WantedBy=multi-user.target |