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
189 stars 77 forks source link

bug: undefined variable 'dict object' has no attribute 'arm64' on Unarchive runner package #209

Closed dnoliver closed 6 months ago

dnoliver commented 6 months ago

Summary

I am using:

roles:
  - name: MonolithProjects.github_actions_runner
    version: "1.18.7"

To deploy a Github Actions Runner in a Mac Mini 2023 - M2 - MacOS Ventura 13.5. The target is a Virtual Machine created with UTM: https://mac.getutm.app/

The error I am getting is the following:

TASK [MonolithProjects.github_actions_runner : Check if desired version already installed] ***********************************************
fatal: [vm]: FAILED! => {"changed": false, "cmd": ["grep", "-i", "2.314.1", "/Users/test/actions-runner/bin/Runner.Listener.deps.json"], "delta": "0:00:00.004140", "end": "2024-05-16 19:40:34.051856", "msg": "non-zero return code", "rc": 2, "start": "2024-05-16 19:40:34.047716", "stderr": "grep: /Users/test/actions-runner/bin/Runner.Listener.deps.json: No such file or directory", "stderr_lines": ["grep: /Users/test/actions-runner/bin/Runner.Listener.deps.json: No such file or directory"], "stdout": "", "stdout_lines": []}
...ignoring

TASK [MonolithProjects.github_actions_runner : Unarchive runner package] *****************************************************************
fatal: [vm]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: {{ github_actions_architecture_map[ansible_facts.architecture] }}: 'dict object' has no attribute 'arm64'. 'dict object' has no attribute 'arm64'. {{ github_actions_architecture_map[ansible_facts.architecture] }}: 'dict object' has no attribute 'arm64'. 'dict object' has no attribute 'arm64'\n\nThe error appears to be in '/root/.ansible/roles/MonolithProjects.github_actions_runner/tasks/install_runner.yml': line 22, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Unarchive runner package\n  ^ here\n"}

Issue Type

Bug Report

Ansible Version

ansible [core 2.16.6]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True

Steps to Reproduce

- name: "GHA in MacOS VM"
  hosts:
    - vm
  become: true
  vars:
    github_account: "REDACTED"
    access_token: REDACTED
    runner_user: "test"
    runner_dir: "/Users/test/actions-runner"
    runner_state: "started"
    runner_org: true
    runner_labels: "{{ runner_labels }}"
    runner_name: "mac-8-cores-16gb-arm-{{ inventory_hostname }}"
    runner_version: "2.314.1"
    runner_group: "'Mac'"
    custom_env: |
      ACTIONS_RUNNER_HOOK_JOB_STARTED=/opt/REDACTED/action_runner_hook_job_started.sh
      ACTIONS_RUNNER_HOOK_JOB_COMPLETED=/opt/REDACTED/action_runner_hook_job_completed.sh
    hide_sensitive_logs: true
  roles:
    - role: MonolithProjects.github_actions_runner
      tags: gha
  environment: "{{ proxy_env }}"

Expected Results

I expected that the play will be successful

Actual Results

root@8068f65b7496:/usr/src/app# ansible-playbook -i inventories/development/ -l vm vms.yml -t gha -J
Vault password:

PLAY [VMs Playbook] **********************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************
[WARNING]: Platform darwin on host vm is using the discovered Python interpreter at /usr/bin/python3, but future installation of another  
Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-
core/2.16/reference_appendices/interpreter_discovery.html for more information.
ok: [vm]

PLAY [GHA in MacOS VM] ************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************
ok: [vm]

TASK [MonolithProjects.github_actions_runner : Include Assert tasks] *********************************************************************
included: /root/.ansible/roles/MonolithProjects.github_actions_runner/tasks/assert.yml for vm

TASK [MonolithProjects.github_actions_runner : Check github_account variable (RUN ONCE)] *************************************************
ok: [vm] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [MonolithProjects.github_actions_runner : Check access_token variable (RUN ONCE)] ***************************************************
ok: [vm] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [MonolithProjects.github_actions_runner : Check runner_org variable (RUN ONCE)] *****************************************************
ok: [vm] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [MonolithProjects.github_actions_runner : Check github_repo variable (RUN ONCE)] ****************************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Include Information collection taks] ******************************************************
included: /root/.ansible/roles/MonolithProjects.github_actions_runner/tasks/collect_info.yml for vm

TASK [MonolithProjects.github_actions_runner : Set complete API url for repo runner] *****************************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Set complete API url for org runner] ******************************************************
ok: [vm]

TASK [MonolithProjects.github_actions_runner : Set complete API url for enterprise runner] ***********************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Get registration token (RUN ONCE)] ********************************************************
ok: [vm]

TASK [MonolithProjects.github_actions_runner : Check currently registered runners for repo (RUN ONCE)] ***********************************
ok: [vm]

TASK [MonolithProjects.github_actions_runner : Get Runner User IDs] **********************************************************************
ok: [vm]

TASK [MonolithProjects.github_actions_runner : Get Runner Group IDs] *********************************************************************
ok: [vm]

TASK [MonolithProjects.github_actions_runner : Set runner_system variable] ***************************************************************
ok: [vm]

TASK [MonolithProjects.github_actions_runner : Find the latest runner version (RUN ONCE)] ************************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Get systemd service facts] ****************************************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Include tasks to install dependencies] ****************************************************
included: /root/.ansible/roles/MonolithProjects.github_actions_runner/tasks/install_deps.yml for vm

TASK [MonolithProjects.github_actions_runner : Install dependencies on Debian Stretch] ***************************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Install dependencies on Debian Buster] ****************************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Install dependencies on Debian Bullseye] **************************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Install dependencies on Debian Bookworm] **************************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Install dependencies on Ubuntu Xenial systems] ********************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Install dependencies on Ubuntu Bionic systems] ********************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Install dependencies on Ubuntu Focal systems] *********************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Install dependencies on Ubuntu Jammy systems] *********************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Install dependencies on RHEL/CentOS/Fedora systems] ***************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Include tasks to uninstall runner] ********************************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Include tasks to install runner] **********************************************************
included: /root/.ansible/roles/MonolithProjects.github_actions_runner/tasks/install_runner.yml for vm

TASK [MonolithProjects.github_actions_runner : Create directory] *************************************************************************
changed: [vm]

TASK [MonolithProjects.github_actions_runner : Set runner_version variable (If latest)] **************************************************
skipping: [vm]

TASK [MonolithProjects.github_actions_runner : Check if desired version already installed] ***********************************************
fatal: [vm]: FAILED! => {"changed": false, "cmd": ["grep", "-i", "2.314.1", "/Users/test/actions-runner/bin/Runner.Listener.deps.json"], "delta": "0:00:00.004140", "end": "2024-05-16 19:40:34.051856", "msg": "non-zero return code", "rc": 2, "start": "2024-05-16 19:40:34.047716", "stderr": "grep: /Users/test/actions-runner/bin/Runner.Listener.deps.json: No such file or directory", "stderr_lines": ["grep: /Users/test/actions-runner/bin/Runner.Listener.deps.json: No such file or directory"], "stdout": "", "stdout_lines": []}
...ignoring

TASK [MonolithProjects.github_actions_runner : Unarchive runner package] *****************************************************************
fatal: [vm]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: {{ github_actions_architecture_map[ansible_facts.architecture] }}: 'dict object' has no attribute 'arm64'. 'dict object' has no attribute 'arm64'. {{ github_actions_architecture_map[ansible_facts.architecture] }}: 'dict object' has no attribute 'arm64'. 'dict object' has no attribute 'arm64'\n\nThe error appears to be in '/root/.ansible/roles/MonolithProjects.github_actions_runner/tasks/install_runner.yml': line 22, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Unarchive runner package\n  ^ here\n"}

PLAY RECAP *******************************************************************************************************************************
vm                         : ok=17   changed=1    unreachable=0    failed=1    skipped=16   rescued=0    ignored=1
dnoliver commented 6 months ago

Noticed that my version doesn't have amr64 in https://github.com/MonolithProjects/ansible-github_actions_runner/blob/1.18.7/vars/main.yml

Updating my runner to 1.21.0 and retrying

dnoliver commented 6 months ago

After updated, run into another issues due to missing tar.

roles:
  - name: MonolithProjects.github_actions_runner
    src: https://github.com/MonolithProjects/ansible-github_actions_runner
    scm: git
    version: "1.21.0"
TASK [MonolithProjects.github_actions_runner : Unarchive runner package] *****************************************************************
fatal: [vm]: FAILED! => {"changed": false, "msg": "Failed to find handler for \"/Users/test/.ansible/tmp/ansible-tmp-1716172767.222517-226-133056964365034/actions-runner-osx-arm64-2.314.1i1o87p2b.tar.gz\". Make sure the required command to extract the file is installed.\nCommand \"/usr/bin/tar\" detected as tar type bsd. GNU tar required.\nCommand \"/usr/bin/unzip\" could not handle archive:   End-of-central-directory signature not found.  Either this file is not\n  a zipfile, or it constitutes one disk of a multi-part archive.  In the\n  latter case the central directory and zipfile comment will be found on\n  the last disk(s) of this archive.\nunzip:  cannot find zipfile directory in one of /Users/test/.ansible/tmp/ansible-tmp-1716172767.222517-226-133056964365034/actions-runner-osx-arm64-2.314.1i1o87p2b.tar.gz or\n        /Users/test/.ansible/tmp/ansible-tmp-1716172767.222517-226-133056964365034/actions-runner-osx-arm64-2.314.1i1o87p2b.tar.gz.zip, and cannot find /Users/test/.ansible/tmp/ansible-tmp-1716172767.222517-226-133056964365034/actions-runner-osx-arm64-2.314.1i1o87p2b.tar.gz. ZIP, period.\n"}

Looks like it's expected, as this roles says that it doens't install deps for macos right. After installing brew, and gnu-tar, Unarchive runner package runs correctly

dnoliver commented 6 months ago

After changing the version, and solving the deps, works! But, each time I got a failure on package deployment, a runner was registered, so next run had to be done with a different runner name :)