Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Last active April 26, 2017 21:58
Show Gist options
  • Save natemccurdy/b48962a5a0f90cc615c5894bb211e18d to your computer and use it in GitHub Desktop.
Save natemccurdy/b48962a5a0f90cc615c5894bb211e18d to your computer and use it in GitHub Desktop.
Puppet config version script
#!/opt/puppetlabs/puppet/bin/ruby
require 'json'
require 'socket'
compile_master = Socket.gethostname
environmentpath = ARGV[0]
environment = ARGV[1]
# Get the short SHA1 commit ID from the control repository.
r10k_deploy_file_path = File.join(environmentpath, environment, '.r10k-deploy.json')
commit_id_short = JSON.parse(File.read(r10k_deploy_file_path))['signature'][0...11]
# Show the compiling master, environment name, and short commit ID.
puts "#{compile_master}-#{environment}-#{commit_id_short}"
config_version = 'scripts/config_version.rb $environmentpath $environment'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment