mixlib-install 3.4.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGELOG.md +9 -3
  4. data/README.md +27 -1
  5. data/VERSION +1 -1
  6. data/acceptance/.suites/ubuntu_install_checksum/.acceptance/acceptance-cookbook/.gitignore +8 -0
  7. data/acceptance/{windows-nano → .suites/ubuntu_install_checksum}/.acceptance/acceptance-cookbook/metadata.rb +0 -0
  8. data/acceptance/{windows-server-2012r2 → .suites/ubuntu_install_checksum}/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -0
  9. data/acceptance/.suites/ubuntu_install_checksum/.acceptance/acceptance-cookbook/recipes/provision.rb +24 -0
  10. data/acceptance/.suites/ubuntu_install_checksum/.acceptance/acceptance-cookbook/recipes/verify.rb +11 -0
  11. data/acceptance/.suites/ubuntu_install_checksum/inspec/verify.rb +78 -0
  12. data/acceptance/.suites/ubuntu_install_checksum/terraform/application.tf +95 -0
  13. data/acceptance/{windows-nano → .suites/ubuntu_install_checksum}/terraform/aws.tf +0 -0
  14. data/acceptance/.suites/ubuntu_install_checksum/terraform/variables.tf +27 -0
  15. data/acceptance/{windows-nano → .suites/windows-nano}/.acceptance/acceptance-cookbook/.gitignore +0 -0
  16. data/acceptance/{windows-nano → .suites/windows-nano}/.acceptance/acceptance-cookbook/libraries/chef_extentions.rb +0 -0
  17. data/acceptance/{windows-server-2012r2 → .suites/windows-nano}/.acceptance/acceptance-cookbook/metadata.rb +0 -0
  18. data/acceptance/{windows-nano → .suites/windows-nano}/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -0
  19. data/acceptance/{windows-nano → .suites/windows-nano}/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -0
  20. data/acceptance/{windows-nano → .suites/windows-nano}/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -0
  21. data/acceptance/{windows-nano → .suites/windows-nano}/inspec/verify.rb +0 -0
  22. data/acceptance/{windows-nano → .suites/windows-nano}/terraform/application.tf +0 -0
  23. data/acceptance/{windows-server-2012r2 → .suites/windows-nano}/terraform/aws.tf +0 -0
  24. data/acceptance/{windows-nano → .suites/windows-nano}/terraform/variables.tf +0 -0
  25. data/acceptance/centos_install_checksum/.acceptance/acceptance-cookbook/.gitignore +8 -0
  26. data/acceptance/centos_install_checksum/.acceptance/acceptance-cookbook/metadata.rb +2 -0
  27. data/acceptance/centos_install_checksum/.acceptance/acceptance-cookbook/recipes/destroy.rb +3 -0
  28. data/acceptance/centos_install_checksum/.acceptance/acceptance-cookbook/recipes/provision.rb +24 -0
  29. data/acceptance/centos_install_checksum/.acceptance/acceptance-cookbook/recipes/verify.rb +11 -0
  30. data/acceptance/centos_install_checksum/inspec/verify.rb +78 -0
  31. data/acceptance/centos_install_checksum/terraform/application.tf +95 -0
  32. data/acceptance/centos_install_checksum/terraform/aws.tf +8 -0
  33. data/acceptance/centos_install_checksum/terraform/variables.tf +27 -0
  34. data/acceptance/{windows-server-2012r2 → windows-server-2012r2-checksum}/.acceptance/acceptance-cookbook/.gitignore +0 -0
  35. data/acceptance/windows-server-2012r2-checksum/.acceptance/acceptance-cookbook/metadata.rb +2 -0
  36. data/acceptance/windows-server-2012r2-checksum/.acceptance/acceptance-cookbook/recipes/destroy.rb +3 -0
  37. data/acceptance/windows-server-2012r2-checksum/.acceptance/acceptance-cookbook/recipes/provision.rb +22 -0
  38. data/acceptance/{windows-server-2012r2 → windows-server-2012r2-checksum}/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -0
  39. data/acceptance/windows-server-2012r2-checksum/inspec/verify.rb +21 -0
  40. data/acceptance/windows-server-2012r2-checksum/terraform/application.tf +94 -0
  41. data/acceptance/windows-server-2012r2-checksum/terraform/aws.tf +8 -0
  42. data/acceptance/{windows-server-2012r2 → windows-server-2012r2-checksum}/terraform/variables.tf +0 -0
  43. data/acceptance/windows-server-2012r2-ps1/.acceptance/acceptance-cookbook/.gitignore +2 -0
  44. data/acceptance/windows-server-2012r2-ps1/.acceptance/acceptance-cookbook/metadata.rb +2 -0
  45. data/acceptance/windows-server-2012r2-ps1/.acceptance/acceptance-cookbook/recipes/destroy.rb +3 -0
  46. data/acceptance/{windows-server-2012r2 → windows-server-2012r2-ps1}/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -0
  47. data/acceptance/windows-server-2012r2-ps1/.acceptance/acceptance-cookbook/recipes/verify.rb +14 -0
  48. data/acceptance/{windows-server-2012r2 → windows-server-2012r2-ps1}/inspec/verify.rb +0 -0
  49. data/acceptance/{windows-server-2012r2 → windows-server-2012r2-ps1}/terraform/application.tf +0 -0
  50. data/acceptance/windows-server-2012r2-ps1/terraform/aws.tf +8 -0
  51. data/acceptance/windows-server-2012r2-ps1/terraform/variables.tf +16 -0
  52. data/lib/mixlib/install/generator/bourne/scripts/fetch_metadata.sh.erb +2 -1
  53. data/lib/mixlib/install/generator/bourne/scripts/fetch_package.sh +41 -7
  54. data/lib/mixlib/install/generator/bourne/scripts/script_cli_parameters.sh +6 -2
  55. data/lib/mixlib/install/generator/powershell/scripts/install_project.ps1 +47 -26
  56. data/lib/mixlib/install/version.rb +1 -1
  57. metadata +49 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 330f993cfb69a22e018ecffd2993b74619945cb9
4
- data.tar.gz: d80c5194651fb543c57cdec4a8c3366b290842ee
3
+ metadata.gz: 8cbca7cb9a853574779432ba1d0e08f2444bf925
4
+ data.tar.gz: 01151257065ddfdd27a4665198c35781727bcc01
5
5
  SHA512:
6
- metadata.gz: fa96263fded01b16629164a336182234331bfa905a80bf16bd91aa40f0efd1c6b3ba1c6e68a576fb5657a48821107e308dc1da66a1efef8b3d77226e83bc8fde
7
- data.tar.gz: 86c5bf3ff6611fbd1282c50e2998b5c43efecbb6752c7eb29f2703d1f7dc366c06e6c34e03e013c9d53d3882424eacd4a45f14dfacd6c3d0ac041eab98ffa772
6
+ metadata.gz: a0f8a54590f1f33f8e45ffc4d73925e435cf1c229ce6778960251811e3c3ca60465693e7bb08c70a1f76006ca8e09262a78a642530a985202ba43b83cb0d682d
7
+ data.tar.gz: 0e2b10d4207acf6ee5fcc551f1011d4cc927a9dc1ff511c1437f8bbf4b9209866353b6c994ba87131e88befe2ae8f6e227fb7d249784cc889daafdf645abf7e1
@@ -37,6 +37,8 @@ matrix:
37
37
  env: SUITE=ubuntu
38
38
  - rvm: 2.3
39
39
  env: SUITE=windows-server
40
+ - rvm: 2.3
41
+ env: SUITE=centos
40
42
 
41
43
  before_script:
42
44
  - ci/before-script.sh
@@ -1,11 +1,17 @@
1
1
  # Mixlib::Install Changes
2
2
 
3
- <!-- latest_release 3.4.0 -->
3
+ <!-- latest_release unreleased -->
4
+ ## Unreleased
5
+
6
+ #### Merged Pull Requests
7
+ - v3.5.0 [#239](https://github.com/chef/mixlib-install/pull/239) ([wrightp](https://github.com/wrightp))
8
+ - download url override and checksum updates [#237](https://github.com/chef/mixlib-install/pull/237) ([wrightp](https://github.com/wrightp))
9
+ <!-- latest_release -->
10
+
4
11
  ## [v3.4.0](https://github.com/chef/mixlib-install/tree/v3.4.0) (2017-08-22)
5
12
 
6
13
  #### Merged Pull Requests
7
14
  - Add install_strategy option to bootstrap install scripts [#232](https://github.com/chef/mixlib-install/pull/232) ([wrightp](https://github.com/wrightp))
8
- <!-- latest_release -->
9
15
 
10
16
  ## [v3.3.4](https://github.com/chef/mixlib-install/tree/v3.3.4) (2017-08-10)
11
17
 
@@ -190,4 +196,4 @@
190
196
 
191
197
  ## [1.0.0]
192
198
  - Ability to query product artifacts from multiple channels
193
- - Ability to generate installation scripts for `sh` and `ps1`
199
+ - Ability to generate installation scripts for `sh` and `ps1`
data/README.md CHANGED
@@ -175,7 +175,7 @@ options = {
175
175
  Collecting software dependencies and license content for ArtifactInfo instances
176
176
  requires additional requests to the repository server. By default, collection is disabled.
177
177
  To return data for instance methods `software_dependencies` and `license_content`, the `include_metadata` option must be enabled.
178
- ```
178
+ ```ruby
179
179
  options = {
180
180
  channel: :current,
181
181
  product_name: 'chef',
@@ -197,6 +197,32 @@ artifact.software_dependencies.class
197
197
 
198
198
  ```
199
199
 
200
+
201
+ ### Install Scripts
202
+ mixlib-install generates the bootstrap installation scripts known as install.sh and install.ps1. The associated install script will be returned when calling `#install_command` on the Mixlib::Install instance.
203
+
204
+ Mixlib::Install instantiation option `install_command_options` can accept variables (bourne) or parameters (powershell) to modify the behavior of the install scripts.
205
+
206
+ Some of the more common options include:
207
+
208
+ `download_url_override`: Use the provided URL instead of fetching the metadata URL from Chef Software Inc's software distribution systems.
209
+ `checksum`: SHA256 value associated to the directed file for the download_url_override option. This setting is optional. Not setting this will download the file even if a cached file is detected.
210
+ `install_strategy`: Set to "once" to have the script exit if the product being installed is detected.
211
+
212
+ ```ruby
213
+ options = {
214
+ product_name: 'chef',
215
+ install_command_options: {
216
+ download_url_override: "https://file/path",
217
+ checksum: "OPTIONAL",
218
+ install_strategy: "once",
219
+ }
220
+ }
221
+
222
+ Mixlib::Install.new(options).install_command
223
+ ```
224
+
225
+
200
226
  ## Development
201
227
  VCR is a tool that helps cache and replay http responses. When these responses change or when you add more tests you might need to update cached responses. Check out [spec_helper.rb](https://github.com/chef/mixlib-install/blob/master/spec/spec_helper.rb) for instructions on how to do this.
202
228
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.4.0
1
+ 3.5.0
@@ -0,0 +1,8 @@
1
+ nodes/
2
+ tmp/
3
+
4
+ # Terraform
5
+ *.tfstate
6
+ *.tfstate.backup
7
+ *_override.tf
8
+
@@ -0,0 +1,24 @@
1
+ # Generate install script then write to disk for terraform to copy to the instance for execution
2
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.new(product_name: 'chef', product_version: :latest, channel: :stable, install_command_options: {download_url_override: 'https://packages.chef.io/files/stable/chef/13.2.20/ubuntu/14.04/chef_13.2.20-1_amd64.deb', cmdline_dl_dir: '/tmp/checksum'}).install_command\" > ../.acceptance_data/ubuntu_install_url.sh" do
3
+ cwd node['chef-acceptance']['suite-dir']
4
+ end
5
+
6
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.new(product_name: 'chef', product_version: :latest, channel: :stable, install_command_options: {download_url_override: 'https://packages.chef.io/files/stable/chef/13.2.20/ubuntu/14.04/chef_13.2.20-1_amd64.deb', checksum: '88cd274a694bfe23d255937794744d50af972097958fa681a544479e2bfb7f6b', cmdline_dl_dir: '/tmp/checksum'}).install_command\" > ../.acceptance_data/ubuntu_install_checksum.sh" do
7
+ cwd node['chef-acceptance']['suite-dir']
8
+ end
9
+
10
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.new(product_name: 'chef', product_version: :latest, channel: :stable, install_command_options: {cmdline_dl_dir: '/tmp/metadata'}).install_command\" > ../.acceptance_data/ubuntu_install_metadata.sh" do
11
+ cwd node['chef-acceptance']['suite-dir']
12
+ end
13
+
14
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.new(product_name: 'chef', product_version: :latest, channel: :stable, install_command_options: {download_url_override: 'https://packages.chef.io/files/stable/chef/13.2.20/ubuntu/14.04/chef_13.2.20-1_amd64.deb', checksum: 'FOOOOOOOOOOOOOO', cmdline_dl_dir: '/tmp/bad'}).install_command\" > ../.acceptance_data/ubuntu_install_bad.sh" do
15
+ cwd node['chef-acceptance']['suite-dir']
16
+ end
17
+
18
+ execute "terraform plan" do
19
+ cwd "#{node['chef-acceptance']['suite-dir']}/terraform"
20
+ end
21
+
22
+ execute "terraform apply" do
23
+ cwd "#{node['chef-acceptance']['suite-dir']}/terraform"
24
+ end
@@ -0,0 +1,11 @@
1
+ ruby_block "get ip" do
2
+ block do
3
+ tf_state = JSON.parse(File.read("#{node['chef-acceptance']['suite-dir']}/terraform/terraform.tfstate"))
4
+ node.default["ip"] = tf_state["modules"].first["resources"]["aws_instance.mixlib_install_sh"]["primary"]["attributes"]["public_ip"]
5
+ end
6
+ end
7
+
8
+ execute "run inspec" do
9
+ command lazy { "inspec exec verify.rb -t ssh://ubuntu@#{node['ip']} -i ~/.ssh/es-infrastructure.pem" }
10
+ cwd "#{node['chef-acceptance']['suite-dir']}/inspec"
11
+ end
@@ -0,0 +1,78 @@
1
+ # Uncomment when re-running for local development
2
+ describe command("sudo rm -rf /tmp/metadata /tmp/checksum /tmp/bad; sudo dpkg -r chef") do
3
+ its("exit_status") { should eq 0 }
4
+ end
5
+
6
+ #
7
+ # DOWNLOAD URL TESTS
8
+ #
9
+ # No checksum provided
10
+ describe command("sudo /tmp/install.sh") do
11
+ its("stdout") { should match /Download URL override specified/ }
12
+ its("stdout") { should match /tmp\/checksum\/chef.* not found/ }
13
+ its("stdout") { should match /Thank you/ }
14
+ end
15
+
16
+ # Running same script again
17
+ describe command("sudo /tmp/install.sh") do
18
+ its("stdout") { should match /Download URL override specified/ }
19
+ its("stdout") { should match /Verifying local file/ }
20
+ its("stdout") { should match /Checksum not specified/ }
21
+ its("stdout") { should match /Thank you/ }
22
+ end
23
+
24
+ # Now with a valid checksum
25
+ describe command("sudo /tmp/install_checksum.sh") do
26
+ its("stdout") { should match /Download URL override specified/ }
27
+ its("stdout") { should match /Verifying local file/ }
28
+ its("stdout") { should match /Checksum match/ }
29
+ its("stdout") { should match /Thank you/ }
30
+ end
31
+
32
+ # Corrupt the file we just downloaded
33
+ describe command("sudo chown ubuntu /tmp/checksum; sudo chown ubuntu /tmp/checksum/*; for i in /tmp/checksum/*; do echo 'oops'>>$i; done;") do
34
+ its("exit_status") { should eq 0 }
35
+ end
36
+
37
+ # Run with checksum and it should download and re-verify the checksum
38
+ describe command("sudo /tmp/install_checksum.sh") do
39
+ its("stdout") { should match /Download URL override specified/ }
40
+ its("stdout") { should match /Verifying local file/ }
41
+ its("stdout") { should match /Checksum mismatch/ }
42
+ its("stdout") { should match /Thank you/ }
43
+ end
44
+
45
+ # clean up
46
+ describe command("sudo dpkg -r chef") do
47
+ its("stdout") { should match /Removing chef/ }
48
+ end
49
+
50
+ #
51
+ # METADATA URL TESTS
52
+ #
53
+ # Default behavior when specifying a download location (otherwise caching is unavailable)
54
+ describe command("sudo /tmp/install_metadata.sh") do
55
+ its("stdout") { should_not match /tmp\/metadata\/chef.* exists/ }
56
+ its("stdout") { should match /Thank you/ }
57
+ end
58
+
59
+ # Running same script again
60
+ describe command("sudo /tmp/install_metadata.sh") do
61
+ its("stdout") { should match /tmp\/metadata\/chef.* exists/ }
62
+ its("stdout") { should match /Thank you/ }
63
+ end
64
+
65
+ # clean up
66
+ describe command("sudo dpkg -r chef") do
67
+ its("stdout") { should match /Removing chef/ }
68
+ end
69
+
70
+ #
71
+ # DOWNLOAD URL BAD CHECKSUM TESTS
72
+ #
73
+ describe command("sudo /tmp/install_bad.sh") do
74
+ its("stdout") { should match /Download URL override specified/ }
75
+ its("stdout") { should match /tmp\/bad\/chef.* not found/ }
76
+ its("stdout") { should match /Package checksum mismatch/ }
77
+ its("exit_status") { should eq 1 }
78
+ end
@@ -0,0 +1,95 @@
1
+ data "aws_ami" "ubuntu_14_ami" {
2
+ most_recent = true
3
+
4
+ filter {
5
+ name = "owner-id"
6
+ values = ["099720109477"]
7
+ }
8
+
9
+ filter {
10
+ name = "name"
11
+ values = ["ubuntu/images/*/ubuntu-*-14.04-*-server-*"]
12
+ }
13
+
14
+ filter {
15
+ name = "architecture"
16
+ values = ["x86_64"]
17
+ }
18
+
19
+ filter {
20
+ name = "virtualization-type"
21
+ values = ["hvm"]
22
+ }
23
+
24
+ filter {
25
+ name = "block-device-mapping.volume-type"
26
+ values = ["standard"]
27
+ }
28
+
29
+ filter {
30
+ name = "image-type"
31
+ values = ["machine"]
32
+ }
33
+ }
34
+
35
+ resource "aws_instance" "mixlib_install_sh" {
36
+ count = 1
37
+
38
+ ami = "${data.aws_ami.ubuntu_14_ami.id}"
39
+ instance_type = "${var.aws_instance_type}"
40
+ key_name = "es-infrastructure"
41
+
42
+ associate_public_ip_address = true
43
+
44
+ subnet_id = "subnet-11ac0174" # Planet Releng Public Subnet
45
+ source_dest_check = false
46
+
47
+ vpc_security_group_ids = [
48
+ "sg-96274af3",
49
+ ]
50
+
51
+ connection {
52
+ user = "ubuntu"
53
+ private_key = "${file("${var.connection_private_key}")}"
54
+ agent = "${var.connection_agent}"
55
+ timeout = "10m"
56
+ }
57
+
58
+ tags {
59
+ # ChefOps's AWS standard tags:
60
+ X-Dept = "EngServ"
61
+ X-Contact = "pwright"
62
+ X-Production = "false"
63
+ X-Environment = "acceptance"
64
+ X-Application = "mixlib-install"
65
+ }
66
+
67
+ provisioner "file" {
68
+ source = "../../.acceptance_data/ubuntu_install_url.sh"
69
+ destination = "/tmp/install.sh"
70
+ }
71
+
72
+ provisioner "file" {
73
+ source = "../../.acceptance_data/ubuntu_install_checksum.sh"
74
+ destination = "/tmp/install_checksum.sh"
75
+ }
76
+
77
+ provisioner "file" {
78
+ source = "../../.acceptance_data/ubuntu_install_metadata.sh"
79
+ destination = "/tmp/install_metadata.sh"
80
+ }
81
+
82
+ provisioner "file" {
83
+ source = "../../.acceptance_data/ubuntu_install_bad.sh"
84
+ destination = "/tmp/install_bad.sh"
85
+ }
86
+
87
+ provisioner "remote-exec" {
88
+ inline = [
89
+ "chmod +x /tmp/install.sh",
90
+ "chmod +x /tmp/install_checksum.sh",
91
+ "chmod +x /tmp/install_metadata.sh",
92
+ "chmod +x /tmp/install_bad.sh",
93
+ ]
94
+ }
95
+ }
@@ -0,0 +1,27 @@
1
+ # Region to create infrastructure in
2
+ variable "aws_region" {
3
+ type = "string"
4
+ default = "us-west-2"
5
+ }
6
+
7
+ variable "aws_instance_type" {
8
+ type = "string"
9
+ default = "t2.micro"
10
+ }
11
+
12
+ # Used to indicidate whether the environment should be treated as "prod"
13
+ # This is mainly used for the `X-Production` AWS tag.
14
+ variable "production" {
15
+ default = "false"
16
+ }
17
+
18
+ # SSH Connection info used for remote provisioning instances
19
+ variable "connection_agent" {
20
+ description = "Set to false to disable using ssh-agent to authenticate"
21
+ default = false
22
+ }
23
+
24
+ variable "connection_private_key" {
25
+ description = "File path to AWS keypair private key to provision with"
26
+ default = "~/.ssh/es-infrastructure.pem"
27
+ }
@@ -0,0 +1,8 @@
1
+ nodes/
2
+ tmp/
3
+
4
+ # Terraform
5
+ *.tfstate
6
+ *.tfstate.backup
7
+ *_override.tf
8
+
@@ -0,0 +1,3 @@
1
+ execute "terraform destroy -force" do
2
+ cwd "#{node['chef-acceptance']['suite-dir']}/terraform"
3
+ end
@@ -0,0 +1,24 @@
1
+ # Generate install script then write to disk for terraform to copy to the instance for execution
2
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.new(product_name: 'chef', product_version: :latest, channel: :stable, install_command_options: {download_url_override: 'https://packages.chef.io/files/stable/chef/13.3.42/el/7/chef-13.3.42-1.el7.x86_64.rpm', cmdline_dl_dir: '/tmp/checksum'}).install_command\" > ../.acceptance_data/centos_install_url.sh" do
3
+ cwd node['chef-acceptance']['suite-dir']
4
+ end
5
+
6
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.new(product_name: 'chef', product_version: :latest, channel: :stable, install_command_options: {download_url_override: 'https://packages.chef.io/files/stable/chef/13.3.42/el/7/chef-13.3.42-1.el7.x86_64.rpm', checksum: 'fe051b504856a74ccce1fd23ff92c296506cb8292a3933c71069ae915e7a4a00', cmdline_dl_dir: '/tmp/checksum'}).install_command\" > ../.acceptance_data/centos_install_checksum.sh" do
7
+ cwd node['chef-acceptance']['suite-dir']
8
+ end
9
+
10
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.new(product_name: 'chef', product_version: :latest, channel: :stable, install_command_options: {cmdline_dl_dir: '/tmp/metadata'}).install_command\" > ../.acceptance_data/centos_install_metadata.sh" do
11
+ cwd node['chef-acceptance']['suite-dir']
12
+ end
13
+
14
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.new(product_name: 'chef', product_version: :latest, channel: :stable, install_command_options: {download_url_override: 'https://packages.chef.io/files/stable/chef/13.3.42/el/7/chef-13.3.42-1.el7.x86_64.rpm', checksum: 'FOOOOOOOOOOOOOO', cmdline_dl_dir: '/tmp/bad'}).install_command\" > ../.acceptance_data/centos_install_bad.sh" do
15
+ cwd node['chef-acceptance']['suite-dir']
16
+ end
17
+
18
+ execute "terraform plan" do
19
+ cwd "#{node['chef-acceptance']['suite-dir']}/terraform"
20
+ end
21
+
22
+ execute "terraform apply" do
23
+ cwd "#{node['chef-acceptance']['suite-dir']}/terraform"
24
+ end
@@ -0,0 +1,11 @@
1
+ ruby_block "get ip" do
2
+ block do
3
+ tf_state = JSON.parse(File.read("#{node['chef-acceptance']['suite-dir']}/terraform/terraform.tfstate"))
4
+ node.default["ip"] = tf_state["modules"].first["resources"]["aws_instance.mixlib_install_sh"]["primary"]["attributes"]["public_ip"]
5
+ end
6
+ end
7
+
8
+ execute "run inspec" do
9
+ command lazy { "inspec exec verify.rb -t ssh://centos@#{node['ip']} -i ~/.ssh/es-infrastructure.pem" }
10
+ cwd "#{node['chef-acceptance']['suite-dir']}/inspec"
11
+ end
@@ -0,0 +1,78 @@
1
+ # Uncomment when re-running for local development
2
+ describe command("sudo rm -rf /tmp/metadata /tmp/checksum /tmp/bad; sudo yum remove chef -y") do
3
+ its("exit_status") { should eq 0 }
4
+ end
5
+
6
+ #
7
+ # DOWNLOAD URL TESTS
8
+ #
9
+ # No checksum provided
10
+ describe command("sudo /tmp/install.sh") do
11
+ its("stdout") { should match /Download URL override specified/ }
12
+ its("stdout") { should match /tmp\/checksum\/chef.* not found/ }
13
+ its("stdout") { should match /Thank you/ }
14
+ end
15
+
16
+ # Running same script again
17
+ describe command("sudo /tmp/install.sh") do
18
+ its("stdout") { should match /Download URL override specified/ }
19
+ its("stdout") { should match /Verifying local file/ }
20
+ its("stdout") { should match /Checksum not specified/ }
21
+ its("stdout") { should match /Thank you/ }
22
+ end
23
+
24
+ # Now with a valid checksum
25
+ describe command("sudo /tmp/install_checksum.sh") do
26
+ its("stdout") { should match /Download URL override specified/ }
27
+ its("stdout") { should match /Verifying local file/ }
28
+ its("stdout") { should match /Checksum match/ }
29
+ its("stdout") { should match /Thank you/ }
30
+ end
31
+
32
+ # Corrupt the file we just downloaded
33
+ describe command("sudo chown centos /tmp/checksum; sudo chown centos /tmp/checksum/*; for i in /tmp/checksum/*; do echo 'oops'>>$i; done;") do
34
+ its("exit_status") { should eq 0 }
35
+ end
36
+
37
+ # Run with checksum and it should download and re-verify the checksum
38
+ describe command("sudo /tmp/install_checksum.sh") do
39
+ its("stdout") { should match /Download URL override specified/ }
40
+ its("stdout") { should match /Verifying local file/ }
41
+ its("stdout") { should match /Checksum mismatch/ }
42
+ its("stdout") { should match /Thank you/ }
43
+ end
44
+
45
+ # clean up
46
+ describe command("sudo yum remove chef -y") do
47
+ its("stdout") { should match /Complete!/ }
48
+ end
49
+
50
+ #
51
+ # METADATA URL TESTS
52
+ #
53
+ # Default behavior when specifying a download location (otherwise caching is unavailable)
54
+ describe command("sudo /tmp/install_metadata.sh") do
55
+ its("stdout") { should_not match /tmp\/metadata\/chef.* exists/ }
56
+ its("stdout") { should match /Thank you/ }
57
+ end
58
+
59
+ # Running same script again
60
+ describe command("sudo /tmp/install_metadata.sh") do
61
+ its("stdout") { should match /tmp\/metadata\/chef.* exists/ }
62
+ its("stdout") { should match /Thank you/ }
63
+ end
64
+
65
+ # clean up
66
+ describe command("sudo yum remove chef -y") do
67
+ its("stdout") { should match /Complete!/ }
68
+ end
69
+
70
+ #
71
+ # DOWNLOAD URL BAD CHECKSUM TESTS
72
+ #
73
+ describe command("sudo /tmp/install_bad.sh") do
74
+ its("stdout") { should match /Download URL override specified/ }
75
+ its("stdout") { should match /tmp\/bad\/chef.* not found/ }
76
+ its("stdout") { should match /Package checksum mismatch/ }
77
+ its("exit_status") { should eq 1 }
78
+ end
@@ -0,0 +1,95 @@
1
+ data "aws_ami" "centos_7_ami" {
2
+ most_recent = true
3
+
4
+ filter {
5
+ name = "owner-id"
6
+ values = ["679593333241"]
7
+ }
8
+
9
+ filter {
10
+ name = "name"
11
+ values = ["CentOS Linux 7*"]
12
+ }
13
+
14
+ filter {
15
+ name = "architecture"
16
+ values = ["x86_64"]
17
+ }
18
+
19
+ filter {
20
+ name = "virtualization-type"
21
+ values = ["hvm"]
22
+ }
23
+
24
+ filter {
25
+ name = "block-device-mapping.volume-type"
26
+ values = ["standard"]
27
+ }
28
+
29
+ filter {
30
+ name = "image-type"
31
+ values = ["machine"]
32
+ }
33
+ }
34
+
35
+ resource "aws_instance" "mixlib_install_sh" {
36
+ count = 1
37
+
38
+ ami = "${data.aws_ami.centos_7_ami.id}"
39
+ instance_type = "${var.aws_instance_type}"
40
+ key_name = "es-infrastructure"
41
+
42
+ associate_public_ip_address = true
43
+
44
+ subnet_id = "subnet-11ac0174" # Planet Releng Public Subnet
45
+ source_dest_check = false
46
+
47
+ vpc_security_group_ids = [
48
+ "sg-96274af3",
49
+ ]
50
+
51
+ connection {
52
+ user = "centos"
53
+ private_key = "${file("${var.connection_private_key}")}"
54
+ agent = "${var.connection_agent}"
55
+ timeout = "10m"
56
+ }
57
+
58
+ tags {
59
+ # ChefOps's AWS standard tags:
60
+ X-Dept = "EngServ"
61
+ X-Contact = "pwright"
62
+ X-Production = "false"
63
+ X-Environment = "acceptance"
64
+ X-Application = "mixlib-install"
65
+ }
66
+
67
+ provisioner "file" {
68
+ source = "../../.acceptance_data/centos_install_url.sh"
69
+ destination = "/tmp/install.sh"
70
+ }
71
+
72
+ provisioner "file" {
73
+ source = "../../.acceptance_data/centos_install_checksum.sh"
74
+ destination = "/tmp/install_checksum.sh"
75
+ }
76
+
77
+ provisioner "file" {
78
+ source = "../../.acceptance_data/centos_install_metadata.sh"
79
+ destination = "/tmp/install_metadata.sh"
80
+ }
81
+
82
+ provisioner "file" {
83
+ source = "../../.acceptance_data/centos_install_bad.sh"
84
+ destination = "/tmp/install_bad.sh"
85
+ }
86
+
87
+ provisioner "remote-exec" {
88
+ inline = [
89
+ "chmod +x /tmp/install.sh",
90
+ "chmod +x /tmp/install_checksum.sh",
91
+ "chmod +x /tmp/install_metadata.sh",
92
+ "chmod +x /tmp/install_bad.sh",
93
+ ]
94
+ }
95
+ }
@@ -0,0 +1,8 @@
1
+ # Restrict operation of terraform to chef-es profile so that
2
+ # we do not create resources in other aws profiles.
3
+ # We assume user has configured standard aws credentials
4
+ # under ~/.aws/credentials or with $AWS_SHARED_CREDENTIALS_FILE
5
+ provider "aws" {
6
+ region = "${var.aws_region}"
7
+ profile = "chef-aws"
8
+ }
@@ -0,0 +1,27 @@
1
+ # Region to create infrastructure in
2
+ variable "aws_region" {
3
+ type = "string"
4
+ default = "us-west-2"
5
+ }
6
+
7
+ variable "aws_instance_type" {
8
+ type = "string"
9
+ default = "t2.micro"
10
+ }
11
+
12
+ # Used to indicidate whether the environment should be treated as "prod"
13
+ # This is mainly used for the `X-Production` AWS tag.
14
+ variable "production" {
15
+ default = "false"
16
+ }
17
+
18
+ # SSH Connection info used for remote provisioning instances
19
+ variable "connection_agent" {
20
+ description = "Set to false to disable using ssh-agent to authenticate"
21
+ default = false
22
+ }
23
+
24
+ variable "connection_private_key" {
25
+ description = "File path to AWS keypair private key to provision with"
26
+ default = "~/.ssh/es-infrastructure.pem"
27
+ }
@@ -0,0 +1,3 @@
1
+ execute "terraform destroy -force" do
2
+ cwd "#{node['chef-acceptance']['suite-dir']}/terraform"
3
+ end
@@ -0,0 +1,22 @@
1
+ # Nothing to see here...
2
+
3
+ install_url = "install -download_url_override https://packages.chef.io/files/stable/chef/13.2.20/windows/2012r2/chef-client-13.2.20-1-x64.msi"
4
+
5
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.install_ps1, '#{install_url}'\" > ../.acceptance_data/powershell_install_url.ps1" do
6
+ cwd node['chef-acceptance']['suite-dir']
7
+ end
8
+
9
+ install_checksum = "#{install_url} -checksum 82772d31ad110b7a584492f3a51358a56f4d706a41920c0d441b87c94b71336c -verbose"
10
+
11
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.install_ps1, '#{install_checksum}'\" > ../.acceptance_data/powershell_install_checksum.ps1" do
12
+ cwd node['chef-acceptance']['suite-dir']
13
+ end
14
+
15
+ execute "terraform plan" do
16
+ cwd "#{node['chef-acceptance']['suite-dir']}/terraform"
17
+ end
18
+
19
+ execute "terraform apply" do
20
+ cwd "#{node['chef-acceptance']['suite-dir']}/terraform"
21
+ end
22
+
@@ -0,0 +1,21 @@
1
+ describe package("Chef Client v13*") do
2
+ it { should be_installed }
3
+ its("version") { should match /13.2.20/ }
4
+ end
5
+
6
+ # redirect verbose output
7
+ describe command("powershell.exe -file /tmp/install_with_checksum.ps1 *>&1") do
8
+ its("stdout") { should match /Found existing installer/ }
9
+ its("stdout") { should match /Checksum verified, using existing installer/ }
10
+ end
11
+
12
+ # corrupt the file
13
+ describe powershell("Out-File -filepath C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\chef-client-13.2.20-1-x64.msi") do
14
+ its("exit_status") { should eq 0 }
15
+ end
16
+
17
+ # redirect verbose output
18
+ describe command("powershell.exe -file /tmp/install_with_checksum.ps1 *>&1") do
19
+ its("stdout") { should match /Found existing installer/ }
20
+ its("stdout") { should match /Checksum mismatch/ }
21
+ end
@@ -0,0 +1,94 @@
1
+ data "aws_ami" "windows_ami" {
2
+ most_recent = true
3
+
4
+ filter {
5
+ name = "owner-alias"
6
+ values = ["amazon"]
7
+ }
8
+
9
+ filter {
10
+ name = "name"
11
+ values = ["Windows_Server-2012-R2*-English-*-Base-*"]
12
+ }
13
+
14
+ filter {
15
+ name = "architecture"
16
+ values = ["x86_64"]
17
+ }
18
+
19
+ filter {
20
+ name = "virtualization-type"
21
+ values = ["hvm"]
22
+ }
23
+
24
+ filter {
25
+ name = "block-device-mapping.volume-type"
26
+ values = ["gp2"]
27
+ }
28
+
29
+ filter {
30
+ name = "image-type"
31
+ values = ["machine"]
32
+ }
33
+ }
34
+
35
+ resource "aws_instance" "mixlib_install_ps1" {
36
+ count = 1
37
+
38
+ ami = "${data.aws_ami.windows_ami.id}"
39
+ instance_type = "${var.aws_instance_type}"
40
+ key_name = "es-infrastructure"
41
+
42
+ associate_public_ip_address = true
43
+
44
+ subnet_id = "subnet-11ac0174" # Planet Releng Public Subnet
45
+ source_dest_check = false
46
+
47
+ vpc_security_group_ids = [
48
+ "sg-96274af3",
49
+ ]
50
+
51
+ connection {
52
+ type = "winrm"
53
+ user = "Administrator"
54
+ password = "${var.admin_password}"
55
+ timeout = "10m"
56
+ }
57
+
58
+ user_data = <<EOF
59
+ <script>
60
+ winrm quickconfig -q & winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"} & winrm set winrm/config @{MaxTimeoutms="1800000"} & winrm set winrm/config/service @{AllowUnencrypted="true"} & winrm set winrm/config/service/auth @{Basic="true"}
61
+ </script>
62
+ <powershell>
63
+ Set-ExecutionPolicy -ExecutionPolicy Bypass
64
+ netsh advfirewall firewall add rule name="WinRM in" protocol=TCP dir=in profile=any localport=5985 remoteip=any localip=any action=allow
65
+ $admin = [adsi]("WinNT://./administrator, user")
66
+ $admin.psbase.invoke("SetPassword", "${var.admin_password}")
67
+ </powershell>
68
+ EOF
69
+
70
+ tags {
71
+ # ChefOps's AWS standard tags:
72
+ X-Dept = "EngServ"
73
+ X-Contact = "pwright"
74
+ X-Production = "false"
75
+ X-Environment = "acceptance"
76
+ X-Application = "mixlib-install"
77
+ }
78
+
79
+ provisioner "file" {
80
+ source = "../../.acceptance_data/powershell_install_url.ps1"
81
+ destination = "/tmp/install.ps1"
82
+ }
83
+
84
+ provisioner "file" {
85
+ source = "../../.acceptance_data/powershell_install_checksum.ps1"
86
+ destination = "/tmp/install_with_checksum.ps1"
87
+ }
88
+
89
+ provisioner "remote-exec" {
90
+ inline = [
91
+ "powershell.exe -file /tmp/install.ps1",
92
+ ]
93
+ }
94
+ }
@@ -0,0 +1,8 @@
1
+ # Restrict operation of terraform to chef-es profile so that
2
+ # we do not create resources in other aws profiles.
3
+ # We assume user has configured standard aws credentials
4
+ # under ~/.aws/credentials or with $AWS_SHARED_CREDENTIALS_FILE
5
+ provider "aws" {
6
+ region = "${var.aws_region}"
7
+ profile = "chef-aws"
8
+ }
@@ -0,0 +1,3 @@
1
+ execute "terraform destroy -force" do
2
+ cwd "#{node['chef-acceptance']['suite-dir']}/terraform"
3
+ end
@@ -0,0 +1,14 @@
1
+ ruby_block "get ip" do
2
+ block do
3
+ tf_state = JSON.parse(File.read("#{node['chef-acceptance']['suite-dir']}/terraform/terraform.tfstate"))
4
+ node.default["ip"] = tf_state["modules"].first["resources"]["aws_instance.mixlib_install_ps1"]["primary"]["attributes"]["public_ip"]
5
+ end
6
+ end
7
+
8
+ execute "run inspec" do
9
+ command lazy { "inspec exec verify.rb -t winrm://Administrator@#{node['ip']} --password $WINDOWS_PASSWORD" }
10
+ cwd "#{node['chef-acceptance']['suite-dir']}/inspec"
11
+ environment(
12
+ "WINDOWS_PASSWORD" => ENV["TF_VAR_admin_password"] || "Pas5w0rD"
13
+ )
14
+ end
@@ -0,0 +1,8 @@
1
+ # Restrict operation of terraform to chef-es profile so that
2
+ # we do not create resources in other aws profiles.
3
+ # We assume user has configured standard aws credentials
4
+ # under ~/.aws/credentials or with $AWS_SHARED_CREDENTIALS_FILE
5
+ provider "aws" {
6
+ region = "${var.aws_region}"
7
+ profile = "chef-aws"
8
+ }
@@ -0,0 +1,16 @@
1
+ # Region to create infrastructure in
2
+ variable "aws_region" {
3
+ type = "string"
4
+ default = "us-west-2"
5
+ }
6
+
7
+ variable "aws_instance_type" {
8
+ type = "string"
9
+ default = "t2.micro"
10
+ }
11
+
12
+ variable "admin_password" {
13
+ description = "Set Windows Administrator password"
14
+ type = "string"
15
+ default = "Pas5w0rD"
16
+ }
@@ -43,7 +43,8 @@ if test "x$download_url_override" = "x"; then
43
43
  sha256=`awk '$1 == "sha256" { print $2 }' "$metadata_filename"`
44
44
  else
45
45
  download_url=$download_url_override
46
- sha256=$checksum
46
+ # Set sha256 to empty string if checksum not set
47
+ sha256=${checksum=""}
47
48
  fi
48
49
 
49
50
  ############
@@ -31,20 +31,54 @@ download_dir=`dirname $download_filename`
31
31
  (umask 077 && mkdir -p $download_dir) || exit 1
32
32
 
33
33
  # check if we have that file locally available and if so verify the checksum
34
+ # Use cases
35
+ # 1) metadata - new download
36
+ # 2) metadata - cached download when cmdline_dl_dir set
37
+ # 3) url override - no checksum new download
38
+ # 4) url override - with checksum new download
39
+ # 5) url override - with checksum cached download when cmdline_dl_dir set
40
+
34
41
  cached_file_available="false"
42
+ verify_checksum="true"
43
+
35
44
  if test -f $download_filename; then
36
- echo "$download_filename already exists, verifiying checksum..."
37
- if do_checksum "$download_filename" "$sha256"; then
38
- echo "checksum compare succeeded, using existing file!"
39
- cached_file_available="true"
45
+ echo "$download_filename exists"
46
+ cached_file_available="true"
47
+ fi
48
+
49
+ if test "x$download_url_override" != "x"; then
50
+ echo "Download URL override specified"
51
+ if test "x$cached_file_available" = "xtrue"; then
52
+ echo "Verifying local file"
53
+ if test "x$sha256" = "x"; then
54
+ echo "Checksum not specified, ignoring existing file"
55
+ cached_file_available="false" # download new file
56
+ verify_checksum="false" # no checksum to compare after download
57
+ elif do_checksum "$download_filename" "$sha256"; then
58
+ echo "Checksum match, using existing file"
59
+ cached_file_available="true" # don't need to download file
60
+ verify_checksum="false" # don't need to checksum again
61
+ else
62
+ echo "Checksum mismatch, ignoring existing file"
63
+ cached_file_available="false" # download new file
64
+ verify_checksum="true" # checksum new downloaded file
65
+ fi
40
66
  else
41
- echo "checksum mismatch, downloading latest version of the file"
67
+ echo "$download_filename not found"
68
+ cached_file_available="false" # download new file
69
+ if test "x$sha256" = "x"; then
70
+ verify_checksum="false" # no checksum to compare after download
71
+ else
72
+ verify_checksum="true" # checksum new downloaded file
73
+ fi
42
74
  fi
43
75
  fi
44
76
 
45
- # download if no local version of the file available
46
77
  if test "x$cached_file_available" != "xtrue"; then
47
- do_download "$download_url" "$download_filename"
78
+ do_download "$download_url" "$download_filename"
79
+ fi
80
+
81
+ if test "x$verify_checksum" = "xtrue"; then
48
82
  do_checksum "$download_filename" "$sha256" || checksum_mismatch
49
83
  fi
50
84
 
@@ -10,13 +10,15 @@
10
10
  # $cmdline_filename: Name of the package downloaded on local disk.
11
11
  # $cmdline_dl_dir: Name of the directory downloaded package will be saved to on local disk.
12
12
  # $install_strategy: Method of package installations. default strategy is to always install upon exec. Set to "once" to skip if project is installed
13
+ # $download_url_override: Install package downloaded from a direct URL.
14
+ # $checksum: SHA256 for download_url_override file (optional)
13
15
  ############
14
16
 
15
17
  # Defaults
16
18
  channel="stable"
17
19
  project="chef"
18
20
 
19
- while getopts pnv:c:f:P:d:s opt
21
+ while getopts pnv:c:f:P:d:s:l:a opt
20
22
  do
21
23
  case "$opt" in
22
24
 
@@ -28,9 +30,11 @@ do
28
30
  P) project="$OPTARG";;
29
31
  d) cmdline_dl_dir="$OPTARG";;
30
32
  s) install_strategy="$OPTARG";;
33
+ l) download_url_override="$OPTARG";;
34
+ a) checksum="$OPTARG";;
31
35
  \?) # unknown flag
32
36
  echo >&2 \
33
- "usage: $0 [-P project] [-c release_channel] [-v version] [-f filename | -d download_dir] [-s install_strategy]"
37
+ "usage: $0 [-P project] [-c release_channel] [-v version] [-f filename | -d download_dir] [-s install_strategy] [-l download_url_override] [-a checksum]"
34
38
  exit 1;;
35
39
  esac
36
40
  done
@@ -48,11 +48,10 @@ function Install-Project {
48
48
  $daemon = 'auto',
49
49
  [string]
50
50
  $http_proxy,
51
- # Specify an alternate download url, must also include checksum
51
+ # Specify an alternate download url
52
52
  [string]
53
53
  $download_url_override,
54
- # SHA256 checksum of the download file
55
- # Must be present when using download_url_override
54
+ # SHA256 checksum to verify cached files (optional)
56
55
  [string]
57
56
  $checksum,
58
57
  # Set to 'once' to skip install if project is detected
@@ -71,6 +70,9 @@ function Install-Project {
71
70
  if(-not [string]::IsNullOrEmpty($http_proxy)) {
72
71
  $env:http_proxy = $http_proxy
73
72
  }
73
+
74
+ $cached_installer_available = $false
75
+ $verify_checksum = $true
74
76
 
75
77
  if (-not [string]::IsNullOrEmpty($download_url_override)) {
76
78
  $download_url = $download_url_override
@@ -97,41 +99,60 @@ function Install-Project {
97
99
  if (-not (test-path $download_directory)) {
98
100
  mkdir $download_directory
99
101
  }
102
+
100
103
  $download_directory = (resolve-path $download_directory).providerpath
101
104
  $download_destination = join-path $download_directory $filename
102
105
 
103
- if ((test-path $download_destination) -and
104
- (Test-ProjectPackage -Path $download_destination -Algorithm 'SHA256' -Hash $sha256 -ea SilentlyContinue)){
105
- Write-Verbose "Found existing valid installer at $download_destination."
106
+ if ((test-path $download_destination)) {
107
+ Write-Verbose "Found existing installer at $download_destination."
108
+ if (-not [string]::IsNullOrEmpty($sha256)) {
109
+ Write-Verbose "Checksum specified"
110
+ $valid_checksum = Test-ProjectPackage -Path $download_destination -Algorithm 'SHA256' -Hash $sha256
111
+ if ($valid_checksum -eq $true) {
112
+ Write-Verbose "Checksum verified, using existing installer."
113
+ $cached_installer_available=$true # local file OK
114
+ $verify_checksum = $false # no need to re-verify checksums
115
+ }
116
+ else {
117
+ Write-Verbose "Checksum mismatch, ignoring existing installer."
118
+ $cached_installer_available=$false # bad local file
119
+ $verify_checksum = $false # re-verify checksums
120
+ }
121
+ }
122
+ else {
123
+ Write-Verbose "Checksum not specified, existing installer ignored."
124
+ $cached_installer_available=$false # ignore local file
125
+ $verify_checksum = $false # no checksum to compare
126
+ }
106
127
  }
107
- else {
128
+
129
+ if (-not ($cached_installer_available)) {
108
130
  if ($pscmdlet.ShouldProcess("$($download_url)", "Download $project")) {
109
131
  Write-Verbose "Downloading $project from $($download_url) to $download_destination."
110
132
  Get-WebContent $download_url -filepath $download_destination
111
133
  }
112
134
  }
113
135
 
114
- if ($pscmdlet.ShouldProcess("$download_destination", "Installing")){
115
- if (Test-ProjectPackage -Path $download_destination -Algorithm 'SHA256' -Hash $sha256) {
116
- Write-Host "Installing $project from $download_destination"
117
- $installingProject = $True
118
- $installAttempts = 0
119
- while ($installingProject) {
120
- $installAttempts++
121
- $result = $false
122
- if($download_destination.EndsWith(".appx")) {
123
- $result = Install-ChefAppx $download_destination $project
124
- }
125
- else {
126
- $result = Install-ChefMsi $download_destination $daemon
127
- }
128
- if(!$result) { continue }
129
- $installingProject = $False
130
- }
131
- }
132
- else {
136
+ if ($pscmdlet.ShouldProcess("$download_destination", "Installing")) {
137
+ if (($verify_checksum) -and (-not (Test-ProjectPackage -Path $download_destination -Algorithm 'SHA256' -Hash $sha256))) {
133
138
  throw "Failed to validate the downloaded installer for $project."
134
139
  }
140
+
141
+ Write-Host "Installing $project from $download_destination"
142
+ $installingProject = $True
143
+ $installAttempts = 0
144
+ while ($installingProject) {
145
+ $installAttempts++
146
+ $result = $false
147
+ if($download_destination.EndsWith(".appx")) {
148
+ $result = Install-ChefAppx $download_destination $project
149
+ }
150
+ else {
151
+ $result = Install-ChefMsi $download_destination $daemon
152
+ }
153
+ if(!$result) { continue }
154
+ $installingProject = $False
155
+ }
135
156
  }
136
157
  }
137
158
  set-alias install -value Install-Project
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class Install
3
- VERSION = "3.4.0"
3
+ VERSION = "3.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-install
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-22 00:00:00.000000000 Z
12
+ date: 2017-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mixlib-shellout
@@ -79,8 +79,37 @@ files:
79
79
  - Rakefile
80
80
  - VERSION
81
81
  - acceptance/.gitignore
82
+ - acceptance/.suites/ubuntu_install_checksum/.acceptance/acceptance-cookbook/.gitignore
83
+ - acceptance/.suites/ubuntu_install_checksum/.acceptance/acceptance-cookbook/metadata.rb
84
+ - acceptance/.suites/ubuntu_install_checksum/.acceptance/acceptance-cookbook/recipes/destroy.rb
85
+ - acceptance/.suites/ubuntu_install_checksum/.acceptance/acceptance-cookbook/recipes/provision.rb
86
+ - acceptance/.suites/ubuntu_install_checksum/.acceptance/acceptance-cookbook/recipes/verify.rb
87
+ - acceptance/.suites/ubuntu_install_checksum/inspec/verify.rb
88
+ - acceptance/.suites/ubuntu_install_checksum/terraform/application.tf
89
+ - acceptance/.suites/ubuntu_install_checksum/terraform/aws.tf
90
+ - acceptance/.suites/ubuntu_install_checksum/terraform/terraform.tfstate
91
+ - acceptance/.suites/ubuntu_install_checksum/terraform/variables.tf
92
+ - acceptance/.suites/windows-nano/.acceptance/acceptance-cookbook/.gitignore
93
+ - acceptance/.suites/windows-nano/.acceptance/acceptance-cookbook/libraries/chef_extentions.rb
94
+ - acceptance/.suites/windows-nano/.acceptance/acceptance-cookbook/metadata.rb
95
+ - acceptance/.suites/windows-nano/.acceptance/acceptance-cookbook/recipes/destroy.rb
96
+ - acceptance/.suites/windows-nano/.acceptance/acceptance-cookbook/recipes/provision.rb
97
+ - acceptance/.suites/windows-nano/.acceptance/acceptance-cookbook/recipes/verify.rb
98
+ - acceptance/.suites/windows-nano/inspec/verify.rb
99
+ - acceptance/.suites/windows-nano/terraform/application.tf
100
+ - acceptance/.suites/windows-nano/terraform/aws.tf
101
+ - acceptance/.suites/windows-nano/terraform/variables.tf
82
102
  - acceptance/Gemfile
83
103
  - acceptance/README.md
104
+ - acceptance/centos_install_checksum/.acceptance/acceptance-cookbook/.gitignore
105
+ - acceptance/centos_install_checksum/.acceptance/acceptance-cookbook/metadata.rb
106
+ - acceptance/centos_install_checksum/.acceptance/acceptance-cookbook/recipes/destroy.rb
107
+ - acceptance/centos_install_checksum/.acceptance/acceptance-cookbook/recipes/provision.rb
108
+ - acceptance/centos_install_checksum/.acceptance/acceptance-cookbook/recipes/verify.rb
109
+ - acceptance/centos_install_checksum/inspec/verify.rb
110
+ - acceptance/centos_install_checksum/terraform/application.tf
111
+ - acceptance/centos_install_checksum/terraform/aws.tf
112
+ - acceptance/centos_install_checksum/terraform/variables.tf
84
113
  - acceptance/ubuntu_install_command/.acceptance/acceptance-cookbook/.gitignore
85
114
  - acceptance/ubuntu_install_command/.acceptance/acceptance-cookbook/metadata.rb
86
115
  - acceptance/ubuntu_install_command/.acceptance/acceptance-cookbook/recipes/destroy.rb
@@ -108,16 +137,15 @@ files:
108
137
  - acceptance/ubuntu_install_sh/terraform/application.tf
109
138
  - acceptance/ubuntu_install_sh/terraform/aws.tf
110
139
  - acceptance/ubuntu_install_sh/terraform/variables.tf
111
- - acceptance/windows-nano/.acceptance/acceptance-cookbook/.gitignore
112
- - acceptance/windows-nano/.acceptance/acceptance-cookbook/libraries/chef_extentions.rb
113
- - acceptance/windows-nano/.acceptance/acceptance-cookbook/metadata.rb
114
- - acceptance/windows-nano/.acceptance/acceptance-cookbook/recipes/destroy.rb
115
- - acceptance/windows-nano/.acceptance/acceptance-cookbook/recipes/provision.rb
116
- - acceptance/windows-nano/.acceptance/acceptance-cookbook/recipes/verify.rb
117
- - acceptance/windows-nano/inspec/verify.rb
118
- - acceptance/windows-nano/terraform/application.tf
119
- - acceptance/windows-nano/terraform/aws.tf
120
- - acceptance/windows-nano/terraform/variables.tf
140
+ - acceptance/windows-server-2012r2-checksum/.acceptance/acceptance-cookbook/.gitignore
141
+ - acceptance/windows-server-2012r2-checksum/.acceptance/acceptance-cookbook/metadata.rb
142
+ - acceptance/windows-server-2012r2-checksum/.acceptance/acceptance-cookbook/recipes/destroy.rb
143
+ - acceptance/windows-server-2012r2-checksum/.acceptance/acceptance-cookbook/recipes/provision.rb
144
+ - acceptance/windows-server-2012r2-checksum/.acceptance/acceptance-cookbook/recipes/verify.rb
145
+ - acceptance/windows-server-2012r2-checksum/inspec/verify.rb
146
+ - acceptance/windows-server-2012r2-checksum/terraform/application.tf
147
+ - acceptance/windows-server-2012r2-checksum/terraform/aws.tf
148
+ - acceptance/windows-server-2012r2-checksum/terraform/variables.tf
121
149
  - acceptance/windows-server-2012r2-fips/.acceptance/acceptance-cookbook/.gitignore
122
150
  - acceptance/windows-server-2012r2-fips/.acceptance/acceptance-cookbook/metadata.rb
123
151
  - acceptance/windows-server-2012r2-fips/.acceptance/acceptance-cookbook/recipes/destroy.rb
@@ -136,15 +164,15 @@ files:
136
164
  - acceptance/windows-server-2012r2-once/terraform/application.tf
137
165
  - acceptance/windows-server-2012r2-once/terraform/aws.tf
138
166
  - acceptance/windows-server-2012r2-once/terraform/variables.tf
139
- - acceptance/windows-server-2012r2/.acceptance/acceptance-cookbook/.gitignore
140
- - acceptance/windows-server-2012r2/.acceptance/acceptance-cookbook/metadata.rb
141
- - acceptance/windows-server-2012r2/.acceptance/acceptance-cookbook/recipes/destroy.rb
142
- - acceptance/windows-server-2012r2/.acceptance/acceptance-cookbook/recipes/provision.rb
143
- - acceptance/windows-server-2012r2/.acceptance/acceptance-cookbook/recipes/verify.rb
144
- - acceptance/windows-server-2012r2/inspec/verify.rb
145
- - acceptance/windows-server-2012r2/terraform/application.tf
146
- - acceptance/windows-server-2012r2/terraform/aws.tf
147
- - acceptance/windows-server-2012r2/terraform/variables.tf
167
+ - acceptance/windows-server-2012r2-ps1/.acceptance/acceptance-cookbook/.gitignore
168
+ - acceptance/windows-server-2012r2-ps1/.acceptance/acceptance-cookbook/metadata.rb
169
+ - acceptance/windows-server-2012r2-ps1/.acceptance/acceptance-cookbook/recipes/destroy.rb
170
+ - acceptance/windows-server-2012r2-ps1/.acceptance/acceptance-cookbook/recipes/provision.rb
171
+ - acceptance/windows-server-2012r2-ps1/.acceptance/acceptance-cookbook/recipes/verify.rb
172
+ - acceptance/windows-server-2012r2-ps1/inspec/verify.rb
173
+ - acceptance/windows-server-2012r2-ps1/terraform/application.tf
174
+ - acceptance/windows-server-2012r2-ps1/terraform/aws.tf
175
+ - acceptance/windows-server-2012r2-ps1/terraform/variables.tf
148
176
  - bin/mixlib-install
149
177
  - ci/before-script.sh
150
178
  - ci/es-infrastructure.pem.enc