Version information
This version is compatible with:
- Puppet Enterprise >= 3.1.3 < 2015.4.0
- Puppet >= 3.4.3 < 5.0.0
- , , , , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'beersy-gms', '1.0.0'
Learn more about managing modules with a PuppetfileDocumentation
This is a fork of abrader-gms used in the https://github.com/maju6406/pe_code_manager_easy_setup module.
Git Management Systems API Types & Providers
As of right now this repository only covers the following GMS functionality:
API functions covered
Function | GitHub | GitLab | Stash |
---|---|---|---|
git_deploy_key | X | X | X |
git_webhook | X | X | X |
Of course it is our intent to provide more coverage of the respective APIs in the future. Please feel free to submit PRs as well.
Permissions to use API
The following is a table indicating the necessary level of permission needed for the user the authenticating credential(s) are associated with:
Function | GitHub | GitLab | Stash |
---|---|---|---|
git_deploy_key | owners | master | repo_admin |
git_webhook | owners | master | repo_admin |
Debugging
Troubleshooting issues when APIs are involved can be painful. Now the advertised providers within this module can pass you useful debugging info when you append the debug argument to your puppet run:
puppet apply --debug
or
puppet agent --debug
git_deploy_key
A deploy key is an SSH key that is stored on your server and grants access to a single GitHub repository. This key is attached directly to the repository instead of to a personal user account. Anyone with access to the repository and server has the ability to deploy the project. It is also beneficial for users since they are not required to change their local SSH settings.
GMS agnostic mandatory parameters
ensure
Add or remove the deploy key from the GMS
ensure => present,
or
ensure => absent,
path
The file Puppet will ensure is provided to the prefered Git management system
path => '/root/.ssh/id_dsa.pub',
project_name
The project name associated with the project
Be sure to follow the 'userid/repo' format to insure proper operation for GitHub & GitLab. For Stash, only include the project name for this parameter.
project_name => 'abrader/abrader-gms',
server_url
The URL path to the Git management system server
Both http & https URLs are acceptable.
server_url => 'http://my.internal.gms.server.example.com',
If using GitHub Enterprise, add /api/v3
to the URL, and you'll probably need to use https:
server_url => 'https://my.internal.gms.server.example.com/api/v3',
provider
The Git Management System you are currently using in reference to the webhook you are managing. Currently only GitHub and GitLab are supported.
provider => 'github',
or
provider => 'gitlab',
or
provider => 'stash',
name
A unique title for the key that will be provided to the prefered Git management system. This parameter is namevar.
name => 'One of my unique deploy keys',
GitHub & GitLab mandatory authentication parameter
GitHub and GitLab utilize a token based authentication system to access their APIs respectively
The API token generated must have admin permissions and the ability to read/write keys. If the permissions are wrong, you'll likely see the following error message:
...can't convert String into Integer...
token
This is the unique token you created within your GMS to allow you to interface with the system via the API.
token => 'ABCDEF1234568',
token_file
The path to a file containing the unique token you created within your GMS to allow you to interface with the system via the API. This is an alternative to, and is mutually exlusive to use of the token
parameter.
token_file => '/etc/gitlab/api-token',
Stash mandatory authentication parameters
Stash utilizes a Basic Authentication system as well as an OAuth system for accessing their API respectively. Since OAuth requires a callback URL based system that can not be feasibly implemented by this GMS module, only Basic Authenticaiton is supported.
username
This is the unique token you created within your GMS to allow you to interface with the system via the API.
username => 'ihavealotof',
password
This is the unique token you created within your GMS to allow you to interface with the system via the API.
password => 'puppet_love',
Stash optional parameter
Stash allows a deploy key to be associated with a project (project_name) or with a repository (repo_name). By choosing to omit the repo_name parameter, this module will assume you are associating the SSH key in your git_deploy_key resource block with the project.
repo_name
repo_name => 'control',
A GitHub & GitLab deploy key example
git_deploy_key { 'add_deploy_key_to_puppet_control':
ensure => present,
name => $::fqdn,
path => '/root/.ssh/id_dsa.pub',
token => hiera('gitlab_api_token'),
project_name => 'puppet/control',
server_url => 'http://your.internal.github.server.com',
provider => 'github',
}
A Stash deploy key example
The example below utilizes the optional repo_name parameter to ensure the SSH key in git_deploy_key resouce block below is associated with the repository and not the parent project.
git_deploy_key { 'magical stash deploy key' :
ensure => present,
name => $::fqdn,
username => hiera('stash_api_username'),
password => hiera('stash_api_password'),
project_name => 'puppet',
repo_name => 'control',
path => '/root/.ssh/id_rsa.pub',
server_url => 'http://your.internal.stash.server.com:7990',
provider => 'stash',
}
--
git_webhook
A webhook allows repository admins to manage the post-receive hooks for a repository. Very helpful in the case you have many Puppet masters you manage and therefore are responsible for their respective webhooks. This is refers only to respository webhooks and not organizational webhook as offered by Github. If that functionality is ever supported by this project it will be identified separately.
GMS system agnostic mandatory parameters
ensure
Add or remove the deploy key from the GMS
ensure => present,
or
ensure => absent,
name
A unique title for the key that will be provided to the prefered Git management system. This parameter is namevar.
name => 'super_unique_name_for_webhook',
provider
The Git Management System you are currently using in reference to the webhook you are managing. Currently only GitHub and GitLab are supported.
provider => 'github',
or
provider => 'gitlab',
or
provider => 'stash',
webhook_url
The URL relating to the webhook. This typically has payload in the name.
webhook_url => 'https://puppetmaster.example.com:8088/payload',
token
This is the unique token you created within your GMS to allow you to interface with the system via the API.
token => 'ABCDEF1234568',
token_file
The path to a file containing the unique token you created within your GMS to allow you to interface with the system via the API. This is an alternative to, and is mutually exlusive to use of the token
parameter.
token_file => '/etc/gitlab/api-token',
project_name
The project name associated with the project
Be sure to follow the 'userid/repo' format to insure proper operation for GitHub & GitLab. For Stash, only include the project name for this parameter.
project_name => 'control',
server_url
The URL path to the Git management system server
Both http & https URLs are acceptable.
server_url => 'http://my.internal.gms.server.example.com',
GitHub & GitLab mandatory authentication parameter
GitHub and GitLab utilize a token based authentication system to access their APIs respectively
token
This is the unique token you created within your GMS to allow you to interface with the system via the API.
token => 'ABCDEF1234568',
token_file
The path to a file containing the unique token you created within your GMS to allow you to interface with the system via the API. This is an alternative to, and is mutually exlusive to use of the token
parameter.
token_file => '/etc/gitlab/api-token',
Stash mandatory authentication parameters
Stash utilizes a Basic Authentication system as well as an OAuth system for accessing their API respectively. Since OAuth requires a callback URL based system that can not be feasibly implemented by this GMS module, only Basic Authenticaiton is supported.
username
This is the unique token you created within your GMS to allow you to interface with the system via the API.
username => 'ihavealotof',
password
This is the unique token you created within your GMS to allow you to interface with the system via the API.
password => 'puppet_love',
Stash mandatory parameter
Stash allows a deploy key to be associated with a project (project_name) or with a repository (repo_name). By choosing to omit the repo_name parameter, this module will assume you are associating the SSH key in your git_deploy_key resource block with the project.
repo_name
The name of the repository associated
repo_name => 'control',
GitHub & Gitlab optional parameters
disable_ssl_verify
Boolean value for disabling SSL verification for this webhook. NOTE: Does not work on Stash
disable_ssl_verify => true,
The gitlab provider sets enable_ssl_verification
to false when this attribute is used
GitLab optional Parameters
merge_request_events
The URL in the webhook_url parameter will be triggered when a merge requests event occurs. NOTE: GitLab only
merge_request_events => true,
tag_push_events
The URL in the webhook_url parameter will be triggered when a tag push event occurs. NOTE: GitLab only
tag_push_events => true,
issue_events
The URL in the webhook_url parameter will be triggered when an issues event occurs. NOTE: GitLab only
issue_events => true,
GitHub webhook example
git_webhook { 'web_post_receive_webhook' :
ensure => present,
webhook_url => 'https://puppetmaster.example.com:8088/payload',
token => hiera('gitlab_api_token'),
project_name => 'puppet/control',
server_url => 'http://your.internal.github.server.com',
disable_ssl_verify => true,
provider => 'github',
}
GitLab webhook example
git_webhook { 'web_post_receive_webhook' :
ensure => present,
webhook_url => 'https://puppetmaster.example.com:8088/payload',
token => hiera('gitlab_api_token'),
merge_request_events => true,
project_name => 'puppet/control',
server_url => 'http://your.internal.gitlab.server.com',
provider => 'gitlab',
}
Stash webhook example
git_webhook { 'web_post_receive_webhook' :
ensure => present,
webhook_url => 'https://puppetmaster.example.com:8088/payload',
username => hiera('stash_api_username'),
password => hiera('stash_api_password'),
project_name => 'puppet',
repo_name => 'control',
server_url => 'http://your.internal.stash.server.com:7990',
provider => 'stash',
}
Limited use access tokens (GitHub only)
By heading over the following link:
You should see a screen that resembles something like the following image:
By highlighting only the following options:
- write:repo_hook
- read:repo_hook
- admin:repo_hook
You are limiting this token to only be able to manage webhooks. This may be very beneficial to you if the current tokens available to you entitle too much access. Ultimately, you are puppetizing webhook creation, limiting scope of the token capability only makes sense.
--
Types in this module release
2016-06-07 - Release 1.0.3
Summary
This release is an attempt to fix the permissions issue users discovered in the previous Forge package mentioned in this issue: Wrong rights on lib/puppet/provider/gms_webhook/github.rb
2016-02-10 - Release 1.0.2
Summary
This release is mainly a wrap of fixes and updates prior to a major rewrite
Fixes
- Deploy Keys
- All Providers
- Removed restriction on SSL port
- Stash
- Fixed issue with initial deploy key not getting created
- All Providers
2015-10-20 - Release 1.0.1
Summary
This release is purely to expose debugging functionality previously assumed as released. ;)
2015-08-24 - Release 1.0.0
Summary
This release introduces Stash support for both deploy keys and webhooks.
The README has been updated to include the usage notes for these parameters.
Features
- New parameters -
Stash
username
password
repo_name
2015-06-12 - Release 0.0.9
Summary
v0.0.8 Tarball on Puppet Forge had bad permissions for the Webhook provider. Thanks to @bhechinger for the heads up.
2015-04-20 - Release 0.0.8
Summary
This release is because I simply missed the updated CHANGELOG when packaging the previous module release.
2015-04-20 - Release 0.0.7
Summary
This release is for the purpose of easing the regex on the git_webhook type so Basic HTTP Auth included with an URL is an accepted parameter.
2015-02-24 - Release 0.0.6
Summary
This release has many new parameters enabling the ability to set different triggers for webhooks on GitLab and disabling ssl checks on GitHub. Minor cleanup as well.
The README has been updated to include the usage notes for these parameters.
Features
- New parameters -
GitLab
merge_request_events
tag_push_events
issue_events
- New parameters -
GitHub
disable_ssl_verify
Dependencies
- puppetlabs/stdlib (>=3.2.0 <5.0.0)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.