github_cli

Ansible Role: github_cli

Role gotmax23.github_cli Github Repo SourceHut Repo MIT Licensed Github Open Issues Github Open PRs Role Version Commits since last version Galaxy Role Quality Galaxy Role Downloads Github Actions Molecule workflow status Github Actions Galaxy workflow status

Ansible role that installs Github CLI (gh).

Beta Warning

This role is currently in beta and is not intended for production use. Breaking changes may occur between releases, so please make sure to read the release notes.

Requirements

This role depends on certain collections that are not included in ansible-core.

To install this role's requirements, create a requirements.yml file with the following contents:

---
collections:
  - community.general

Then, if you are using ansible-base/ansible-core 2.10 or later, run this command.

ansible-galaxy install -r requirements.yml

If you are still using Ansible 2.9, run this command, instead.

ansible-galaxy collection install -r requirements.yml

Role Variables

Available Installation Methods

This role allows you to choose which source to install Github CLI from. You may override the default installation method by setting github_cli_install_method to the one of the values outlined below.

github_cli_install_method=repo

Description: This installs Github CLI from upstream's Apt and RPM repos.

Supported Distributions: The apt repository supports all Debian derivatives. The RPM repository supports RPM distros such as Fedora, Enterprise Linux (CentOS, Almalinux, Rocky Linux, RHEL, etc), OpenSUSE Leap, and OpenSUSE Tumbleweed.

Default: Yes (for all distributions except Archlinux, where this option is not supported.)

github_cli_install_method=distro_package

Description: This installs Github CLI from the distribution's repositories, if it's available.

Supported Distributions: Archlinux, OpenSUSE Tumbleweed, and Fedora

Default: Only for Archlinux where github_cli_install_method=repo is not supported.


Here are this role's variables and their default values, as set in defaults/main.yml. If you'd like, you may change them to customize this role's behavior.

---
# defaults file for github_cli

# Options:
# - `present` ensures that Github CLI is installed
# - `absent` ensures that Github CLI is not installed.

# If you would like to switch installation methods, you will have to run this
# role once with the old setting using `state=absent`, and then run it again
# with the new setting using `state=present`.
github_cli_state: present

# By default, `github_cli_install_method` is dynamically assigned based on your distribution.
_github_cli_install_method:
  Archlinux: distro_package  # Default for Archlinux
  default: repo  # Default for all other distros

# As explained above, you may override this variable.
# Just make sure the option you chooose supports your distro.
github_cli_install_method: "{{ _github_cli_install_method[ansible_distribution] | default(_github_cli_install_method['default']) }}"

# Whether to check the RPM repo signing key's fingerprint before importing it.
# Note that this is option is only available for the RPM repo and not the apt one.
github_cli_check_rpm_key_fingerprint: true

# See [here][1] for more information.
# This role's default is based on Github's recommendation.
github_cli_apt_repo_codename: stable

# On Yum/Dnf: Pass `enablerepo` to `package` module.
github_cli_enablerepo: omit

[1]: https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-apt

Example Playbook

---
- name: Install Github CLI
  hosts: all
  become: true

  tasks:
    - name: Update apt cache
      when: ansible_pkg_mgr == "apt"
      ansible.builtin.apt:
        update_cache: true
        cache_valid_time: 3600

    - name: Install Github CLI
      ansible.builtin.include_role:
        name: "gotmax23.github_cli"

Compatibility

This role is tested using the latest version of ansible-core and the latest version of the collections from Ansible Galaxy. This is the only version of Ansible that this role officially supports. Best effort support is provided for other versions.

This role is compatible with the following distros:

distro versions
Archlinux any
Debian buster, bullseye, bookworm
EL 8
Fedora 34, 35, 36
opensuse 15.3, tumbleweed
Ubuntu bionic, focal

License

MIT

Author

Maxwell G (@gotmax23)

About

Ansible role that installs Github CLI (gh).

Install
ansible-galaxy install gotmax23/ansible-role-github_cli
GitHub repository
License
mit
Downloads
199
Owner
@gotmax:matrix.org | Fedora developer. Ansible Community Steering Committee member. Pythonista. | See my sr.ht profile for my current code.