Last active
September 23, 2016 22:09
-
-
Save acidprime/938f97ec6f4200a588e383a658b89b6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/puppetlabs/puppet/bin/ruby | |
require 'rugged' | |
require 'octokit' | |
require 'yaml' | |
# needs refactoring for code manager | |
# https://github.com/puppetlabs/control-repo/blob/production/scripts/code_manager_config_version.rb | |
environmentpath = ARGV[0] | |
environment = ARGV[1] | |
config = YAML.load_file('/etc/config_version.yaml') | |
client = Octokit::Client.new(:access_token => config['api_key']) | |
repo = Rugged::Repository.discover(File.join(environmentpath, environment)) | |
# sha1 hash of the newest commit in environment | |
head_sha = repo.head.target_id | |
# Lookup up the commit via github API | |
commit = client.commit(config['repo'],head_sha, | |
:accept => 'application/vnd.github.cryptographer-preview') | |
# Get the commit message from github or fail back to the message off disk | |
message = commit[:commit][:message] || repo.lookup(head_sha) | |
if commit[:commit][:verification][:verified] | |
badge = "๐" | |
else | |
badge = "๐" | |
end | |
puts "%s [%s](%s)" % [badge,message,commit[:html_url]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
I have been planing arround with GPG signing commits and passing that along to puppet. I have some more interesting thoughts on blocking commits that are not signed for the future. In the present, here a simple config version to show you if your puppet code that you are applying is verified according to github's new GPG key features.
Install Prerequisites
Install required gems
Generate Github API token
Follow these steps to create a github API token with the following privs:
While you are there , upload your GPG key to github so it knows yours identity (extra credit if you use a yubikey).
The resultant file should be created on all masters (not agents) via the code example above.
Test
Read up on signing commits
You can view these in the new Github UI

Download the gist above and test the script

# DeployOnce tested , add to control-repo and add the following to environment.conf in the root of your control-repo
https://github.com/puppetlabs/control-repo/blob/production/environment.conf#L2