mirror of
https://github.com/genebean/dots.git
synced 2026-03-27 17:37:43 -04:00
Reworked to use Ruby since its needed for Puppet
This commit is contained in:
parent
bff34cde83
commit
4f0169d4fc
21 changed files with 73 additions and 38 deletions
10
puppet/scripts/code_manager_config_version.rb
Executable file
10
puppet/scripts/code_manager_config_version.rb
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'json'
|
||||
|
||||
environmentpath = ARGV[0]
|
||||
environment = ARGV[1]
|
||||
|
||||
r10k_deploy_file_path = File.join(environmentpath, environment, '.r10k-deploy.json')
|
||||
|
||||
# output the sha1 from the control-repo
|
||||
puts JSON.parse(File.read(r10k_deploy_file_path))['signature']
|
||||
24
puppet/scripts/config_version.rb
Executable file
24
puppet/scripts/config_version.rb
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env ruby
|
||||
begin
|
||||
require 'rugged'
|
||||
rescue LoadError => e
|
||||
t = Time.new
|
||||
puts t.to_i
|
||||
else
|
||||
|
||||
environmentpath = ARGV[0]
|
||||
environment = ARGV[1]
|
||||
|
||||
repo = Rugged::Repository.discover(File.join(environmentpath, environment))
|
||||
head = repo.head
|
||||
|
||||
# sha1 hash of the newest commit
|
||||
head_sha = head.target_id
|
||||
|
||||
# the commit message associated the newest commit
|
||||
commit = repo.lookup(head_sha)
|
||||
|
||||
# add something to find the remote url
|
||||
|
||||
puts head_sha
|
||||
end
|
||||
12
puppet/scripts/config_version.sh
Executable file
12
puppet/scripts/config_version.sh
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
if [ -e $1/$2/.r10k-deploy.json ]
|
||||
then
|
||||
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/code_manager_config_version.rb $1 $2
|
||||
elif [ -e /opt/puppetlabs/server/pe_version ]
|
||||
then
|
||||
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
|
||||
else
|
||||
/usr/bin/git --version > /dev/null 2>&1 &&
|
||||
/usr/bin/git --git-dir $1/$2/.git rev-parse HEAD ||
|
||||
date +%s
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue