Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ suites:
enabled: true
compliance:
enabled: true

- name: gce_compliance
run_list: "marketplace_image::default"
attributes:
Expand All @@ -64,6 +65,36 @@ suites:
compliance:
enabled: true

- name: vmware_compliance
run_list: "marketplace_image::default"
attributes:
marketplace_image:
vmware:
compliance:
enabled: true
- name: vmware_automate
run_list: "marketplace_image::default"
attributes:
vmware:
packer_ssh_password: <%= ENV['PACKER_SSH_PASSWORD'] %>
esx_host: <%= ENV['ESX_HOST'] %>
esx_password: <%= ENV['ESX_PASSWORD'] %>
packman:
version: '1.1.0'
marketplace_image:
vmware:
automate:
enabled: true
- name: vmware_all
run_list: "marketplace_image::default"
attributes:
marketplace_image:
vmware:
automate:
enabled: true
compliance:
enabled: true

- name: aws_public_automate
run_list: "marketplace_image::default"
attributes:
Expand Down Expand Up @@ -131,6 +162,7 @@ suites:
enabled: true
compliance:
enabled: true

- name: all
run_list: "marketplace_image::default"
attributes:
Expand All @@ -156,3 +188,8 @@ suites:
enabled: true
compliance:
enabled: true
vmware:
automate:
enabled: true
compliance:
enabled: true
2 changes: 1 addition & 1 deletion Berksfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
source 'https://supermarket.chef.io'

cookbook 'fancy_execute', git: 'https://github.com/irvingpop/fancy_execute.git'
#cookbook 'fancy_execute', git: 'https://github.com/irvingpop/fancy_execute.git'
cookbook 'packman', git: 'https://github.com/chef-partners/packman.git'

metadata
77 changes: 77 additions & 0 deletions attributes/vmware.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# frozen_string_literal: true
default['marketplace_image']['vmware']['aio']['enabled'] = false
default['marketplace_image']['vmware']['compliance']['enabled'] = false

override['packman']['checksums']['1.1.0'] = 'bd1eddfa114f7e6258ef3419613380297f1b4e438f5bae92f1177150519be934'

cred_dir = ::File.expand_path(::File.join('~', '.vmware'))
account_file = ::File.join(cred_dir, 'account.json')

default['marketplace_image']['vmware']['cred_dir'] = cred_dir
default['marketplace_image']['vmware']['account_file'] = account_file

default_marketplace_config = {
'role' => 'aio',
'platform' => 'vmware',
'support_email' => '[email protected]',
'reporting_cron_enabled' => true,
'doc_url' => 'https://docs.chef.io/google_marketplace.html',
'disable_outbound_traffic' => false,
'license_count' => 25,
'license_type' => 'fixed',
'free_node_count' => 5,
}

vmware_builder_config = {
'type' => 'vmware-iso',
'iso_url' => 'http://mirror.rackspace.com/CentOS/7/isos/x86_64/CentOS-7-x86_64-Minimal-1708.iso',
'iso_checksum' => 'bba314624956961a2ea31dd460cd860a77911c1e0a56e4820a12b9c5dad363f5',
'iso_checksum_type' => 'sha256',
'ssh_username' => 'root',
'ssh_password' => node['vmware']['packer_ssh_password'],
'ssh_wait_timeout' => '30m',
'floppy_files' => [
'/tmp/ks.cfg'
],
'boot_command' => '<tab> inst.text inst.ks=hd:fd0:/ks.cfg <enter><wait>',
'shutdown_command' => 'shutdown -P now',
'remote_type' => 'esx5',
'remote_host' => node['vmware']['esx_host'],
'remote_username' => 'root',
'remote_password' => node['vmware']['esx_password'],
'vnc_disable_password' => 'true',
'format' => 'ova',
'vmx_data' => {
'ethernet0.networkName' => 'VM Network'
}
}

default['marketplace_image']['vmware']['aio']['products'] =
#[5, 25, 50, 100, 150, 200, 250].map do |node_count|
[250].map do |node_count|
{
'name' => "vmware_aio_#{node_count}",
'builder_options' => vmware_builder_config,
#'builder_options' => vmware_builder_config.merge(
# 'image_name' => "Chef_AIO_#{node_count}_{{timestamp}}"
#),
'marketplace_config_options' => default_marketplace_config.merge(
'license_count' => node_count
),
}
end

default['marketplace_image']['vmware']['compliance']['products'] =
[5, 25, 50, 100, 150, 200, 250].map do |node_count|
{
'name' => "vmware_compliance_#{node_count}",
'builder_options' => vmware_builder_config.merge(
'image_name' => "Chef_Compliance_#{node_count}_{{timestamp}}"
),
'marketplace_config_options' => default_marketplace_config.merge(
'license_count' => node_count,
'role' => 'compliance',
'doc_url' => 'https://docs.chef.io/install_compliance.html#vmware'
),
}
end
26 changes: 24 additions & 2 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
module MarketplaceImageCookbook
module Helpers
def marketplace_products
aws_products + azure_products + gce_products
aws_products + azure_products + gce_products + vmware_products
end

def enabled_products
enabled_aws_products + enabled_azure_products + enabled_gce_products
enabled_aws_products + enabled_azure_products + enabled_gce_products + enabled_vmware_products
end

def enabled_builders
Expand Down Expand Up @@ -110,6 +110,28 @@ def enabled_gce_products
products
end

def vmware_products
node['marketplace_image']['vmware']['aio']['products'] +
node['marketplace_image']['vmware']['compliance']['products']
end

def enabled_vmware_products
products = []
products += node['marketplace_image']['vmware']['aio']['products'] if
node['marketplace_image']['vmware']['automate']['enabled']
products += node['marketplace_image']['vmware']['compliance']['products'] if
node['marketplace_image']['vmware']['compliance']['enabled']
products
end

def vmware_builders
vmware_products.map { |p| p['name'] }
end

def enabled_vmware_image_names
enabled_vmware_products.map { |p| p['builder_options']['image_name'] }
end

def enabled_gce_image_names
enabled_gce_products.map { |p| p['builder_options']['image_name'] }
end
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
chef_version '>=12.19'

depends 'packman'
depends 'fancy_execute', '~> 2.0'
#depends 'fancy_execute', '~> 2.0'
26 changes: 26 additions & 0 deletions recipes/_packer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,29 @@
content JSON.pretty_generate(creds['gce']['account'])
end
end

if creds['vmware']
directory node['marketplace_image']['vmware']['cred_dir']

file node['marketplace_image']['vmware']['account_file'] do
sensitive true
content JSON.pretty_generate(creds['vmware']['account'])
end

template '/tmp/ks.cfg' do
source 'ks.cfg'
variables({
:root_password => node['vmware']['packer_ssh_password']
})
end

remote_file '/tmp/ovftool.bundle' do
source 'https://s3-us-west-2.amazonaws.com/sce-pub/VMware-ovftool-4.2.0-5965791-lin.x86_64.bundle'
mode '0755'
end

#execute 'install-ovftool' do
# cwd '/tmp'
# command './ovftool.bundle --eulas-agreed'
#end
end
78 changes: 78 additions & 0 deletions templates/default/ks.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
install
cdrom
lang en_US.UTF-8
keyboard us
unsupported_hardware
network --bootproto=dhcp
rootpw <%= @root_password %>
firewall --disabled
selinux --disabled
timezone UTC
unsupported_hardware
bootloader --location=mbr
text
skipx
zerombr
clearpart --all --initlabel
autopart
auth --enableshadow --passalgo=sha512 --kickstart
firstboot --disabled
eula --agreed
services --enabled=NetworkManager,sshd
reboot

%packages --ignoremissing --excludedocs
@Base
@Core
openssh-clients
sudo
openssl-devel
readline-devel
zlib-devel
kernel-headers
kernel-devel
net-tools
vim
wget
curl
rsync

# unnecessary firmware
-aic94xx-firmware
-atmel-firmware
-b43-openfwwf
-bfa-firmware
-ipw2100-firmware
-ipw2200-firmware
-ivtv-firmware
-iwl100-firmware
-iwl1000-firmware
-iwl3945-firmware
-iwl4965-firmware
-iwl5000-firmware
-iwl5150-firmware
-iwl6000-firmware
-iwl6000g2a-firmware
-iwl6050-firmware
-libertas-usb8388-firmware
-ql2100-firmware
-ql2200-firmware
-ql23xx-firmware
-ql2400-firmware
-ql2500-firmware
-rt61pci-firmware
-rt73usb-firmware
-xorg-x11-drv-ati-firmware
-zd1211-firmware
%end

%post
yum update -y

# update root certs
wget -O/etc/pki/tls/certs/ca-bundle.crt http://curl.haxx.se/ca/cacert.pem

# sudo
yum install -y sudo
yum clean all
%end