gogetit 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/gogetit.gemspec +1 -1
- data/lib/gogetit/cli.rb +2 -2
- data/lib/gogetit/util.rb +62 -18
- data/lib/gogetit/version.rb +1 -1
- data/lib/providers/lxd.rb +4 -4
- data/lib/sample_conf/gogetit.yml +1 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eece96e8731a88531e7acb63f44b960d4a674cd9
|
4
|
+
data.tar.gz: 69eda3942e9e7ed98edb508fe2c42894aa206b07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a24f807fd2271e9c7336cfbb187d5cb7a30d00b3fa3091a2bf43f8988844b575a34a20e1b30d785974253bbab747259cd26ed6357c21f389183bc231f654084b
|
7
|
+
data.tar.gz: 724ba1bceefcf866b18d18665eab1e39997920ffd8fd79a6e1d416376432e8a8def9b082f91734689652581c4051966ce63a069681bab4f5eceffbe3738f07f9
|
data/README.md
CHANGED
@@ -79,13 +79,17 @@ gogetit destroy chef01 --chef
|
|
79
79
|
```ruby
|
80
80
|
require 'gogetit'
|
81
81
|
```
|
82
|
+
## To make Gogetit recognize data bag that needs to be encrypted by Vault
|
83
|
+
- Fill this out!
|
82
84
|
|
83
|
-
##
|
84
|
-
-
|
85
|
-
-
|
86
|
-
- Static IP auto-assignment with VLAN info.
|
85
|
+
## To develop
|
86
|
+
- Deploying bare metal machine from machine pool
|
87
|
+
- Static IP auto-assignment with VLAN info
|
87
88
|
- Working with Multiple LXD and Libvirt hosts
|
88
89
|
|
90
|
+
## To document
|
91
|
+
- How to make Gogetit recognize vault data bag items
|
92
|
+
|
89
93
|
## Development and Contributing
|
90
94
|
Clone and then execute followings:
|
91
95
|
|
data/gogetit.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
#spec.add_runtime_dependency 'etcd-rb', '~> 1.1.0'
|
36
36
|
spec.add_runtime_dependency 'json', '~> 2.1.0'
|
37
37
|
spec.add_runtime_dependency 'hyperkit', '~> 1.1.0'
|
38
|
-
spec.add_runtime_dependency 'maas-client'
|
38
|
+
spec.add_runtime_dependency 'maas-client'
|
39
39
|
spec.add_runtime_dependency 'ruby-libvirt', '~> 0.7.0'
|
40
40
|
spec.add_runtime_dependency 'oga', '~> 2.10'
|
41
41
|
spec.add_runtime_dependency 'net-ssh', '~> 4.1.0'
|
data/lib/gogetit/cli.rb
CHANGED
@@ -42,7 +42,7 @@ module Gogetit
|
|
42
42
|
# post-tasks
|
43
43
|
if options[:chef]
|
44
44
|
knife_bootstrap(name, options[:provider], Gogetit.config, Gogetit.logger)
|
45
|
-
|
45
|
+
update_databags(Gogetit.config, Gogetit.logger)
|
46
46
|
end
|
47
47
|
Gogetit.config[:default][:user] ||= ENV['USER']
|
48
48
|
puts "ssh #{Gogetit.config[:default][:user]}@#{name}"
|
@@ -66,7 +66,7 @@ module Gogetit
|
|
66
66
|
# post-tasks
|
67
67
|
if options[:chef]
|
68
68
|
knife_remove(name, Gogetit.logger) if options[:chef]
|
69
|
-
|
69
|
+
update_databags(Gogetit.config, Gogetit.logger)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
data/lib/gogetit/util.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
require 'net/ssh'
|
3
3
|
require 'active_support/core_ext/hash'
|
4
|
+
require 'json'
|
4
5
|
|
5
6
|
module Gogetit
|
6
7
|
module Util
|
8
|
+
def run_command(cmd, logger)
|
9
|
+
logger.info("Calling <#{__method__.to_s}> to run #{cmd}")
|
10
|
+
system(cmd)
|
11
|
+
end
|
12
|
+
|
7
13
|
def knife_bootstrap(name, provider, config, logger)
|
8
14
|
logger.info("Calling <#{__method__.to_s}>")
|
15
|
+
config[:chef][:target_environment] ||= '_default'
|
9
16
|
if find_executable 'knife'
|
10
17
|
if system('knife ssl check')
|
11
18
|
install_cmd = "curl \
|
@@ -15,6 +22,7 @@ module Gogetit
|
|
15
22
|
--node-name #{name} \
|
16
23
|
--ssh-user ubuntu \
|
17
24
|
--sudo \
|
25
|
+
--environment #{config[:chef][:target_environment]} \
|
18
26
|
--bootstrap-install-command \"#{install_cmd}\"".gsub(/ * /, ' ')
|
19
27
|
puts 'Bootstrapping..'
|
20
28
|
puts knife_cmd
|
@@ -23,28 +31,64 @@ module Gogetit
|
|
23
31
|
end
|
24
32
|
end
|
25
33
|
|
26
|
-
def
|
34
|
+
def update_databags(config, logger)
|
27
35
|
logger.info("Calling <#{__method__.to_s}>")
|
28
|
-
# It assumes the data_bags directory is under the root directory of Chef Repo
|
29
|
-
vaults = `knife vault list`.split
|
30
36
|
data_bags_dir = "#{config[:chef][:chef_repo_root]}/data_bags"
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
|
38
|
+
puts 'Listing databags..'
|
39
|
+
databags_as_is = `knife data bag list`.split
|
40
|
+
databags_to_be = Dir.entries(data_bags_dir) - ['.', '..']
|
41
|
+
|
42
|
+
puts 'Checking databags to delete..'
|
43
|
+
(databags_as_is - databags_to_be).each do |bag|
|
44
|
+
puts "Deleting databag '#{bag}'.."
|
45
|
+
answer = ask(
|
46
|
+
'Do you really want to delete this?',
|
47
|
+
:echo => true,
|
48
|
+
:limited_to => ['y', 'n']
|
49
|
+
)
|
50
|
+
case answer
|
51
|
+
when 'y'
|
52
|
+
run_command("knife data bag delete -y #{bag}", logger)
|
53
|
+
when 'n'
|
54
|
+
puts 'Keeping..'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
puts 'Checking databags to create..'
|
59
|
+
(databags_to_be - databags_as_is).each do |bag|
|
60
|
+
puts "Creating databag '#{bag}'.."
|
61
|
+
run_command("knife data bag create #{bag}", logger)
|
62
|
+
end
|
63
|
+
|
64
|
+
puts 'Checking items..'
|
65
|
+
databags_to_be.each do |bag|
|
66
|
+
items_as_is = `knife data bag show #{bag}`.split
|
67
|
+
Dir.entries(data_bags_dir+'/'+bag).select do |file|
|
68
|
+
/^.*\.json/.match(file)
|
69
|
+
end.each do |item|
|
70
|
+
item_file = data_bags_dir+'/'+bag+'/'+item
|
71
|
+
item = item.gsub('.json', '')
|
72
|
+
if JSON.parse(File.read(item_file))['vault']
|
73
|
+
if items_as_is.include? item
|
74
|
+
run_command(
|
75
|
+
"knife vault update #{bag} #{item} --json #{item_file} --search '*:*' -M client",
|
76
|
+
logger
|
77
|
+
)
|
78
|
+
else
|
79
|
+
run_command(
|
80
|
+
"knife vault create #{bag} #{item} --json #{item_file} --search '*:*' -M client",
|
81
|
+
logger
|
82
|
+
)
|
83
|
+
end
|
84
|
+
run_command(
|
85
|
+
"knife vault refresh #{bag} #{item} --clean-unknown-clients -M client",
|
86
|
+
logger
|
87
|
+
)
|
88
|
+
else
|
89
|
+
run_command("knife data bag from file #{bag} #{item_file}", logger)
|
36
90
|
end
|
37
|
-
).each do |item|
|
38
|
-
item.slice! '_keys'
|
39
|
-
puts 'Refreshing vaults..'
|
40
|
-
refresh_cmd = "knife vault refresh #{bag} #{item.gsub('.json', '')} --clean-unknown-clients"
|
41
|
-
puts refresh_cmd
|
42
|
-
system(refresh_cmd)
|
43
91
|
end
|
44
|
-
puts 'Updating data bags..'
|
45
|
-
update_cmd = "knife data bag from file #{bag} #{data_bags_dir}/#{bag}"
|
46
|
-
puts update_cmd
|
47
|
-
system(update_cmd)
|
48
92
|
end
|
49
93
|
end
|
50
94
|
|
data/lib/gogetit/version.rb
CHANGED
data/lib/providers/lxd.rb
CHANGED
@@ -169,16 +169,16 @@ module Gogetit
|
|
169
169
|
args[:config][:'user.user-data']['ssh_authorized_keys'].push(key['key'])
|
170
170
|
end
|
171
171
|
|
172
|
+
# To disable to update apt database on first boot
|
173
|
+
# so chef client can keep doing its job.
|
174
|
+
args[:config][:'user.user-data']['package_update'] = false
|
175
|
+
|
172
176
|
pkg_repos.each do |repo|
|
173
177
|
if repo['name'] == 'main_archive'
|
174
178
|
args[:config][:'user.user-data']['apt_mirror'] = repo['url']
|
175
179
|
end
|
176
180
|
end
|
177
181
|
|
178
|
-
# To disable to update apt database on first boot
|
179
|
-
# so chef client can keep doing its job.
|
180
|
-
args[:config][:'user.user-data']['package_update'] = false
|
181
|
-
|
182
182
|
args[:config][:"user.user-data"] = \
|
183
183
|
YAML.dump(args[:config][:"user.user-data"])[4..-1]
|
184
184
|
|
data/lib/sample_conf/gogetit.yml
CHANGED
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.5.
|
4
|
+
version: 0.5.2
|
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-
|
11
|
+
date: 2017-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,16 +112,16 @@ dependencies:
|
|
112
112
|
name: maas-client
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0
|
117
|
+
version: '0'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0
|
124
|
+
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: ruby-libvirt
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|