Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github_members_keys module #61209

Open
wants to merge 1 commit into
base: devel
from

Conversation

@sestrella
Copy link
Contributor

commented Aug 23, 2019

SUMMARY

This module fetches team members SSH keys from GitHub. The output provided by this module could be used in combination with the authorized_key module in order to manage SSH keys via GitHub teams.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

github_members_keys

ADDITIONAL INFORMATION

Authorized all team members SSH keys via GitHub:

- name: Fetch team members SSH keys
  local_action:
    module: github_members_keys
    token: token
    organization: organization
    team: team
  register: result
- name: Set authorized_key taken from GitHub
  authorized_key:
    user: user
    key: "{{ result.members_keys | join('\n') }}"
    exclusive: yes

Additionally, there are some validations in place to prevent locking members out of a server:

options:
    mandatory_members:
        description:
            - List of members that must be part of the team
            - If a member is not part of the team it raises an error
            - If a member has no keys it raises an error
            - Each member corresponds to a GitHub username
            - Check used to avoid locking members out of a server
        type: list
        required: false
        default: []
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Aug 23, 2019

The test ansible-test sanity --test pylint [explain] failed with 3 errors:

test/units/modules/source_control/test_github_members_keys.py:53:35: bad-whitespace Exactly one space required after comma                 mock.MagicMock(id=1,key='ssh-rsa AAA...'),                                    ^
test/units/modules/source_control/test_github_members_keys.py:54:35: bad-whitespace Exactly one space required after comma                 mock.MagicMock(id=2,key='ssh-rsa BBB...')                                    ^
test/units/modules/source_control/test_github_members_keys.py:57:35: bad-whitespace Exactly one space required after comma                 mock.MagicMock(id=3,key='ssh-rsa CCC...')                                    ^

The test ansible-test sanity --test future-import-boilerplate [explain] failed with 1 error:

test/units/modules/source_control/test_github_members_keys.py:0:0: missing: from __future__ import (absolute_import, division, print_function)

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/source_control/github_members_keys.py:3:0: SyntaxError: Non-ASCII character '\xc3' in file /root/ansible/lib/ansible/modules/source_control/github_members_keys.py on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/source_control/github_members_keys.py:3:0: SyntaxError: Non-ASCII character '\xc3' in file /root/ansible/lib/ansible/modules/source_control/github_members_keys.py on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

The test ansible-test sanity --test metaclass-boilerplate [explain] failed with 1 error:

test/units/modules/source_control/test_github_members_keys.py:0:0: missing: __metaclass__ = type

The test ansible-test sanity --test pep8 [explain] failed with 8 errors:

test/units/modules/source_control/test_github_members_keys.py:5:1: E302 expected 2 blank lines, found 1
test/units/modules/source_control/test_github_members_keys.py:53:36: E231 missing whitespace after ','
test/units/modules/source_control/test_github_members_keys.py:54:36: E231 missing whitespace after ','
test/units/modules/source_control/test_github_members_keys.py:57:36: E231 missing whitespace after ','
test/units/modules/source_control/test_github_members_keys.py:96:1: E101 indentation contains mixed spaces and tabs
test/units/modules/source_control/test_github_members_keys.py:96:1: W191 indentation contains tabs
test/units/modules/source_control/test_github_members_keys.py:96:6: E123 closing bracket does not match indentation of opening bracket's line
test/units/modules/source_control/test_github_members_keys.py:98:1: E101 indentation contains mixed spaces and tabs

click here for bot help

@ansibot ansibot added needs_revision and removed core_review labels Aug 23, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/source_control/github_members_keys.py:27:0: SyntaxError: Non-ASCII character '\xc3' in file /root/ansible/lib/ansible/modules/source_control/github_members_keys.py on line 28, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/source_control/github_members_keys.py:27:0: SyntaxError: Non-ASCII character '\xc3' in file /root/ansible/lib/ansible/modules/source_control/github_members_keys.py on line 28, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/source_control/github_members_keys.py:99:0: ImportError: No module named builtins

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/source_control/github_members_keys.py:99:0: ImportError: No module named builtins

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

@sestrella sestrella force-pushed the sestrella:github_members_keys branch from 739d5c3 to 357de98 Aug 26, 2019

@sestrella sestrella changed the title New module: GitHub members keys github_members_keys module Aug 26, 2019

@sestrella sestrella force-pushed the sestrella:github_members_keys branch 3 times, most recently from c37d193 to a1a1d34 Aug 26, 2019

@bcoca bcoca removed the needs_triage label Aug 29, 2019

@ansibot ansibot added stale_ci and removed new_contributor labels Sep 6, 2019

@sestrella sestrella force-pushed the sestrella:github_members_keys branch from a1a1d34 to f98423b Sep 14, 2019

@sestrella sestrella changed the title github_members_keys module Add `github_members_keys` module Sep 14, 2019

@ansibot ansibot removed the stale_ci label Sep 14, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Sep 14, 2019

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/source_control/github_members_keys.py:0:0: module-incorrect-version-added: version_added should be '2.10'. Currently '2.9'

click here for bot help

@sestrella sestrella force-pushed the sestrella:github_members_keys branch from f98423b to 8f6d425 Sep 14, 2019

@sestrella sestrella changed the title Add `github_members_keys` module Add github_members_keys module Sep 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.