bourdain 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b004a03b3490c700e0e0347b3516a4bbc2059c5d
4
- data.tar.gz: a635f4b84631e3bee09582de76c818f6a1c5eda5
3
+ metadata.gz: 270fbf9547b48a86f75570212bb2dbb2a11a511e
4
+ data.tar.gz: 86e522eb39acb28252859376f21389cfe1a8c90c
5
5
  SHA512:
6
- metadata.gz: c7ee9939a1072a1dfbde59fcae34fa87a674653c233d4ae590bcac8852cffa6f09daaaf83439191616e033bd64f39d59c632751b34f4fde16890d3bda150b553
7
- data.tar.gz: 51613421ecb5af2dcda569a3361d12acdc8bf1830b681452294d8c2bcc3d52091f1e20853882f62a79c0f8c7c2c525c001ce9517c742dfd7b185024ba7d85e81
6
+ metadata.gz: 69dc72f2ddac33c5b5c03ff74ed8336af507351a9c73219bb54a413911b8e8cba50b01497bd6eb6f78a26faf23213bfd77136fc327916c360df33c8699eb2f8a
7
+ data.tar.gz: 847d50b46fa0625684c711403fb099463723475884bae78ad0d18c015fc08cb7cab629c77101be59a9724b61ff52668596b83d58b72ae676ad911d16fda6d9f5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.5.0
@@ -67,5 +67,4 @@ end
67
67
 
68
68
  require_relative 'checks/chef'
69
69
  require_relative 'checks/bourdain'
70
- require_relative 'checks/cookbooks'
71
- require_relative 'checks/ssh_config'
70
+ require_relative 'checks/cookbooks'
@@ -11,6 +11,7 @@ module Bourdain
11
11
  def initialize cookbook_config
12
12
  super []
13
13
  return unless require_chef!
14
+ log.info 'Checking cookbooks, this may take a while...'
14
15
  check_gitlab_cookbooks! cookbook_config
15
16
  check_local_cookbooks! cookbook_config
16
17
  end
@@ -18,64 +19,51 @@ module Bourdain
18
19
 
19
20
 
20
21
  private
21
- def check_cookbook_freshness cookbook
22
+ def check_cookbook cookbook
22
23
  notifications = []
23
24
  path = cookbook[:path]
24
25
  stale = []
25
26
 
26
- if Dir.exists? path
27
- if youre_dirty? path
28
- notifications.push [ path, :warn, "Your cookbook %{path} is dirty." % cookbook ]
29
- elsif youre_ahead? path
30
- notifications.push [ path, :warn, "Your cookbook %{path} is ahead of %{repo}." % cookbook ]
31
- elsif youre_behind? path
32
- notifications.push [ path, :warn, "Looks like your cookbook %{path} is behind %{repo}. Will try pulling for you in a moment..." % cookbook ]
33
- stale.push path
34
- else
35
- notifications.push [ path, :info, "Your cookbook %{path} looks up-to-date." % cookbook ]
36
- end
27
+ unless Dir.exists? path
28
+ ensure_cookbook_exists cookbook
29
+ return
37
30
  end
38
31
 
39
- log_notifications [ notifications ]
40
- stale
41
- end
42
-
43
- def check_cookbook_exists cookbook
44
- unless Dir.exists? cookbook[:path]
45
- log.warn "Populating cookbook %{path} with %{repo}" % cookbook
46
- %x| git clone git@#{GITLAB_HOST}:#{cookbook[:repo]} #{cookbook[:path]} |
47
- log.info "Your cookbook %{path} is now up-to-date." % cookbook
32
+ log.info "Fetching latest work on %{path} from %{repo}..." % cookbook
33
+ Dir.chdir(path) { %x| git fetch | }
34
+
35
+ if youre_dirty? path
36
+ log.warn "Your cookbook %{path} is dirty." % cookbook
37
+ elsif youre_ahead? path
38
+ log.warn "Your cookbook %{path} is ahead of %{repo}." % cookbook
39
+ elsif youre_behind? path
40
+ ensure_cookbook_up_to_date cookbook
41
+ else
42
+ log.info "Your cookbook %{path} looks up-to-date." % cookbook
48
43
  end
49
44
  end
50
45
 
51
- def log_notifications notifications
52
- ns = notifications.map { |n| n.first rescue nil }.compact.select { |n| !n.empty? }
53
- ns.sort_by(&:first).each do |n|
54
- next if n.empty?
55
- _, severity, message = n
56
- log.send severity, message
57
- end
58
- end
59
46
 
60
- def ensure_cookbook_up_to_date cookbook_path
61
- log.warn "Pulling in remote changes to existing cookbook %s" % cookbook_path
62
- %x| git -C #{cookbook_path} pull |
63
- log.info "Your cookbook %s is now up-to-date." % cookbook_path
47
+ def ensure_cookbook_exists cookbook
48
+ return if Dir.exists? cookbook[:path]
49
+ log.warn "Populating cookbook %{path} with %{repo}..." % cookbook
50
+ %x| git clone git@#{GITLAB_HOST}:#{cookbook[:repo]} #{cookbook[:path]} |
51
+ log.info "Your cookbook %{path} is now up-to-date." % cookbook
64
52
  end
65
53
 
66
54
 
55
+ def ensure_cookbook_up_to_date cookbook
56
+ return unless Dir.exists? cookbook[:path]
57
+ log.warn "Pulling in changes to %{path} from %{repo}..." % cookbook
58
+ Dir.chdir(cookbook[:path]) { %x| git pull | }
59
+ log.info "Your cookbook %{path} is now up-to-date." % cookbook
60
+ end
67
61
 
68
- def check_gitlab_cookbooks! cookbook_configs
69
- stale_cookbooks = cookbook_configs.pmap do |cookbook|
70
- check_cookbook_freshness cookbook
71
- end.flatten.compact
72
62
 
73
- stale_cookbooks.sort.each do |cookbook_path|
74
- ensure_cookbook_up_to_date cookbook_path
75
- end
76
-
77
- cookbook_configs.sort_by { |cc| cc[:path] }.each do |cookbook|
78
- check_cookbook_exists cookbook
63
+ def check_gitlab_cookbooks! cookbook_configs
64
+ cookbook_configs.sort_by! { |cc| cc[:path] }
65
+ cookbook_configs.each do |cookbook|
66
+ check_cookbook cookbook
79
67
  end
80
68
  end
81
69
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bourdain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-08 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pmap
@@ -114,7 +114,6 @@ files:
114
114
  - lib/bourdain/resources/checks/bourdain.rb
115
115
  - lib/bourdain/resources/checks/chef.rb
116
116
  - lib/bourdain/resources/checks/cookbooks.rb
117
- - lib/bourdain/resources/checks/ssh_config.rb
118
117
  - lib/bourdain/resources/commands.rb
119
118
  - lib/bourdain/resources/commands/bump.rb
120
119
  - lib/bourdain/resources/commands/check.rb
@@ -1,61 +0,0 @@
1
- require 'json'
2
-
3
- module Bourdain
4
- module Checks
5
-
6
- class SSHConfigCheck < Check
7
- usage :check, <<-END
8
- Ensure all nodes are enterened into the local SSH config
9
- ssh_config
10
- END
11
-
12
-
13
- def initialize cookbook_config
14
- super []
15
- return unless require_chef!
16
- check_ssh_config!
17
- end
18
-
19
-
20
-
21
- private
22
- def check_ssh_config! ssh_config=File.join(ENV['HOME'], '.ssh', 'config')
23
- unless File::exist?(ssh_config)
24
- log.warn 'Skipping SSH config check. File does not exist: %s' % ssh_config.inspect
25
- return
26
- end
27
-
28
- nodes = Dir[File.join('nodes', '*.json')]
29
- nodes = nodes.map do |path|
30
- JSON::parse File.read(path)
31
- end
32
-
33
- config = File.read(ssh_config)
34
-
35
- hosts = []
36
- config.lines.select do |l|
37
- l =~ /Host (\S+)/
38
- hosts << $1 if $1
39
- end
40
-
41
- unconfigured_nodes = nodes.select do |n|
42
- !hosts.include? n['name']
43
- end
44
-
45
- File.open(ssh_config, 'a') do |f|
46
- f.puts unless unconfigured_nodes.empty?
47
- unconfigured_nodes.each do |n|
48
- log.info 'Adding %s to %s' % [ n['name'].inspect, ssh_config ]
49
- f.puts "Host %s" % n['name']
50
- f.puts "\tHostName\t%s" % n['name']
51
- f.puts "\tPort\t22"
52
- f.puts "\tUser\tvagrant"
53
- f.puts "\tStrictHostKeyChecking\tno"
54
- f.puts "\tIdentityFile\t~/.vagrant.d/insecure_private_key"
55
- f.puts
56
- end
57
- end
58
- end
59
- end
60
- end
61
- end