MonolithProjects / ansible-github_actions_runner

Ansible Role to deploy GitHub Actions self-hosted runner
https://galaxy.ansible.com/ui/standalone/roles/monolithprojects/github_actions_runner/
MIT License
190 stars 77 forks source link

bug: Fails to start runner with "No such file or directory", when looking for svc.sh #175

Closed ollien closed 10 months ago

ollien commented 1 year ago

Summary

I have a playbook that uses this role to deploy self-hosted runners to some of our development hosts. The playbook has not changed, but recent iterations seem to fail with the following (hide_sensitive_logs need to be turned off)

 ________________________________________________________ 
/ TASK [monolithprojects.github_actions_runner : Install \
\ service]                                               /
 -------------------------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

fatal: [myhost]: FAILED! => {"changed": true, "cmd": "./svc.sh install ubuntu", "msg": "[Errno 2] No such file or directory", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
 ____________ 

It seems that Github has changed the entrypoint for the runner from svc.sh to run.sh (and indeed, I do not see svc.sh in the runner directory). I have updated to 1.18.3 and the issue seems to persist

Issue Type

Bug Report

Ansible Version

ansible [core 2.14.8]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/nick/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/nick/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.4 (main, Jun  7 2023, 00:00:00) [GCC 12.3.1 20230508 (Red Hat 12.3.1-1)] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = False

Steps to Reproduce

- name: Add Github Actions Runner
  hosts: '{{ target }}'
  become: true
  vars:
    github_account: "myOrg"
    github_owner: "myOrg"
    runner_org: yes
    runner_name: '{{ target }}'
    runner_user: ubuntu
  roles:
    # https://github.com/MonolithProjects/ansible-github_actions_runner
    # See env variables required, here
    - role: monolithprojects.github_actions_runner

I have removed the org I am running this under, but I suspect this would also happen on any other org.

Expected Results

I expect the runner to start

Actual Results

________________________________________________________ 
/ TASK [monolithprojects.github_actions_runner : Install \
\ service]                                               /
 -------------------------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

fatal: [myhost]: FAILED! => {"changed": true, "cmd": "./svc.sh install ubuntu", "msg": "[Errno 2] No such file or directory", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
 ____________
anders-wind commented 1 year ago

Did you manage to work around the issue?

ollien commented 1 year ago

Unfortunately not. I haven't needed this playbook since so I haven't looked much. At the time of reporting I was dealing with a single host so I just installed the runner manually.

slaapotti-kapacityio commented 11 months ago

I ran in to the same problem and it ended up being me re-using the runner name, which causes the task to skip the configuration --> no svc.sh gets generated

So basically this check working as intended: https://github.com/MonolithProjects/ansible-github_actions_runner/blob/27514626f451de58629ba9379408f70a17c7cb49/tasks/install_runner.yml#L84C24-L84C24

MonolithProjects commented 10 months ago

Hi @ollien , hard to say what happened in your case. But, since svc.sh does not exist I would say config.sh did not run on your destination host at all (as the svc.sh is being created after you run config.sh. svc.sh is not a part of the runner's gzip file). This Ansible Role checks if the runner with the same name is already registered in your github repo/org. And only if it's not, it will run the config.sh. To force the Role to re-run the config.sh, use reinstall_runner: yes.