community.general.github_repo module – Manage your repositories on Github
Note
This module is part of the community.general collection (version 6.6.2).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.github_repo
.
New in community.general 2.2.0
Synopsis
Manages Github repositories using PyGithub library.
Authentication can be done with access_token or with username and password.
Requirements
The below requirements are needed on the host that executes this module.
PyGithub>=1.54
Parameters
Parameter |
Comments |
---|---|
Token parameter for authentication. This is only needed when not using username and password. |
|
URL to the GitHub API if not using github.com but you own instance. Default: |
|
Description for the repository. Defaults to empty if force_defaults=true, which is the default in this module. Defaults to empty if force_defaults=false when creating a new repository. This is only used when state is |
|
Overwrite current description and private attributes with defaults if set to The default for this option will be deprecated in a future version of this collection, and eventually change to Choices:
|
|
Repository name. |
|
Organization for the repository. When state is |
|
Password used for authentication. This is only needed when not using access_token. |
|
Whether the repository should be private or not. Defaults to Defaults to This is only used when state is Choices:
|
|
Whether the repository should exist or not. Choices:
|
|
Username used for authentication. This is only needed when not using access_token. |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Notes
Note
For Python 3, PyGithub>=1.54 should be used.
For Python 3.5, PyGithub==1.54 should be used. More information: https://pygithub.readthedocs.io/en/latest/changes.html#version-1-54-november-30-2020.
For Python 2.7, PyGithub==1.45 should be used. More information: https://pygithub.readthedocs.io/en/latest/changes.html#version-1-45-december-29-2019.
Examples
- name: Create a Github repository
community.general.github_repo:
access_token: mytoken
organization: MyOrganization
name: myrepo
description: "Just for fun"
private: true
state: present
force_defaults: false
register: result
- name: Delete the repository
community.general.github_repo:
username: octocat
password: password
organization: MyOrganization
name: myrepo
state: absent
register: result
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Repository information as JSON. See https://docs.github.com/en/rest/reference/repos#get-a-repository. Returned: success and state is |
Collection links
Issue Tracker Repository (Sources) Submit a bug report Request a feature Communication