gogetit 0.14.0 → 0.15.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: '0069b408c8ca685e130a7e0d999dcada0260cd6d'
4
- data.tar.gz: 823609fa164ac340398640d288ea7a186d398641
3
+ metadata.gz: 1f33677b64fb94c2039ff7aca0675ff5166a5d10
4
+ data.tar.gz: b1984bee721e53fc456cee41dffb5b404521d45f
5
5
  SHA512:
6
- metadata.gz: 40df33d8170177b3404c0aba7eb180624dd4d4f9a61ec656b557cf40ce2b6c2666a05cc443066cdeaad4bf4a6e94dc001ddcc215f763016a9bf9a249cbcc1878
7
- data.tar.gz: c7821587c326c9ff112efb1d3cccd6a56c0bfe17409df63b60ef8e87e599d73a6e1cc0c5b4fb891bd061574a7b2bd89f09fa05f593b438783efbbdaea02fa85c
6
+ metadata.gz: d7b7f4f94038df38b32ff160c966fa739c9f212bfb7d546112ed937f4c7266fbb2fdc1de89cbdc492ced11e8db364a2274331b56dc8b0ab7d1f12a384261f9a7
7
+ data.tar.gz: 054a08528c44b4aecab3b695d2f121df63718531a59b0a58e62cda617026b675a0e3b9a2454314f79a9c34251b4956bee8f5ac143cb68f08c94904cd67cb014d
data/README.md CHANGED
@@ -60,8 +60,8 @@ gogetit create kvm01 -p libvirt
60
60
  gogetit create kvm01 -p libvirt -i 192.168.10.10 10.0.0.2
61
61
 
62
62
  # When specifying alias for LXD provider
63
- gogetit create kvm01 -a centos7
64
- gogetit create kvm01 -p lxd -a centos7
63
+ gogetit create lxd01 -a centos7
64
+ gogetit create lxd02 -p lxd -a centos7
65
65
 
66
66
  # When specifying distro for Libvirt provider
67
67
  gogetit create kvm01 -p libvirt -d centos
@@ -74,20 +74,18 @@ gogetit deploy kvm01 -d centos
74
74
  gogetit create lxd01 --no-maas -f lxd_without_maas.yml
75
75
  gogetit create lxd01 --no-maas -f lxd_without_maas_vlans.yml
76
76
 
77
- # to provision with a bare metal machine
78
- # gogetit create kvm01 -p bare
79
-
80
77
  gogetit destroy lxd01
81
78
 
82
79
  # This feature is broken and might be deprecated in the future.
83
80
  # gogetit rebuild kvm01
84
81
 
85
- # to create a container bootstrapping as a chef node
82
+ # to create a container bootstrapping as server node
86
83
  gogetit create chef01 --chef
84
+ gogetit destroy chef01 --chef
87
85
 
88
- or
89
-
90
- CHEF=true gogetit create chef01
86
+ # to create a container bootstrapping as zero(local) node
87
+ gogetit create chef01 --zero
88
+ gogetit destroy chef01 --zero
91
89
 
92
90
 
93
91
  # to destroy a container deleting corresponding chef node and client
data/lib/gogetit/cli.rb CHANGED
@@ -61,6 +61,8 @@ module Gogetit
61
61
  :desc => 'A distro name with its series for libvirt provider'
62
62
  method_option :chef, :aliases => '-c', :type => :boolean, \
63
63
  :default => false, :desc => 'Chef awareness'
64
+ method_option :zero, :aliases => '-z', :type => :boolean, \
65
+ :default => false, :desc => 'Chef Zero awareness'
64
66
  method_option :vlans, :aliases => '-v', :type => :array, \
65
67
  :desc => 'A list of VLAN IDs to connect to'
66
68
  method_option :ipaddresses, :aliases => '-i', :type => :array, \
@@ -73,6 +75,9 @@ module Gogetit
73
75
  abort("'vlans' and 'ipaddresses' can not be set together.") \
74
76
  if options['vlans'] and options['ipaddresses']
75
77
 
78
+ abort("'chef' and 'zero' can not be set together.") \
79
+ if options['chef'] and options['zero']
80
+
76
81
  abort("when 'no-maas', the network configuration have to be set by 'file'.") \
77
82
  if options['no-maas'] and (options['vlans'] or options['ipaddresses'])
78
83
 
@@ -96,14 +101,22 @@ module Gogetit
96
101
 
97
102
  # post-tasks
98
103
  if options['chef']
99
- knife_bootstrap(name, options[:provider], config, logger)
100
- update_databags(config, logger)
104
+ bootstrap_chef(name, options[:provider], config)
105
+ update_databags(config)
106
+ elsif options['zero']
107
+ knife_bootstrap_zero(name, options[:provider], config)
101
108
  end
102
109
  end
103
110
 
104
111
  desc 'destroy NAME', 'Destroy either a container or KVM instance.'
105
- method_option :chef, :type => :boolean, :desc => "Enable chef awareness."
112
+ method_option :chef, :aliases => '-c', :type => :boolean, \
113
+ :default => false, :desc => 'Chef awareness'
114
+ method_option :zero, :aliases => '-z', :type => :boolean, \
115
+ :default => false, :desc => 'Chef Zero awareness'
106
116
  def destroy(name)
117
+ abort("'chef' and 'zero' can not be set together.") \
118
+ if options['chef'] and options['zero']
119
+
107
120
  provider = get_provider_of(name, providers)
108
121
  if provider
109
122
  case provider
@@ -117,8 +130,10 @@ module Gogetit
117
130
  end
118
131
  # post-tasks
119
132
  if options['chef']
120
- knife_remove(name) if options[:chef]
133
+ knife_remove(name, options)
121
134
  update_databags(config)
135
+ elsif options['zero']
136
+ knife_remove(name, options)
122
137
  end
123
138
  end
124
139
 
@@ -127,25 +142,41 @@ module Gogetit
127
142
  :desc => 'A distro name with its series for libvirt provider'
128
143
  method_option :chef, :aliases => '-c', :type => :boolean, \
129
144
  :default => false, :desc => 'Chef awareness'
145
+ method_option :zero, :aliases => '-z', :type => :boolean, \
146
+ :default => false, :desc => 'Chef Zero awareness'
130
147
  def deploy(name)
148
+ abort("'chef' and 'zero' can not be set together.") \
149
+ if options['chef'] and options['zero']
150
+
131
151
  Gogetit::CLI.result = libvirt.deploy(name, options.to_hash)
132
152
 
133
153
  # post-tasks
134
154
  if options['chef']
135
- knife_bootstrap(name, options[:provider], config, logger)
136
- update_databags(config, logger)
155
+ knife_bootstrap(name, options[:provider], config)
156
+ update_databags(config)
157
+ elsif options['zero']
158
+ knife_bootstrap_zero(name, options[:provider], config)
137
159
  end
138
160
  end
139
161
 
140
162
  desc 'release NAME', 'Release a node in MAAS'
141
163
  method_option :chef, :type => :boolean, :desc => "Enable chef awareness."
164
+ method_option :chef, :aliases => '-c', :type => :boolean, \
165
+ :default => false, :desc => 'Chef awareness'
166
+ method_option :zero, :aliases => '-z', :type => :boolean, \
167
+ :default => false, :desc => 'Chef Zero awareness'
142
168
  def release(name)
169
+ abort("'chef' and 'zero' can not be set together.") \
170
+ if options['chef'] and options['zero']
171
+
143
172
  Gogetit::CLI.result = libvirt.release(name)
144
173
 
145
174
  # post-tasks
146
175
  if options['chef']
147
- knife_remove(name) if options[:chef]
176
+ knife_remove(name, options)
148
177
  update_databags(config)
178
+ elsif options['zero']
179
+ knife_remove(name, options)
149
180
  end
150
181
  end
151
182
 
@@ -153,7 +184,12 @@ module Gogetit
153
184
  ' either a container or a node(machine) in MAAS again.'
154
185
  method_option :chef, :aliases => '-c', :type => :boolean, \
155
186
  :default => false, :desc => 'Chef awareness'
187
+ method_option :zero, :aliases => '-z', :type => :boolean, \
188
+ :default => false, :desc => 'Chef Zero awareness'
156
189
  def rebuild(name)
190
+ abort("'chef' and 'zero' can not be set together.") \
191
+ if options['chef'] and options['zero']
192
+
157
193
  provider = get_provider_of(name, providers)
158
194
  if provider
159
195
  case provider
@@ -177,8 +213,8 @@ module Gogetit
177
213
  end
178
214
  # post-tasks
179
215
  if options['chef']
180
- knife_remove(name, logger) if options[:chef]
181
- update_databags(config, logger)
216
+ knife_remove(name) if options[:chef]
217
+ update_databags(config)
182
218
  end
183
219
  end
184
220
  end
data/lib/gogetit/util.rb CHANGED
@@ -65,7 +65,7 @@ module Gogetit
65
65
  end
66
66
  end
67
67
 
68
- def knife_bootstrap(name, provider, config)
68
+ def knife_bootstrap_chef(name, provider, config)
69
69
  logger.info("Calling <#{__method__.to_s}>")
70
70
  config[:chef][:target_environment] ||= '_default'
71
71
  if find_executable 'knife'
@@ -79,13 +79,28 @@ module Gogetit
79
79
  --sudo \
80
80
  --environment #{config[:chef][:target_environment]} \
81
81
  --bootstrap-install-command \"#{install_cmd}\"".gsub(/ * /, ' ')
82
- puts 'Bootstrapping..'
83
- puts knife_cmd
82
+ puts 'Bootstrapping with chef-server..'
83
+ logger.info(knife_cmd)
84
84
  system(knife_cmd)
85
85
  end
86
86
  end
87
87
  end
88
88
 
89
+ def knife_bootstrap_zero(name, provider, config)
90
+ logger.info("Calling <#{__method__.to_s}>")
91
+ config[:chef][:target_environment] ||= '_default'
92
+ if find_executable 'knife'
93
+ knife_cmd = "knife zero bootstrap #{name} \
94
+ --node-name #{name} \
95
+ --ssh-user ubuntu \
96
+ --sudo \
97
+ --environment #{config[:chef][:target_environment]}".gsub(/ * /, ' ')
98
+ puts 'Bootstrapping with chef-zero..'
99
+ logger.info(knife_cmd)
100
+ system(knife_cmd)
101
+ end
102
+ end
103
+
89
104
  def update_databags(config)
90
105
  logger.info("Calling <#{__method__.to_s}>")
91
106
  data_bags_dir = "#{config[:chef][:chef_repo_root]}/data_bags"
@@ -146,13 +161,28 @@ module Gogetit
146
161
  end
147
162
  end
148
163
 
149
- def knife_remove(name)
164
+ def knife_remove(name, options)
150
165
  logger.info("Calling <#{__method__.to_s}>")
151
166
  if find_executable 'knife'
152
- if system('knife ssl check')
167
+ if options['chef']
168
+ if system('knife ssl check')
169
+ logger.info("With chef-server..")
170
+ puts "Deleting node #{name}.."
171
+ logger.info("knife node delete -y #{name}")
172
+ system("knife node delete -y #{name}")
173
+ puts "Deleting client #{name}.."
174
+ logger.info("knife client delete -y #{name}")
175
+ system("knife client delete -y #{name}")
176
+ else
177
+ abort('knife is not configured properly.')
178
+ end
179
+ elsif options['zero']
180
+ logger.info("With chef-zero..")
153
181
  puts "Deleting node #{name}.."
182
+ logger.info("knife node delete -y #{name}")
154
183
  system("knife node delete -y #{name}")
155
184
  puts "Deleting client #{name}.."
185
+ logger.info("knife client delete -y #{name}")
156
186
  system("knife client delete -y #{name}")
157
187
  end
158
188
  end
@@ -1,3 +1,3 @@
1
1
  module Gogetit
2
- VERSION = "0.14.0"
2
+ VERSION = "0.15.0"
3
3
  end
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.14.0
4
+ version: 0.15.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: 2018-02-02 00:00:00.000000000 Z
11
+ date: 2018-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler