kitchen-puppet 0.0.17 → 0.0.18

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.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kitchen
4
4
  module Puppet
5
- VERSION = '0.0.17'
5
+ VERSION = '0.0.18'
6
6
  end
7
7
  end
@@ -51,6 +51,8 @@ module Kitchen
51
51
  default_config :chef_bootstrap_url, 'https://www.getchef.com/chef/install.sh'
52
52
 
53
53
  default_config :puppet_agent_command, nil
54
+
55
+ default_config :http_proxy, nil
54
56
 
55
57
  default_config :puppet_config_path do |provisioner|
56
58
  provisioner.calculate_path('puppet.conf', :file)
@@ -114,7 +116,7 @@ module Kitchen
114
116
  info("Installing puppet on #{puppet_platform}")
115
117
  <<-INSTALL
116
118
  if [ ! $(which puppet) ]; then
117
- #{sudo('wget')} #{puppet_apt_repo}
119
+ #{sudo('wget')} #{wget_proxy_parm} #{puppet_apt_repo}
118
120
  #{sudo('dpkg')} -i #{puppet_apt_repo_file}
119
121
  #{update_packages_debian_cmd}
120
122
  #{sudo('apt-get')} -y install puppet-common#{puppet_debian_version}
@@ -122,11 +124,11 @@ module Kitchen
122
124
  fi
123
125
  #{install_busser}
124
126
  INSTALL
125
- when 'redhat', 'centos', 'fedora'
127
+ when 'redhat', 'centos', 'fedora', 'oracle', 'amazon'
126
128
  info("Installing puppet on #{puppet_platform}")
127
129
  <<-INSTALL
128
130
  if [ ! $(which puppet) ]; then
129
- #{sudo('rpm')} -ivh #{puppet_yum_repo}
131
+ #{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
130
132
  #{update_packages_redhat_cmd}
131
133
  #{sudo('yum')} -y install puppet#{puppet_redhat_version}
132
134
  fi
@@ -137,16 +139,16 @@ module Kitchen
137
139
  <<-INSTALL
138
140
  if [ ! $(which puppet) ]; then
139
141
  if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ]; then
140
- #{sudo('rpm')} -ivh #{puppet_yum_repo}
142
+ #{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
141
143
  #{update_packages_redhat_cmd}
142
144
  #{sudo('yum')} -y install puppet#{puppet_redhat_version}
143
145
  else
144
146
  if [ -f /etc/system-release ] || grep -q 'Amazon Linux' /etc/system-release; then
145
- #{sudo('rpm')} -ivh #{puppet_yum_repo}
147
+ #{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
146
148
  #{update_packages_redhat_cmd}
147
149
  #{sudo('yum')} -y install puppet#{puppet_redhat_version}
148
150
  else
149
- #{sudo('wget')} #{puppet_apt_repo}
151
+ #{sudo('wget')} #{wget_proxy_parm} #{puppet_apt_repo}
150
152
  #{sudo('dpkg')} -i #{puppet_apt_repo_file}
151
153
  #{update_packages_debian_cmd}
152
154
  #{sudo('apt-get')} -y install puppet-common#{puppet_debian_version}
@@ -219,7 +221,7 @@ module Kitchen
219
221
  else
220
222
  [
221
223
  custom_facts,
222
- sudo('puppet'),
224
+ sudo_env('puppet'),
223
225
  'agent',
224
226
  puppet_server_flag,
225
227
  "--waitforcert=#{config[:puppet_waitforcert]}",
@@ -272,12 +274,16 @@ module Kitchen
272
274
  end
273
275
 
274
276
  def update_packages_debian_cmd
275
- config[:update_package_repos] ? "#{sudo('apt-get')} update" : nil
277
+ config[:update_package_repos] ? "#{sudo_env('apt-get')} update" : nil
276
278
  end
277
279
 
278
280
  def update_packages_redhat_cmd
279
- config[:update_package_repos] ? "#{sudo('yum')} makecache" : nil
281
+ config[:update_package_repos] ? "#{sudo_env('yum')} makecache" : nil
280
282
  end
283
+
284
+ def sudo_env(pm)
285
+ http_proxy ? "#{sudo('env')} http_proxy=#{http_proxy} #{pm}" : "#{sudo(pm)}"
286
+ end
281
287
 
282
288
  def custom_facts
283
289
  return nil if config[:custom_facts].none?
@@ -342,6 +348,22 @@ module Kitchen
342
348
  def puppet_yum_repo
343
349
  config[:puppet_yum_repo]
344
350
  end
351
+
352
+ def proxy_parm
353
+ http_proxy ? "--httpproxy #{URI.parse(http_proxy).host.downcase} --httpport #{URI.parse(http_proxy).port} " : nil
354
+ end
355
+
356
+ def gem_proxy_parm
357
+ http_proxy ? "--http-proxy #{http_proxy}" : nil
358
+ end
359
+
360
+ def wget_proxy_parm
361
+ http_proxy ? "-e use_proxy=yes -e http_proxy=#{http_proxy}" : nil
362
+ end
363
+
364
+ def http_proxy
365
+ config[:http_proxy]
366
+ end
345
367
 
346
368
  def chef_url
347
369
  config[:chef_bootstrap_url]
@@ -20,6 +20,7 @@
20
20
  # for documentation configuration parameters with puppet_apply provisioner.
21
21
  #
22
22
 
23
+ require 'uri'
23
24
  require 'json'
24
25
  require 'kitchen/provisioner/base'
25
26
  require 'kitchen/provisioner/puppet/librarian'
@@ -52,6 +53,8 @@ module Kitchen
52
53
  default_config :chef_bootstrap_url, 'https://www.getchef.com/chef/install.sh'
53
54
 
54
55
  default_config :puppet_apply_command, nil
56
+
57
+ default_config :http_proxy, nil
55
58
 
56
59
  default_config :hiera_data_remote_path, '/var/lib/hiera'
57
60
  default_config :manifest, 'site.pp'
@@ -162,21 +165,21 @@ module Kitchen
162
165
  info("Installing puppet on #{puppet_platform}")
163
166
  <<-INSTALL
164
167
  if [ ! $(which puppet) ]; then
165
- #{sudo('wget')} #{puppet_apt_repo}
168
+ #{sudo('wget')} #{wget_proxy_parm} #{puppet_apt_repo}
166
169
  #{sudo('dpkg')} -i #{puppet_apt_repo_file}
167
170
  #{update_packages_debian_cmd}
168
- #{sudo('apt-get')} -y install puppet-common#{puppet_debian_version}
169
- #{sudo('apt-get')} -y install puppet#{puppet_debian_version}
171
+ #{sudo_env('apt-get')} -y install puppet-common#{puppet_debian_version}
172
+ #{sudo_env('apt-get')} -y install puppet#{puppet_debian_version}
170
173
  fi
171
174
  #{install_busser}
172
175
  INSTALL
173
- when 'redhat', 'centos', 'fedora'
176
+ when 'redhat', 'centos', 'fedora', 'oracle', 'amazon'
174
177
  info("Installing puppet on #{puppet_platform}")
175
178
  <<-INSTALL
176
179
  if [ ! $(which puppet) ]; then
177
- #{sudo('rpm')} -ivh #{puppet_yum_repo}
180
+ #{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
178
181
  #{update_packages_redhat_cmd}
179
- #{sudo('yum')} -y install puppet#{puppet_redhat_version}
182
+ #{sudo_env('yum')} -y install puppet#{puppet_redhat_version}
180
183
  fi
181
184
  #{install_busser}
182
185
  INSTALL
@@ -185,20 +188,20 @@ module Kitchen
185
188
  <<-INSTALL
186
189
  if [ ! $(which puppet) ]; then
187
190
  if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ]; then
188
- #{sudo('rpm')} -ivh #{puppet_yum_repo}
191
+ #{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
189
192
  #{update_packages_redhat_cmd}
190
- #{sudo('yum')} -y install puppet#{puppet_redhat_version}
193
+ #{sudo_env('yum')} -y install puppet#{puppet_redhat_version}
191
194
  else
192
195
  if [ -f /etc/system-release ] || [ grep -q 'Amazon Linux' /etc/system-release ]; then
193
- #{sudo('rpm')} -ivh #{puppet_yum_repo}
196
+ #{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
194
197
  #{update_packages_redhat_cmd}
195
- #{sudo('yum')} -y install puppet#{puppet_redhat_version}
198
+ #{sudo_env('yum')} -y install puppet#{puppet_redhat_version}
196
199
  else
197
- #{sudo('wget')} #{puppet_apt_repo}
200
+ #{sudo('wget')} #{wget_proxy_parm} #{puppet_apt_repo}
198
201
  #{sudo('dpkg')} -i #{puppet_apt_repo_file}
199
202
  #{update_packages_debian_cmd}
200
- #{sudo('apt-get')} -y install puppet-common#{puppet_debian_version}
201
- #{sudo('apt-get')} -y install puppet#{puppet_debian_version}
203
+ #{sudo_env('apt-get')} -y install puppet-common#{puppet_debian_version}
204
+ #{sudo_env('apt-get')} -y install puppet#{puppet_debian_version}
202
205
  fi
203
206
  fi
204
207
  fi
@@ -216,7 +219,7 @@ module Kitchen
216
219
  # A backend for Hiera that provides per-value asymmetric encryption of sensitive data
217
220
  if [[ $(#{sudo('gem')} list hiera-eyaml -i) == 'false' ]]; then
218
221
  echo "-----> Installing hiera-eyaml to provide encryption of hiera data"
219
- #{sudo('gem')} install --no-ri --no-rdoc hiera-eyaml
222
+ #{sudo('gem')} install #{gem_proxy_parm} --no-ri --no-rdoc hiera-eyaml
220
223
  fi
221
224
  INSTALL
222
225
  end
@@ -333,7 +336,7 @@ module Kitchen
333
336
  [
334
337
  custom_facts,
335
338
  facter_facts,
336
- sudo('puppet'),
339
+ sudo_env('puppet'),
337
340
  'apply',
338
341
  File.join(config[:root_path], 'manifests', manifest),
339
342
  "--modulepath=#{File.join(config[:root_path], 'modules')}",
@@ -469,12 +472,17 @@ module Kitchen
469
472
  end
470
473
 
471
474
  def update_packages_debian_cmd
472
- config[:update_package_repos] ? "#{sudo('apt-get')} update" : nil
475
+ config[:update_package_repos] ? "#{sudo_env('apt-get')} update" : nil
473
476
  end
474
477
 
475
478
  def update_packages_redhat_cmd
476
- config[:update_package_repos] ? "#{sudo('yum')} makecache" : nil
479
+ # #{sudo('yum')}
480
+ config[:update_package_repos] ? "#{sudo_env('yum')} makecache" : nil
477
481
  end
482
+
483
+ def sudo_env(pm)
484
+ http_proxy ? "#{sudo('env')} http_proxy=#{http_proxy} #{pm}" : "#{sudo(pm)}"
485
+ end
478
486
 
479
487
  def remove_puppet_repo
480
488
  config[:remove_puppet_repo]
@@ -489,11 +497,7 @@ module Kitchen
489
497
  end
490
498
 
491
499
  def remove_repo
492
- if remove_puppet_repo
493
- "; #{sudo('rm')} -rf /tmp/kitchen #{hiera_data_remote_path} #{hiera_eyaml_key_remote_path} /etc/puppet/* "
494
- else
495
- nil
496
- end
500
+ remove_puppet_repo ? "; #{sudo('rm')} -rf /tmp/kitchen #{hiera_data_remote_path} #{hiera_eyaml_key_remote_path} /etc/puppet/* " : nil
497
501
  end
498
502
 
499
503
  def puppet_apt_repo
@@ -507,6 +511,22 @@ module Kitchen
507
511
  def puppet_yum_repo
508
512
  config[:puppet_yum_repo]
509
513
  end
514
+
515
+ def proxy_parm
516
+ http_proxy ? "--httpproxy #{URI.parse(http_proxy).host.downcase} --httpport #{URI.parse(http_proxy).port} " : nil
517
+ end
518
+
519
+ def gem_proxy_parm
520
+ http_proxy ? "--http-proxy #{http_proxy}" : nil
521
+ end
522
+
523
+ def wget_proxy_parm
524
+ http_proxy ? "-e use_proxy=yes -e http_proxy=#{http_proxy}" : nil
525
+ end
526
+
527
+ def http_proxy
528
+ config[:http_proxy]
529
+ end
510
530
 
511
531
  def chef_url
512
532
  config[:chef_bootstrap_url]
@@ -37,6 +37,7 @@ hiera_eyaml | false | use hiera-eyaml to encrypt hiera data
37
37
  hiera_eyaml_key_remote_path | "/etc/puppet/secure/keys" | directory of hiera-eyaml keys on server
38
38
  hiera_eyaml_key_path | "hiera_keys" | directory of hiera-eyaml keys on workstation
39
39
  facter_file | nil | yaml file of custom facter_files to be provided to the puppet-apply command
40
+ http_proxy | nil | use http proxy when installing puppet and packages
40
41
 
41
42
  ## Puppet Apply Configuring Provisioner Options
42
43
 
@@ -118,6 +119,7 @@ chef_bootstrap_url |"https://www.getchef.com/chef/install.sh"| the chef (needed
118
119
  puppet_agent_command | nil | Overwrite the puppet agent command. Needs "sudo -E puppet agent" as a prefix.
119
120
  require_chef_for_busser | true | Install chef as currently needed by busser to run tests
120
121
  puppet_config_path | | path of custom puppet.conf file
122
+ http_proxy | nil | use http proxy when installing puppet and packages
121
123
 
122
124
 
123
125
  ## Puppet Agent Configuring Provisioner Options
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-30 00:00:00.000000000 Z
12
+ date: 2014-11-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! '== DESCRIPTION:
15
15