mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
github_app_access_token: add support for private key fact (#8989)
* github_app_access_token: add support for private key fact Adds support for specifying the GitHub App private key via an ansible fact instead of a path to a file. This is useful when you want to generate registration tokens for a remote host but don't want to put secrets on the host. * Add license file * Fix pep8 formatting * Add changelog fragment * Run sanity tests on changelog * Apply suggestions from code review Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de> * Add input validation check * Add import * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Add error for mutually exclusive options * Update plugins/lookup/github_app_access_token.py Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
9fb686fe35
commit
5b3b7a1fb1
7 changed files with 106 additions and 6 deletions
|
@ -0,0 +1,30 @@
|
|||
####################################################################
|
||||
# WARNING: These are designed specifically for Ansible tests #
|
||||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
# Test code for the github_app_access_token plugin.
|
||||
#
|
||||
# Copyright (c) 2017-2018, Abhijeet Kasurde <akasurde@redhat.com>
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Install JWT
|
||||
ansible.builtin.pip:
|
||||
name:
|
||||
- jwt
|
||||
|
||||
- name: Read file
|
||||
ansible.builtin.set_fact:
|
||||
github_app_private_key: "{{ lookup('ansible.builtin.file', 'app-private-key.pem') }}"
|
||||
|
||||
- name: Generate Github App Token
|
||||
register: github_app_access_token
|
||||
ignore_errors: true
|
||||
ansible.builtin.set_fact:
|
||||
github_app_token: "{{ lookup('community.general.github_app_access_token', app_id=github_app_id, installation_id=github_app_installation_id, private_key=github_app_private_key) }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- github_app_access_token is failed
|
||||
- '"Github return error" in github_app_access_token.msg'
|
Loading…
Add table
Add a link
Reference in a new issue