Skip to content

Commit ee0e87d

Browse files
author
Gabriel M. Schuyler
authored
Merge pull request #50 from natemccurdy/show_master
config_version: Show the compiling master's name
2 parents ac97852 + 124b1a2 commit ee0e87d

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
#!/usr/bin/env ruby
1+
#!/opt/puppetlabs/puppet/bin/ruby
22
require 'json'
3+
require 'socket'
34

45
environmentpath = ARGV[0]
56
environment = ARGV[1]
67

8+
# Get the hostname of the Puppet master compiling the catalog.
9+
compiling_master = Socket.gethostname
10+
11+
# Get the path to the Code Manager deployment info file.
712
r10k_deploy_file_path = File.join(environmentpath, environment, '.r10k-deploy.json')
813

9-
#output the sha1 from the control-repo
10-
puts JSON.parse(File.read(r10k_deploy_file_path))['signature']
14+
# Get the first 12 characters of the commit ID out of the deployment file.
15+
commit_id = JSON.parse(File.read(r10k_deploy_file_path))['signature'][0...11]
16+
17+
# Show the compiling master, environment name, and commit ID.
18+
puts "#{compiling_master}-#{environment}-#{commit_id}"

scripts/config_version.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#!/usr/bin/env ruby
22
begin
33
require 'rugged'
4+
require 'socket'
45
rescue LoadError => e
56
t = Time.new
67
puts t.to_i
78
else
8-
99
environmentpath = ARGV[0]
1010
environment = ARGV[1]
1111

12-
repo = Rugged::Repository.discover(File.join(environmentpath, environment))
13-
head = repo.head
14-
15-
#sha1 hash of the newest commit
16-
head_sha = head.target_id
12+
# Get the hostname of the Puppet master compiling the catalog.
13+
compiling_master = Socket.gethostname
1714

18-
#the commit message associated the newest commit
19-
commit = repo.lookup(head_sha)
15+
# Get the path to the environment being compiled.
16+
repo = Rugged::Repository.discover(File.join(environmentpath, environment))
17+
head = repo.head
2018

21-
#add something to find the remote url
19+
# First 12 characters of the sha1 hash of the newest commit.
20+
commit_id = head.target_id[0...11]
2221

23-
puts head_sha
22+
# Show the compiling master, environment name, and commit ID.
23+
puts "#{compiling_master}-#{environment}-#{commit_id}"
2424
end

scripts/config_version.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ if [ -e $1/$2/.r10k-deploy.json ]
33
then
44
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/code_manager_config_version.rb $1 $2
55
elif [ -e /opt/puppetlabs/server/pe_version ]
6-
then
7-
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
6+
then
7+
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
88
else
99
/usr/bin/git --version > /dev/null 2>&1 &&
1010
/usr/bin/git --git-dir $1/$2/.git rev-parse HEAD ||
1111
date +%s
12-
fi
12+
fi

0 commit comments

Comments
 (0)