Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Missing svc.sh error when runner_name already in use #145

Open
gregerspoulsen opened this issue Aug 10, 2022 · 2 comments
Open

bug: Missing svc.sh error when runner_name already in use #145

gregerspoulsen opened this issue Aug 10, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@gregerspoulsen
Copy link

Summary

When the role is executed with a 'runner_name' already present in the organization , it fails due to a missing svc.sh file. That gives the impression something is wrong with the role. This will happen if you incidentally use the same runner name twice or try to install it on a different machine without deregistering the original. It would be helpful if the role warns that the 'runner_name' is already in use and aborts.

Issue Type

Bug Report

Ansible Version

ansible [core 2.13.3rc1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/vagrant/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]
  jinja version = 3.0.3
  libyaml = True

Steps to Reproduce

  1. Run the playbook below
  2. Delete /opt/action_runner/ or move to a different machine
  3. Run the playbook again
- name: Install GitHub Actions Runner
  hosts: localhost
  become: yes

  roles:
    - role: monolithprojects.github_actions_runner
      vars:
        - github_account: xxx
        - runner_org: yes
        - runner_on_ghes: yes
        - runner_labels:
          - my_runner

Expected Results

I would expect a warning or error that the runner_name is already in use instead of an error due to the missing svc.sh file (which is expected to be missing given that register_runner is skipped)

Actual Results

TASK [monolithprojects.github_actions_runner : Register runner] ********************************************************
skipping: [localhost]

TASK [monolithprojects.github_actions_runner : Replace registered runner] **********************************************
skipping: [localhost]

TASK [monolithprojects.github_actions_runner : Install service] ********************************************************
fatal: [localhost]: FAILED! => {"changed": false, "cmd": "./svc.sh install vagrant", "msg": "[Errno 2] No such file or directory: b'./svc.sh'", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
@gregerspoulsen gregerspoulsen added the bug Something isn't working label Aug 10, 2022
@ramiro-sr
Copy link

ramiro-sr commented Aug 7, 2023

I removed and not runner_org from 'when:' and it reinstalled my org runner. install_runner.yml file, line 95.

- name: Replace registered runner
  environment:
    RUNNER_ALLOW_RUNASROOT: "1"
  ansible.builtin.command:
    "{{ runner_dir }}/config.sh \
    --url {{ github_full_url }} \
    --token {{ registration.json.token }} \
    --name '{{ runner_name }}' \
    --labels {{ runner_labels | join(',') }} \
    --unattended \
    {{ runner_extra_config_args }} \
    --replace"
  args:
    chdir: "{{ runner_dir }}"
  become_user: "{{ runner_user }}"
  no_log: "{{ hide_sensitive_logs | bool }}"
  when: runner_name in registered_runners.json.runners|map(attribute='name')|list and reinstall_runner

lewismiddleton added a commit to lewismiddleton/ansible-github_actions_runner that referenced this issue May 14, 2024
This removes a condition from the 'Replace registered runner' task to
allow it to replace organisation runners.

Resolves MonolithProjects#207
Resolves MonolithProjects#145
@stianlagstad
Copy link

Thank you! We ran into this today. We had to remove the existing entry in https://github.com/organizations//settings/actions/runners, and then after that the installation worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants