wombat-cli 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +23 -23
- data/.travis.yml +22 -27
- data/CHANGELOG.md +438 -423
- data/DESIGN.md +49 -49
- data/Gemfile +5 -5
- data/README.md +146 -146
- data/Rakefile +26 -26
- data/bin/wombat +24 -24
- data/generator_files/Vagrantfile +120 -120
- data/generator_files/cookbooks/automate/.gitignore +16 -16
- data/generator_files/cookbooks/automate/.kitchen.ec2.yml +34 -34
- data/generator_files/cookbooks/automate/.kitchen.yml +24 -24
- data/generator_files/cookbooks/automate/Berksfile +6 -6
- data/generator_files/cookbooks/automate/README.md +4 -4
- data/generator_files/cookbooks/automate/chefignore +102 -102
- data/generator_files/cookbooks/automate/libraries/_helper.rb +52 -52
- data/generator_files/cookbooks/automate/libraries/delivery_api.rb +204 -204
- data/generator_files/cookbooks/automate/libraries/delivery_project.rb +31 -31
- data/generator_files/cookbooks/automate/libraries/dsl.rb +4 -4
- data/generator_files/cookbooks/automate/metadata.rb +11 -11
- data/generator_files/cookbooks/automate/recipes/default.rb +118 -124
- data/generator_files/cookbooks/automate/recipes/update-users.rb +48 -48
- data/generator_files/cookbooks/automate/templates/delivery.erb +6 -6
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/chef.crt +25 -25
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/metadata.rb +3 -3
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/recipes/default.rb +27 -27
- data/generator_files/cookbooks/automate/test/integration/default/automate_spec.rb +56 -56
- data/generator_files/cookbooks/build_node/.gitignore +16 -16
- data/generator_files/cookbooks/build_node/.kitchen.ec2.yml +37 -37
- data/generator_files/cookbooks/build_node/.kitchen.yml +23 -23
- data/generator_files/cookbooks/build_node/Berksfile +8 -8
- data/generator_files/cookbooks/build_node/README.md +4 -4
- data/generator_files/cookbooks/build_node/chefignore +102 -102
- data/generator_files/cookbooks/build_node/metadata.rb +12 -12
- data/generator_files/cookbooks/build_node/recipes/default.rb +38 -38
- data/generator_files/cookbooks/build_node/templates/client.erb +2 -2
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/chef.crt +25 -25
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/metadata.rb +2 -2
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/recipes/default.rb +18 -18
- data/generator_files/cookbooks/build_node/test/integration/default/build-node_spec.rb +40 -40
- data/generator_files/cookbooks/chef_server/.gitignore +16 -16
- data/generator_files/cookbooks/chef_server/.kitchen.ec2.yml +34 -34
- data/generator_files/cookbooks/chef_server/.kitchen.yml +24 -24
- data/generator_files/cookbooks/chef_server/Berksfile +6 -6
- data/generator_files/cookbooks/chef_server/README.md +4 -4
- data/generator_files/cookbooks/chef_server/chefignore +102 -102
- data/generator_files/cookbooks/chef_server/metadata.rb +11 -11
- data/generator_files/cookbooks/chef_server/recipes/bootstrap_users.rb +91 -91
- data/generator_files/cookbooks/chef_server/recipes/default.rb +113 -113
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/chef.crt +25 -25
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/metadata.rb +2 -2
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/recipes/default.rb +23 -23
- data/generator_files/cookbooks/chef_server/test/integration/default/chef_server_spec.rb +50 -50
- data/generator_files/cookbooks/compliance/.gitignore +16 -16
- data/generator_files/cookbooks/compliance/.kitchen.ec2.yml +34 -34
- data/generator_files/cookbooks/compliance/.kitchen.yml +24 -24
- data/generator_files/cookbooks/compliance/Berksfile +7 -7
- data/generator_files/cookbooks/compliance/README.md +4 -4
- data/generator_files/cookbooks/compliance/chefignore +102 -102
- data/generator_files/cookbooks/compliance/metadata.rb +11 -11
- data/generator_files/cookbooks/compliance/recipes/default.rb +57 -57
- data/generator_files/cookbooks/compliance/spec/spec_helper.rb +2 -2
- data/generator_files/cookbooks/compliance/spec/unit/recipes/default_spec.rb +20 -20
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/chef.crt +25 -25
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/metadata.rb +4 -4
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/recipes/default.rb +21 -21
- data/generator_files/cookbooks/compliance/test/integration/default/compliance.rb +28 -28
- data/generator_files/cookbooks/infranodes/.gitignore +16 -16
- data/generator_files/cookbooks/infranodes/.kitchen.ec2.yml +48 -48
- data/generator_files/cookbooks/infranodes/.kitchen.yml +21 -21
- data/generator_files/cookbooks/infranodes/Berksfile +6 -6
- data/generator_files/cookbooks/infranodes/README.md +4 -4
- data/generator_files/cookbooks/infranodes/attributes/default.rb +2 -2
- data/generator_files/cookbooks/infranodes/chefignore +102 -102
- data/generator_files/cookbooks/infranodes/metadata.rb +13 -13
- data/generator_files/cookbooks/infranodes/recipes/default.rb +57 -57
- data/generator_files/cookbooks/infranodes/spec/spec_helper.rb +2 -2
- data/generator_files/cookbooks/infranodes/spec/unit/recipes/default_spec.rb +20 -20
- data/generator_files/cookbooks/infranodes/templates/default/client.rb.erb +5 -5
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/chef.crt +25 -25
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/metadata.rb +3 -3
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/recipes/default.rb +27 -27
- data/generator_files/cookbooks/infranodes/test/integration/default/infranodes_spec.rb +22 -22
- data/generator_files/cookbooks/infranodes/test/integration/helpers/serverspec/spec_helper.rb +8 -8
- data/generator_files/cookbooks/wombat/.gitignore +16 -16
- data/generator_files/cookbooks/wombat/.kitchen.yml +43 -43
- data/generator_files/cookbooks/wombat/Berksfile +5 -5
- data/generator_files/cookbooks/wombat/README.md +4 -4
- data/generator_files/cookbooks/wombat/attributes/default.rb +79 -80
- data/generator_files/cookbooks/wombat/attributes/packer.rb +18 -18
- data/generator_files/cookbooks/wombat/chefignore +102 -102
- data/generator_files/cookbooks/wombat/metadata.rb +13 -13
- data/generator_files/cookbooks/wombat/recipes/authorized-keys.rb +20 -20
- data/generator_files/cookbooks/wombat/recipes/default.rb +111 -111
- data/generator_files/cookbooks/wombat/recipes/etc-hosts.rb +51 -51
- data/generator_files/cookbooks/workstation/.gitignore +16 -16
- data/generator_files/cookbooks/workstation/.kitchen.azure.yml +45 -0
- data/generator_files/cookbooks/workstation/.kitchen.ec2.yml +46 -30
- data/generator_files/cookbooks/workstation/.kitchen.yml +42 -22
- data/generator_files/cookbooks/workstation/Berksfile +7 -7
- data/generator_files/cookbooks/workstation/README.md +3 -3
- data/generator_files/cookbooks/workstation/chefignore +106 -102
- data/generator_files/cookbooks/workstation/files/atom.apm.list +10 -7
- data/generator_files/cookbooks/workstation/files/atom.config.cson +6 -3
- data/generator_files/cookbooks/workstation/{templates/default/ise_profile.ps1.erb → files/ise_profile.ps1} +11 -11
- data/generator_files/cookbooks/workstation/libraries/home.rb +4 -4
- data/generator_files/cookbooks/workstation/metadata.rb +14 -14
- data/generator_files/cookbooks/workstation/recipes/browser.rb +53 -58
- data/generator_files/cookbooks/workstation/recipes/certs-keys.rb +41 -45
- data/generator_files/cookbooks/workstation/recipes/chef.rb +29 -28
- data/generator_files/cookbooks/workstation/recipes/default.rb +24 -21
- data/generator_files/cookbooks/workstation/recipes/dotnet.rb +19 -17
- data/generator_files/cookbooks/workstation/recipes/editor.rb +46 -18
- data/generator_files/cookbooks/workstation/recipes/profile.rb +14 -41
- data/generator_files/cookbooks/workstation/recipes/terminal.rb +11 -11
- data/generator_files/cookbooks/workstation/templates/default/bookmarks.html.erb +23 -23
- data/generator_files/cookbooks/workstation/templates/default/data_collector.rb.erb +2 -2
- data/generator_files/cookbooks/workstation/templates/default/knife.rb.erb +10 -10
- data/generator_files/cookbooks/workstation/templates/default/master_preferences.json.erb +28 -28
- data/generator_files/cookbooks/workstation/templates/default/ssh_config.erb +16 -16
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/chef.crt +26 -26
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/metadata.rb +2 -2
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/recipes/default.rb +21 -21
- data/generator_files/cookbooks/workstation/test/integration/default/workstation_spec.rb +77 -37
- data/generator_files/packer/automate.json +136 -136
- data/generator_files/packer/build-node.json +142 -142
- data/generator_files/packer/chef-server.json +137 -137
- data/generator_files/packer/compliance.json +133 -133
- data/generator_files/packer/infranodes-windows.json +143 -143
- data/generator_files/packer/infranodes.json +134 -134
- data/generator_files/packer/scripts/PreSysprep.ps1 +9 -0
- data/generator_files/packer/workstation.json +160 -142
- data/generator_files/templates/arm.md.json.erb +754 -754
- data/generator_files/templates/arm.vhd.json.erb +630 -630
- data/generator_files/templates/bootstrap-aws.erb +39 -39
- data/generator_files/templates/cfn.json.erb +675 -674
- data/generator_files/wombat.yml +75 -74
- data/lib/wombat/aws.rb +67 -67
- data/lib/wombat/build.rb +392 -392
- data/lib/wombat/cli.rb +254 -254
- data/lib/wombat/common.rb +420 -420
- data/lib/wombat/crypto.rb +65 -65
- data/lib/wombat/delete.rb +67 -67
- data/lib/wombat/deploy.rb +128 -128
- data/lib/wombat/init.rb +32 -32
- data/lib/wombat/latest.rb +27 -27
- data/lib/wombat/output.rb +101 -101
- data/lib/wombat/update.rb +20 -20
- data/lib/wombat/version.rb +3 -3
- data/lib/wombat.rb +8 -8
- data/spec/functional/common_spec.rb +26 -26
- data/spec/spec_helper.rb +103 -103
- data/spec/unit/common_spec.rb +116 -116
- data/terraform/README.md +13 -13
- data/terraform/templates/terraform.tfvars.erb +12 -12
- data/terraform/wombat.tf +328 -328
- data/wombat-cli.gemspec +36 -36
- metadata +6 -4
data/generator_files/wombat.yml
CHANGED
@@ -1,74 +1,75 @@
|
|
1
|
-
---
|
2
|
-
name: wombat
|
3
|
-
# Uncomment domain_prefix if you wish to prepend your generated domain.
|
4
|
-
# Ex: The below example would create foo-chef.animals.biz.
|
5
|
-
# domain_prefix: foo-
|
6
|
-
domain: animals.biz
|
7
|
-
enterprise: mammals
|
8
|
-
org: marsupials
|
9
|
-
certs: ['automate', 'chef', 'compliance']
|
10
|
-
ttl: 6
|
11
|
-
linux: ubuntu
|
12
|
-
version: 0.
|
13
|
-
owner:
|
14
|
-
products:
|
15
|
-
chef: stable-latest
|
16
|
-
chef-server: stable-latest
|
17
|
-
chefdk: stable-latest
|
18
|
-
compliance: stable-latest
|
19
|
-
automate: stable-latest
|
20
|
-
push-jobs-server: stable-latest
|
21
|
-
manage: stable-latest
|
22
|
-
build-nodes:
|
23
|
-
count: 1
|
24
|
-
workstations:
|
25
|
-
platform: windows
|
26
|
-
# Must meet the minimum Microsoft Complexity Requirements
|
27
|
-
# https://technet.microsoft.com/en-us/library/hh994562(v=ws.11).aspx)
|
28
|
-
password: 'ZL9@T40BTmXhZ'
|
29
|
-
count: 1
|
30
|
-
infranodes:
|
31
|
-
# Add a list of infrastructure nodes here with their associated run list to have these nodes precreated on the Chef Server
|
32
|
-
# Note: the cookbook content won't be automatically uploaded, only the node object will be created with the run list added,
|
33
|
-
# if the content doesn't exist at the first checkin the chef-client run will fail.
|
34
|
-
# acceptance:
|
35
|
-
# platform: windows
|
36
|
-
# environment: web-acceptance
|
37
|
-
# run_list:
|
38
|
-
# - recipe[bacon::chewy]
|
39
|
-
# delivered:
|
40
|
-
# environment: web-delivered
|
41
|
-
# run_list:
|
42
|
-
# - recipe[bacon::crispy]
|
43
|
-
conf:
|
44
|
-
key_dir: 'keys'
|
45
|
-
cookbook_dir: 'cookbooks'
|
46
|
-
packer_dir: 'packer'
|
47
|
-
template_dir: 'templates'
|
48
|
-
log_dir: 'logs'
|
49
|
-
stack_dir: 'stacks'
|
50
|
-
audio: false
|
51
|
-
aws:
|
52
|
-
az: us-east-1e
|
53
|
-
keypair: keypair-us-east
|
54
|
-
region: us-east-1
|
55
|
-
# This optional key presumes these IAM roles are already created
|
56
|
-
# and are only applied to workstations currently
|
57
|
-
# iam_roles: ['iam_role', 'iam_roles_buddy']
|
58
|
-
source_image:
|
59
|
-
ubuntu: ami-
|
60
|
-
windows: ami-
|
61
|
-
centos: ami-6d1c2007
|
62
|
-
azure:
|
63
|
-
location: eastus
|
64
|
-
storage_account:
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
1
|
+
---
|
2
|
+
name: wombat
|
3
|
+
# Uncomment domain_prefix if you wish to prepend your generated domain.
|
4
|
+
# Ex: The below example would create foo-chef.animals.biz.
|
5
|
+
# domain_prefix: foo-
|
6
|
+
domain: animals.biz
|
7
|
+
enterprise: mammals
|
8
|
+
org: marsupials
|
9
|
+
certs: ['automate', 'chef', 'compliance']
|
10
|
+
ttl: 6
|
11
|
+
linux: ubuntu
|
12
|
+
version: 0.3.0
|
13
|
+
owner:
|
14
|
+
products:
|
15
|
+
chef: stable-latest
|
16
|
+
chef-server: stable-latest
|
17
|
+
chefdk: stable-latest
|
18
|
+
compliance: stable-latest
|
19
|
+
automate: stable-latest
|
20
|
+
push-jobs-server: stable-latest
|
21
|
+
manage: stable-latest
|
22
|
+
build-nodes:
|
23
|
+
count: 1
|
24
|
+
workstations:
|
25
|
+
platform: windows
|
26
|
+
# Must meet the minimum Microsoft Complexity Requirements
|
27
|
+
# https://technet.microsoft.com/en-us/library/hh994562(v=ws.11).aspx)
|
28
|
+
password: 'ZL9@T40BTmXhZ'
|
29
|
+
count: 1
|
30
|
+
infranodes:
|
31
|
+
# Add a list of infrastructure nodes here with their associated run list to have these nodes precreated on the Chef Server
|
32
|
+
# Note: the cookbook content won't be automatically uploaded, only the node object will be created with the run list added,
|
33
|
+
# if the content doesn't exist at the first checkin the chef-client run will fail.
|
34
|
+
# acceptance:
|
35
|
+
# platform: windows
|
36
|
+
# environment: web-acceptance
|
37
|
+
# run_list:
|
38
|
+
# - recipe[bacon::chewy]
|
39
|
+
# delivered:
|
40
|
+
# environment: web-delivered
|
41
|
+
# run_list:
|
42
|
+
# - recipe[bacon::crispy]
|
43
|
+
conf:
|
44
|
+
key_dir: 'keys'
|
45
|
+
cookbook_dir: 'cookbooks'
|
46
|
+
packer_dir: 'packer'
|
47
|
+
template_dir: 'templates'
|
48
|
+
log_dir: 'logs'
|
49
|
+
stack_dir: 'stacks'
|
50
|
+
audio: false
|
51
|
+
aws:
|
52
|
+
az: us-east-1e
|
53
|
+
keypair: keypair-us-east
|
54
|
+
region: us-east-1
|
55
|
+
# This optional key presumes these IAM roles are already created
|
56
|
+
# and are only applied to workstations currently
|
57
|
+
# iam_roles: ['iam_role', 'iam_roles_buddy']
|
58
|
+
source_image:
|
59
|
+
ubuntu: ami-70b67d10
|
60
|
+
windows: ami-48b4bf31
|
61
|
+
centos: ami-6d1c2007
|
62
|
+
azure:
|
63
|
+
location: eastus
|
64
|
+
storage_account:
|
65
|
+
use_managed_disks: true
|
66
|
+
source_image:
|
67
|
+
ubuntu: Canonical:UbuntuServer:14.04.5-LTS
|
68
|
+
windows: MicrosoftWindowsServer:WindowsServer:2016-Datacenter
|
69
|
+
gce:
|
70
|
+
zone: us-east1-b
|
71
|
+
project: wombat-gce
|
72
|
+
account_file: wombat-gce.json
|
73
|
+
source_image:
|
74
|
+
ubuntu: ubuntu-1404-trusty-v20160809a
|
75
|
+
windows: windows-server-2012-r2-dc-v20160809
|
data/lib/wombat/aws.rb
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
require "wombat/common"
|
2
|
-
require "aws-sdk"
|
3
|
-
|
4
|
-
# http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#describe_images-instance_method
|
5
|
-
# https://github.com/test-kitchen/kitchen-ec2/blob/aa8e7f2cf9bfbb10fa4057f3297c2a20dc079f7b/lib/kitchen/driver/aws/standard_platform.rb
|
6
|
-
# https://github.com/test-kitchen/kitchen-ec2/blob/aa8e7f2cf9bfbb10fa4057f3297c2a20dc079f7b/lib/kitchen/driver/aws/standard_platform/ubuntu.rb
|
7
|
-
|
8
|
-
module Wombat
|
9
|
-
module Aws
|
10
|
-
include Wombat::Common
|
11
|
-
|
12
|
-
def find_latest_amis
|
13
|
-
client = ::Aws::EC2::Client.new(:region => wombat["aws"]["region"])
|
14
|
-
# static list of images
|
15
|
-
desc_hash = {
|
16
|
-
"ubuntu-16.04" => ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*", "099720109477"],
|
17
|
-
"ubuntu-14.04" => ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*", "099720109477"],
|
18
|
-
"centos-7" => ["CentOS Linux 7 x86_64 HVM EBS*", "679593333241"],
|
19
|
-
"windows-2012r2" => ["Windows_Server-2012-R2_RTM-English-64Bit-Base-*", "801119661308"]
|
20
|
-
}
|
21
|
-
desc_hash.each do |k, v|
|
22
|
-
resp = client.describe_images({
|
23
|
-
dry_run: false,
|
24
|
-
filters: [
|
25
|
-
{
|
26
|
-
name: "name",
|
27
|
-
values: [v[0]],
|
28
|
-
},
|
29
|
-
{
|
30
|
-
name: "owner-id",
|
31
|
-
values: [v[1]],
|
32
|
-
},
|
33
|
-
],
|
34
|
-
})
|
35
|
-
images = sort_images(resp.images)
|
36
|
-
|
37
|
-
puts "#{k}: #{images[:image_id]}"
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def prefer(images, &block)
|
43
|
-
# Put the matching ones *before* the non-matching ones.
|
44
|
-
matching, non_matching = images.partition(&block)
|
45
|
-
matching + non_matching
|
46
|
-
end
|
47
|
-
|
48
|
-
def sort_images(images)
|
49
|
-
# P5: We prefer more recent images over older ones
|
50
|
-
images = images.sort_by(&:creation_date).reverse
|
51
|
-
# P4: We prefer x86_64 over i386 (if available)
|
52
|
-
images = prefer(images) { |image| image.architecture == :x86_64 }
|
53
|
-
# P3: We prefer gp2 (SSD) (if available)
|
54
|
-
images = prefer(images) do |image|
|
55
|
-
image.block_device_mappings.any? do |b|
|
56
|
-
b.device_name == image.root_device_name && b.ebs && b.ebs.volume_type == "gp2"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
# P2: We prefer ebs over instance_store (if available)
|
60
|
-
images = prefer(images) { |image| image.root_device_type == "ebs" }
|
61
|
-
# P1: We prefer hvm (the modern standard)
|
62
|
-
images = prefer(images) { |image| image.virtualization_type == "hvm" }
|
63
|
-
# Grab the image from the top of the stack
|
64
|
-
images.first
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
1
|
+
require "wombat/common"
|
2
|
+
require "aws-sdk"
|
3
|
+
|
4
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#describe_images-instance_method
|
5
|
+
# https://github.com/test-kitchen/kitchen-ec2/blob/aa8e7f2cf9bfbb10fa4057f3297c2a20dc079f7b/lib/kitchen/driver/aws/standard_platform.rb
|
6
|
+
# https://github.com/test-kitchen/kitchen-ec2/blob/aa8e7f2cf9bfbb10fa4057f3297c2a20dc079f7b/lib/kitchen/driver/aws/standard_platform/ubuntu.rb
|
7
|
+
|
8
|
+
module Wombat
|
9
|
+
module Aws
|
10
|
+
include Wombat::Common
|
11
|
+
|
12
|
+
def find_latest_amis
|
13
|
+
client = ::Aws::EC2::Client.new(:region => wombat["aws"]["region"])
|
14
|
+
# static list of images
|
15
|
+
desc_hash = {
|
16
|
+
"ubuntu-16.04" => ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*", "099720109477"],
|
17
|
+
"ubuntu-14.04" => ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*", "099720109477"],
|
18
|
+
"centos-7" => ["CentOS Linux 7 x86_64 HVM EBS*", "679593333241"],
|
19
|
+
"windows-2012r2" => ["Windows_Server-2012-R2_RTM-English-64Bit-Base-*", "801119661308"]
|
20
|
+
}
|
21
|
+
desc_hash.each do |k, v|
|
22
|
+
resp = client.describe_images({
|
23
|
+
dry_run: false,
|
24
|
+
filters: [
|
25
|
+
{
|
26
|
+
name: "name",
|
27
|
+
values: [v[0]],
|
28
|
+
},
|
29
|
+
{
|
30
|
+
name: "owner-id",
|
31
|
+
values: [v[1]],
|
32
|
+
},
|
33
|
+
],
|
34
|
+
})
|
35
|
+
images = sort_images(resp.images)
|
36
|
+
|
37
|
+
puts "#{k}: #{images[:image_id]}"
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def prefer(images, &block)
|
43
|
+
# Put the matching ones *before* the non-matching ones.
|
44
|
+
matching, non_matching = images.partition(&block)
|
45
|
+
matching + non_matching
|
46
|
+
end
|
47
|
+
|
48
|
+
def sort_images(images)
|
49
|
+
# P5: We prefer more recent images over older ones
|
50
|
+
images = images.sort_by(&:creation_date).reverse
|
51
|
+
# P4: We prefer x86_64 over i386 (if available)
|
52
|
+
images = prefer(images) { |image| image.architecture == :x86_64 }
|
53
|
+
# P3: We prefer gp2 (SSD) (if available)
|
54
|
+
images = prefer(images) do |image|
|
55
|
+
image.block_device_mappings.any? do |b|
|
56
|
+
b.device_name == image.root_device_name && b.ebs && b.ebs.volume_type == "gp2"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
# P2: We prefer ebs over instance_store (if available)
|
60
|
+
images = prefer(images) { |image| image.root_device_type == "ebs" }
|
61
|
+
# P1: We prefer hvm (the modern standard)
|
62
|
+
images = prefer(images) { |image| image.virtualization_type == "hvm" }
|
63
|
+
# Grab the image from the top of the stack
|
64
|
+
images.first
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|