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: Role fails if runner_version var has different values for different hosts #206

Open
bissquit opened this issue May 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@bissquit
Copy link

bissquit commented May 9, 2024

Summary

Let's say we have host-1 with runner_version: 2.316.1 and host-2 with runner_version: "latest". Role will fail in that case.
I suppose it's because the following task has when: runner_version == "latest" condition:

    - name: Find the latest runner version (RUN ONCE)
      ansible.builtin.uri:
        url: "https://api.github.com/repos/{{ runner_download_repository }}/releases/latest"
        headers:
          Content-Type: "application/json"
        method: GET
        return_content: true
        status_code: 200
        body_format: json
      check_mode: false
      register: api_response
      run_once: true
      become: false
      delegate_to: localhost
      when: runner_version == "latest"

Issue Type

Bug Report

Ansible Version

ansible [core 2.12.6]
  config file = /infra-github-runners/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True

Steps to Reproduce

  1. Configure environment like the following:
TASK [debug] *******************************************************************
ok: [host-1] => {
    "runner_version": "2.316.1"
}
ok: [host-2] => {
    "runner_version": "latest"
}
  1. Run role against two hosts
  2. Output will be the following (shortened):
TASK [ansible-github_actions_runner : Find the latest runner version (RUN ONCE)] ***
skipping: [host-1]

...
TASK [ansible-github_actions_runner : Set runner_version variable (If latest)] ***
skipping: [host-1]
fatal: [host-2]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'json'\n\nThe error appears to be in '/__w/infra-github-runners/infra-github-runners/roles/ansible-github_actions_runner/tasks/install_runner.yml': line 10, 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: Set runner_version variable (If latest)\n  ^ here\n"}

Expected Results

api_response is set for all hosts in play

Actual Results

`api_response` is set only if the first host has `runner_version: "latest"`
@bissquit bissquit added the bug Something isn't working label May 9, 2024
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

1 participant