Skip to content

bug: Authorization header is incorrect #232

Open
@dyc3

Description

@dyc3

Summary

The format of the Authorization header that this playbook uses for API requests is incorrect.

The correct format is Authorization: Bearer <token>, as seen in the API docs here: https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28

Also, it would probably be a good idea to pin the API version with the X-GitHub-Api-Version header as well.

Issue Type

Bug Report

Ansible Version

ansible [core 2.18.4]
  config file = None
  configured module search path = ['/home/carson/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /nix/store/m814jivygiq72l57xlb35c0cm2s6zl5f-python3.12-ansible-core-2.18.4/lib/python3.12/site-packages/ansible
  ansible collection location = /home/carson/.ansible/collections:/usr/share/ansible/collections
  executable location = /nix/store/m814jivygiq72l57xlb35c0cm2s6zl5f-python3.12-ansible-core-2.18.4/bin/ansible
  python version = 3.12.9 (main, Feb  4 2025, 14:38:38) [GCC 14.2.1 20241116] (/nix/store/f2krmq3iv5nibcvn4rw7nrnrciqprdkh-python3-3.12.9/bin/python3.12)
  jinja version = 3.1.6
  libyaml = True

Steps to Reproduce

---
- name: Install GitHub Actions Runner
  hosts: all
  user: "{{ ansible_user }}"
  become: true
  vars:
    github_account: my-org
    runner_user: "{{ ansible_user }}"
    runner_org: true
    # this must be a fine grained personal access token
    access_token: "{{ github_actions_access_token}}"
    runner_name: "{{ runner_name }}"
    hide_sensitive_logs: false
  pre_tasks:
    - name: Set runner name
      ansible.builtin.set_fact:
        runner_name: "{{ ansible_nodename }}"
    - name: Ensure runner_name is not empty
      ansible.builtin.fail:
        msg: "runner_name must not be empty"
      when: runner_name == ""
  roles:
    - role: ansible-github_actions_runner

Expected Results

I expected it to succeed.

Actual Results

fatal: [worker-linux-1]: FAILED! => {"changed": false, "msg": "Invalid header value b'token <my fine grained personal access token>'", "status": -1, "url": "https://api.github.com/orgs/midpayapp/actions/runners/registration-token"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions