ansible.galaxy package

This manages remote shared Ansible objects, mainly roles

class ansible.galaxy.Galaxy(options)[source]

Bases: object

Keeps global galaxy info

default_readme
default_meta
default_test
default_travis
add_role(role)[source]
remove_role(role_name)[source]

Submodules

ansible.galaxy.api module

ansible.galaxy.api.g_connect(method)[source]

wrapper to lazily initialize connection info to galaxy

class ansible.galaxy.api.GalaxyAPI(galaxy)[source]

Bases: object

This class is meant to be used as a API client for an Ansible Galaxy server

SUPPORTED_VERSIONS = ['v1']
api_server
validate_certs
authenticate(*args, **kwargs)[source]
create_import_task(github_user, github_repo, reference=None)[source]

Post an import request

get_import_task(*args, **kwargs)[source]
lookup_role_by_name(*args, **kwargs)[source]
get_list(*args, **kwargs)[source]
search_roles(*args, **kwargs)[source]
add_secret(*args, **kwargs)[source]
list_secrets(*args, **kwargs)[source]
remove_secret(*args, **kwargs)[source]
delete_role(*args, **kwargs)[source]

ansible.galaxy.login module

class ansible.galaxy.login.GalaxyLogin(galaxy, github_token=None)[source]

Bases: object

Class to handle authenticating user with Galaxy API prior to performing CUD operations

GITHUB_AUTH = 'https://api.github.com/authorizations'
get_credentials()[source]
remove_github_token()[source]

If for some reason an ansible-galaxy token was left from a prior login, remove it. We cannot retrieve the token after creation, so we are forced to create a new one.

create_github_token()[source]

Create a personal authorization token with a note of ‘ansible-galaxy login’

ansible.galaxy.role module

class ansible.galaxy.role.GalaxyRole(galaxy, name, src=None, version=None, scm=None, path=None)[source]

Bases: object

SUPPORTED_SCMS = set(['git', 'hg'])
META_MAIN = 'meta/main.yml'
META_INSTALL = 'meta/.galaxy_install_info'
ROLE_DIRS = ('defaults', 'files', 'handlers', 'meta', 'tasks', 'templates', 'vars', 'tests')
metadata

Returns role metadata

install_info

Returns role install info

remove()[source]

Removes the specified role from the roles path. There is a sanity check to make sure there’s a meta/main.yml file at this path so the user doesn’t blow away random directories.

fetch(role_data)[source]

Downloads the archived role from github to a temp location

install()[source]
spec

Returns role spec info.

In the format:

{
'scm': 'git',
'src': 'http://git.example.com/repos/repo.git',
'version': 'v1.0',
'name': 'repo'
}

ansible.galaxy.token module

class ansible.galaxy.token.GalaxyToken[source]

Bases: object

Class to storing and retrieving token in ~/.ansible_galaxy

set(token)[source]
get()[source]
save()[source]