ansible-github_actions_runner icon indicating copy to clipboard operation
ansible-github_actions_runner copied to clipboard

bug: Can't customize the SYSTEMD Service Name

Open Th0masL opened this issue 3 years ago • 4 comments

Summary

I don't like the complicated service name that is used by default, and would like to be able to customize the name of the service to something simpler.

# Default service name :
/etc/systemd/system/actions.runner.<org_name>(.<eventually_repo_name>).<hostname>.service

I've tracked down the problem as the content of the svc.sh file, which set the variable SVC_NAME as :

root@gitrunner1:/home/thomas# cat /opt/actions-runner/svc.sh  | head -10
#!/bin/bash

SVC_NAME="actions.runner.my_organization.this_server_hostname.service"

According to the actions/runner issues #1612 and #1367, it seems like they have implemented something that might be able to address this problem, but I can't seems to understand exactly how to implement that in this ansible role.

For the moment, my workaround is to add a new variable called runner_service_name: "actions_runner" and those two tasks to the file install_runner.yml, just before the Install service task :

> cat monolithprojects.github_actions_runner/tasks/install_runner.yml | grep -i "Show the service name" -A15
- name: "Show the service name"
  debug:
    msg: "runner_service_name: {{ runner_service_name }}"

- name: "Update the service name in the svc.sh file because there's a bug and we can't pass the value dynamically"
  lineinfile:
    path: "{{ runner_dir }}/svc.sh"
    line: 'SVC_NAME="{{ runner_service_name }}.service"'
    regexp: "^SVC_NAME=.actions"
    insertbefore: "^SVC_DESCRIPTION="

- name: Install service

Is there any way we can find a long term fix to support custom SYSTEMD Service names ?

Thanks

Thomas

Issue Type

Bug Report

Ansible Version

ansible [core 2.12.6]
  config file = /Users/thomas/.ansible.cfg
  configured module search path = ['/Users/thomas/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/5.9.0/libexec/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/thomas/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.4 (main, Apr 26 2022, 19:42:59) [Clang 13.1.6 (clang-1316.0.21.2)]
  jinja version = 3.1.2
  libyaml = True

Steps to Reproduce

Run the playbook and look at the service file :

ls /etc/systemd/system | grep action

Expected Results

I'd like to be able to change the SYSTEMD Service Name.

Actual Results

The service name is :

/etc/systemd/system/actions.runner.<org_name>(.<eventually_repo_name>).<hostname>.service

Th0masL avatar Jul 02 '22 12:07 Th0masL

Hi @Th0masL, the issue https://github.com/actions/runner/issues/1367 and https://github.com/actions/runner/pull/1612 is regarding the systemd service template - not the service name. As far as i know there isn't standard way to install self-hosted runner with completely custom name of the service (only using the hacks you posted above) thus i do not plan to implement it.

MonolithProjects avatar Jul 04 '22 20:07 MonolithProjects

Thanks for your answer.

I've open an issue on the actions/runner repo to try to get them implement this functionality.

https://github.com/actions/runner/issues/1987

Th0masL avatar Jul 10 '22 10:07 Th0masL

Here is the response of people in the other issue:

Hi @Th0masL,

You can easily customize the name of your service by changing the value of the SVC_NAME variable inside the svc.sh script ☺️

I think it's safe to assume that they won't implement anything that allows to customize the service name upon install, and the only approach is the approach I'm using.

Should I suggest a PR in the Ansible Playbook for that ?

Th0masL avatar Jul 13 '22 23:07 Th0masL

Yeah you can create a PR :wink:

MonolithProjects avatar Jul 20 '22 15:07 MonolithProjects