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: Impossible to un-register a runner on Linux #178

Closed giordano closed 10 months ago

giordano commented 1 year ago

Summary

It's impossible to un-register an already installed runner, if the user is different from runner_user, because at https://github.com/MonolithProjects/ansible-github_actions_runner/blob/f7f0dcab20d6622c20946572f9a50128b0c5f64f/tasks/uninstall_runner.yml#L26-L27 become: false completely defeats the point of setting become_user in the first place.

Also other changes like https://github.com/MonolithProjects/ansible-github_actions_runner/commit/65b15a8f18a817ae30ac870bfbf329092140fead#diff-c075509e76672dcf3249176a63e0a2e5e90db807b64696d88364ed0c65f82a9eL90 look suspiciously wrong, become defaults to false/no, thus making become_user pointless.

I'm not really sure what's the rationale of these changes.

Issue Type

Bug Report

Ansible Version

ansible [core 2.15.4]
  config file = None
  configured module search path = ['/home/mose/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/mose/repo/TLOmodel/src/scripts/dev/ci-test-vm/env/lib/python3.11/site-packages/ansible
  ansible collection location = /home/mose/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/mose/repo/TLOmodel/src/scripts/dev/ci-test-vm/env/bin/ansible
  python version = 3.11.5 (main, Sep  2 2023, 14:16:33) [GCC 13.2.1 20230801] (/home/mose/repo/TLOmodel/src/scripts/dev/ci-test-vm/env/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Steps to Reproduce

---
- name: Install GitHub Actions Runner
  hosts: all
  user: ansible
  become: yes
  vars:
    - github_account: github-access-user
    - github_repo: my_awesome_repo
    - runner_user: gha
    - reinstall_runner: yes
  roles:
    - role: monolithprojects.github_actions_runner

Use this twice to reinstall the runners, the key is setting runner_user to a different user.

Expected Results

Operation is successful, and the agent is correctly unregistered before being installed again

Actual Results

The operation fails, because `./config.sh` is being run with the wrong user.
MonolithProjects commented 10 months ago

Issue fixed in https://github.com/MonolithProjects/ansible-github_actions_runner/pull/190