gogetit 0.1.19 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69a041470a02b35929805777c4c591c2b748fbf8
4
- data.tar.gz: 3a1be3d51b36f9be2ebc96eac14a67529f2e92d2
3
+ metadata.gz: e06872bd9f7527a326036e8208076da736b992b6
4
+ data.tar.gz: 322ede4c1ae979880b93010b5b60e3def969e896
5
5
  SHA512:
6
- metadata.gz: 1dec3d7518f34f4b973cf7eba4542b9a9f37ece0d94013318a511c1da3916a4d83c9463b4486c2e954c0f7427eaece90cd1b5f611c977b661ef1d65e411f52bd
7
- data.tar.gz: 92907d8e36b55819124bd4c1733c7d995c1e4543421c946c3f1117a4553d9dd0952e9f28f6c4fd114ce3cd2f04a6949835249cb421e19e1905e858dc58399d81
6
+ metadata.gz: 50ad1167b838527060e1302b2a7179398cb6b7a1bde5ca9d9ad8aa31e44e5826b5bfe564f34ea55c6bd284715fb3409b53d7345681f5a2f65fbf667027ed2fb8
7
+ data.tar.gz: e8a8b40a648503da5401ca20f12d95f4058bf2eb0ad6cd741b669d11c202425827cba3ee5fa1fec9359deaa5eec2c9b2e506e07d4c9c4cbf33bb5ba95aa15abd
@@ -28,7 +28,10 @@ module Gogetit
28
28
  abort('Invalid argument entered.')
29
29
  end
30
30
  # post-tasks
31
- knife_bootstrap(name, type, Gogetit.config) if options[:chef]
31
+ if options[:chef]
32
+ knife_bootstrap(name, type, Gogetit.config)
33
+ update_vault(Gogetit.config)
34
+ end
32
35
  Gogetit.config[:default][:user] ||= ENV['USER']
33
36
  puts "ssh #{Gogetit.config[:default][:user]}@#{name}"
34
37
  end
@@ -48,7 +51,10 @@ module Gogetit
48
51
  end
49
52
  end
50
53
  # post-tasks
51
- knife_remove(name) if options[:chef]
54
+ if options[:chef]
55
+ knife_remove(name) if options[:chef]
56
+ update_vault(Gogetit.config)
57
+ end
52
58
  end
53
59
 
54
60
  desc 'rebuild NAME', 'Destroy and create either a container or KVM domain again.'
@@ -14,7 +14,7 @@ module Gogetit
14
14
  --node-name #{name} \
15
15
  --ssh-user ubuntu \
16
16
  --sudo \
17
- --bootstrap-install-command \"#{install_cmd}\""
17
+ --bootstrap-install-command \"#{install_cmd}\"".gsub(/ * /, ' ')
18
18
  puts 'Bootstrapping..'
19
19
  puts knife_cmd
20
20
  system(knife_cmd)
@@ -22,6 +22,26 @@ module Gogetit
22
22
  end
23
23
  end
24
24
 
25
+ def update_vault(config)
26
+ # It assumes the data_bags directory is under the root directory of Chef Repo
27
+ data_bags_dir = "#{config[:chef][:chef_repo_root]}/data_bags"
28
+ (Dir.entries("#{data_bags_dir}") - ['.', '..']).each do |bag|
29
+ (Dir.entries("#{data_bags_dir}/#{bag}").select do |f|
30
+ /^((?!keys).)*\.json/.match(f)
31
+ end
32
+ ).each do |item|
33
+ puts 'Refreshing vaults..'
34
+ refresh_cmd = "knife vault refresh #{bag} #{item.gsub('.json', '')} --clean-unknown-clients"
35
+ puts refresh_cmd
36
+ system(refresh_cmd)
37
+ end
38
+ puts 'Updating data bags..'
39
+ update_cmd = "knife data bag from file #{bag} #{data_bags_dir}/#{bag}"
40
+ puts update_cmd
41
+ system(update_cmd)
42
+ end
43
+ end
44
+
25
45
  def knife_remove(name)
26
46
  if find_executable 'knife'
27
47
  if system('knife ssl check')
@@ -1,3 +1,3 @@
1
1
  module Gogetit
2
- VERSION = "0.1.19"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -14,6 +14,7 @@ lxd:
14
14
  libvirt:
15
15
  url: qemu+ssh://WHOAMI@kvm.example.com/system
16
16
  chef:
17
+ chef_repo_root: /SOMEWHERE/CHEF_REPO
17
18
  bootstrap:
18
19
  install_script:
19
20
  libvirt: http://chef.example.com/install_chef_script.sh
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gogetit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Draper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-04 00:00:00.000000000 Z
11
+ date: 2017-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler