Skip to content

Commit

Permalink
Merge pull request #120 from gusztavvargadr/feature/add-azure-support-61
Browse files Browse the repository at this point in the history
Add initial support for Azure images #61
  • Loading branch information
gusztavvargadr authored May 29, 2019
2 parents 2d8b511 + 35d02f9 commit 5b694cf
Show file tree
Hide file tree
Showing 104 changed files with 387 additions and 487 deletions.
2 changes: 2 additions & 0 deletions Berksfile.core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def gusztavvargadr_packer_sources
gusztavvargadr_packer_cookbook 'de'
gusztavvargadr_packer_cookbook 'vs17c'
gusztavvargadr_packer_cookbook 'vs17p'
gusztavvargadr_packer_cookbook 'vs19c'
gusztavvargadr_packer_cookbook 'vs19p'
gusztavvargadr_packer_cookbook 'iis'
gusztavvargadr_packer_cookbook 'sql14d'
gusztavvargadr_packer_cookbook 'sql17d'
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Contents** [TL;DR] | [Overview] | [Getting started] | [Usage] | [Next steps] | [Contributing] | [Resources]

This repository contains common [Packer] helper tools and sample templates for [Docker], [IIS], [SQL Server] and [Visual Studio] on [Windows] and [Ubuntu], building virtual machine images and [Vagrant] boxes for [VirtualBox], [Hyper-V] and [AWS], provisioned with [Chef].
This repository contains common [Packer] helper tools and sample templates for [Visual Studio], [Docker], [IIS] and [SQL Server] on [Windows] and [Ubuntu], building virtual machine images and [Vagrant] boxes for [VirtualBox], [Hyper-V], Azure and [AWS], provisioned with [Chef].

## TL;DR

Expand All @@ -21,10 +21,10 @@ This repository contains common [Packer] helper tools and sample templates for [
This repository contains [Packer] sample template for the following virtualization scenarios:

- [Operating systems] for generic experiments with [Windows] and [Ubuntu].
- [Hosting] using [Docker], [IIS] and [SQL Server].
- [Development] using [Visual Studio].
- [Hosting] using [Docker], [IIS] and [SQL Server].

The virtual machine images and [Vagrant] boxes are built for [VirtualBox], [Hyper-V] - supporting [nested virtualization] - and [AWS], and are provisioned using [Chef].
The virtual machine images and [Vagrant] boxes are built for [VirtualBox], [Hyper-V] - supporting [nested virtualization] -, Azure and [AWS], and are provisioned using [Chef].

> **Note** All the components, including the core operating systems, share the following characteristics:
>
Expand Down Expand Up @@ -65,14 +65,28 @@ The following Vagrant boxes can be used for generic experiments on the respectiv

#### Ubuntu

- [**Ubuntu Desktop 1604**][ubuntu-desktop]
- [**Ubuntu Server 1604**][ubuntu-server]
- [**Ubuntu Desktop 1604 LTS**][ubuntu-desktop]
- [**Ubuntu Server 1604 LTS**][ubuntu-server]

[Ubuntu]: #ubuntu

[ubuntu-desktop]: https://app.vagrantup.com/gusztavvargadr/boxes/ubuntu-desktop/
[ubuntu-server]: https://app.vagrantup.com/gusztavvargadr/boxes/ubuntu-server/

### Development

The following Vagrant boxes can be used for development scenarios including setting up [virtual workstations]. They contain the respective development tools with the common configuration and are based on the core [operating systems].

[Development]: #development

#### Visual Studio

- [**Visual Studio 2019 and 2017 Community** on Windows 10 Version 1809 Enterprise and Windows Server 2019 Standard][box-visual-studio]

[Visual Studio]: #visual-studio

[box-visual-studio]: https://app.vagrantup.com/gusztavvargadr/boxes/visual-studio/

### Hosting

The following Vagrant boxes can be used for hosting scenarios. They contain the respective hosting tools with the default configuration are based on the core [operating systems].
Expand All @@ -82,7 +96,7 @@ The following Vagrant boxes can be used for hosting scenarios. They contain the
#### Docker

- [**Docker 1809 Enterprise** on Windows Server 2019 Standard Core][docker-windows]
- [**Docker 1809 Community** on Ubuntu Server 1604][docker-linux]
- [**Docker 1809 Community** on Ubuntu Server 1604 LTS][docker-linux]

[Docker]: #docker

Expand All @@ -105,20 +119,6 @@ The following Vagrant boxes can be used for hosting scenarios. They contain the

[box-sql-server]: https://app.vagrantup.com/gusztavvargadr/boxes/sql-server/

### Development

The following Vagrant boxes can be used for development scenarios including setting up [virtual workstations]. They contain the respective development tools with the common configuration and are based on the core [operating systems].

[Development]: #development

#### Visual Studio

- [**Visual Studio 2017 Community and Professional** on Windows Server 2019 Standard and Windows 10 Version 1809 Enterprise][box-visual-studio]

[Visual Studio]: #visual-studio

[box-visual-studio]: https://app.vagrantup.com/gusztavvargadr/boxes/visual-studio/

## Getting started

> **Note** The rest of this document covers the details of building virtual machine images and Vagrant boxes, and assumes that you are familiar with the basics of [Packer]. If that's not the case, it's recommended that you take a quick look at its [getting started guide][PackerGettingStarted].
Expand Down
82 changes: 39 additions & 43 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,81 +15,77 @@ VagrantMachine.defaults_include(
}
)

VagrantProvider.defaults_include(
VagrantVirtualBoxProvider.defaults_include(
'memory' => 4096,
'cpus' => 2
)

VagrantHyperVProvider.defaults_include(
'memory' => 4096,
'cpus' => 2
)

def version
'1901.0.0'
'1905'
end

VagrantDeployment.configure(directory, 'stack' => 'packer') do |deployment|
# windows-10
create_packer_windows_vms(deployment, 'w10e')
create_packer_vms(deployment, 'w10e', 'windows-10', "1809.0.#{version}-enterprise")

# windows-server
create_packer_windows_vms(deployment, 'ws2019s')
create_packer_windows_vms(deployment, 'ws2019sc')
create_packer_vms(deployment, 'ws2019s', 'windows-server', "1809.0.#{version}-standard")
create_packer_vms(deployment, 'ws2019sc', 'windows-server', "1809.0.#{version}-standard-core")

# ubuntu-desktop
create_packer_linux_vms(deployment, 'u16d')
create_packer_vms(deployment, 'u16d', 'ubuntu-desktop', "1604.0.#{version}-lts")

# ubuntu-server
create_packer_linux_vms(deployment, 'u16s')
create_packer_vms(deployment, 'u16s', 'ubuntu-server', "1604.0.#{version}-lts")

# docker-windows
create_packer_windows_vms(deployment, 'ws2019sc-de')
create_packer_vms(deployment, 'ws2019sc-de', 'docker-windows', "1809.0.#{version}-enterprise-windows-server-1809-standard-core")

# docker-linux
create_packer_linux_vms(deployment, 'u16s-dc')
create_packer_vms(deployment, 'u16s-dc', 'docker-linux', "1809.0.#{version}-community-ubuntu-server-1604-lts")

# iis
create_packer_windows_vms(deployment, 'ws2019s-iis')
create_packer_vms(deployment, 'ws2019s-iis', 'iis', "10.0.#{version}-windows-server-1809-standard")

# sql-server
create_packer_windows_vms(deployment, 'ws2019s-sql17d')
create_packer_vms(deployment, 'ws2019s-sql17d', 'sql-server', "2017.0.#{version}-developer-windows-server-1809-standard")

# visual-studio
create_packer_windows_vms(deployment, 'w10e-dc-vs17c')
create_packer_windows_vms(deployment, 'w10e-dc-vs17p')
create_packer_vms(deployment, 'w10e-dc-vs17c', 'visual-studio', "2017.0.#{version}-community-windows-10-1809-enterprise")
create_packer_vms(deployment, 'w10e-dc-vs17p', 'visual-studio', "2017.0.#{version}-professional-windows-10-1809-enterprise")
create_packer_vms(deployment, 'w10e-dc-vs19c', 'visual-studio', "2019.0.#{version}-community-windows-10-1809-enterprise")
create_packer_vms(deployment, 'w10e-dc-vs19p', 'visual-studio', "2019.0.#{version}-professional-windows-10-1809-enterprise")

create_packer_windows_vms(deployment, 'ws2019s-dc-vs17c')
create_packer_windows_vms(deployment, 'ws2019s-dc-vs17p')
end

def create_packer_windows_vms(deployment, name)
create_local_packer_vm(deployment, name, 'sysprep')
create_cloud_packer_vm(deployment, name)
create_packer_vms(deployment, 'ws2019s-dc-vs17c', 'visual-studio', "2017.0.#{version}-community-windows-server-1809-standard")
create_packer_vms(deployment, 'ws2019s-dc-vs17p', 'visual-studio', "2017.0.#{version}-professional-windows-server-1809-standard")
create_packer_vms(deployment, 'ws2019s-dc-vs19c', 'visual-studio', "2019.0.#{version}-community-windows-server-1809-standard")
create_packer_vms(deployment, 'ws2019s-dc-vs19p', 'visual-studio', "2019.0.#{version}-professional-windows-server-1809-standard")
end

def create_packer_linux_vms(deployment, name)
def create_packer_vms(deployment, name, cloud_name, cloud_version)
create_local_packer_vm(deployment, name, 'sysprep')
create_cloud_packer_vm(deployment, name)
create_cloud_packer_vm(deployment, name, cloud_name, cloud_version)
end

def create_local_packer_vm(deployment, name, type = '')
type_suffix = type.to_s.empty? ? '' : "-#{type}"

def create_local_packer_vm(deployment, name, type)
VagrantMachine.configure(deployment, 'name' => "#{name}-local", 'box' => "gusztavvargadr/#{name}-local") do |machine|
VagrantVirtualBoxProvider.configure(machine) do |provider|
provider.override.vm.box_url = "file://#{File.dirname(__FILE__)}/build/#{name}/virtualbox#{type_suffix}/output/vagrant.box"
provider.override.vm.box_url = "file://#{File.dirname(__FILE__)}/build/#{name}/virtualbox-#{type}/output/vagrant.box"
end

VagrantHyperVProvider.configure(machine) do |provider|
provider.override.vm.box_url = "file://#{File.dirname(__FILE__)}/build/#{name}/hyperv#{type_suffix}/output/vagrant.box"
provider.override.vm.box_url = "file://#{File.dirname(__FILE__)}/build/#{name}/hyperv-#{type}/output/vagrant.box"
end
end
end

def create_cloud_packer_vm(deployment, name)
def create_cloud_packer_vm(deployment, name, cloud_name, cloud_version)
VagrantMachine.configure(deployment, 'name' => "#{name}-cloud", 'box' => "gusztavvargadr/#{name}-cloud") do |machine|
VagrantVirtualBoxProvider.configure(machine) do |provider|
provider.override.vm.box_url = "https://vagrantcloud.com/gusztavvargadr/boxes/#{name}/versions/#{version}/providers/virtualbox.box"
end
machine.vagrant.vm.box = "gusztavvargadr/#{cloud_name}"
machine.vagrant.vm.box_version = cloud_version

VagrantHyperVProvider.configure(machine) do |provider|
provider.override.vm.box_url = "https://vagrantcloud.com/gusztavvargadr/boxes/#{name}/versions/#{version}/providers/hyperv.box"
end
# VagrantVirtualBoxProvider.configure(machine) do |provider|
# provider.override.vm.box_url = "https://vagrantcloud.com/gusztavvargadr/boxes/#{cloud_name}/versions/#{cloud_version}/providers/virtualbox.box"
# end

# VagrantHyperVProvider.configure(machine) do |provider|
# provider.override.vm.box_url = "https://vagrantcloud.com/gusztavvargadr/boxes/#{cloud_name}/versions/#{cloud_version}/providers/hyperv.box"
# end
end
end
70 changes: 38 additions & 32 deletions ci.cake
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,31 @@ var ws2019s_sql17d = PackerTemplates_CreateWindows("ws2019s-sql17d", parents: ws
var w10e_dc = PackerTemplates_CreateWindows("w10e-dc", parents: w10e);
var w10e_dc_vs17c = PackerTemplates_CreateWindows("w10e-dc-vs17c", parents: w10e_dc);
var w10e_dc_vs17p = PackerTemplates_CreateWindows("w10e-dc-vs17p", parents: w10e_dc);
var w10e_dc_vs19c = PackerTemplates_CreateWindows("w10e-dc-vs19c", parents: w10e_dc);
var w10e_dc_vs19p = PackerTemplates_CreateWindows("w10e-dc-vs19p", parents: w10e_dc);

var ws2019s_dc = PackerTemplates_CreateWindows("ws2019s-dc", parents: ws2019s);
var ws2019s_dc_vs17c = PackerTemplates_CreateWindows("ws2019s-dc-vs17c", parents: ws2019s_dc);
var ws2019s_dc_vs17p = PackerTemplates_CreateWindows("ws2019s-dc-vs17p", parents: ws2019s_dc);
var ws2019s_dc_vs19c = PackerTemplates_CreateWindows("ws2019s-dc-vs19c", parents: ws2019s_dc);
var ws2019s_dc_vs19p = PackerTemplates_CreateWindows("ws2019s-dc-vs19p", parents: ws2019s_dc);

packerTemplate = configuration;
packerRecursive = recursive;

IEnumerable<PackerTemplate> PackerTemplates_CreateWindows(string type, bool amazon = false, IEnumerable<PackerTemplate> parents = null) {
IEnumerable<PackerTemplate> PackerTemplates_CreateWindows(string name, IEnumerable<PackerTemplate> parents = null) {
var items = new List<PackerTemplate>();

var virtualBoxCore = PackerTemplate_Create(
type,
name,
"virtualbox-core",
new [] { PackerBuilder_Create(parents == null ? "virtualbox-iso" : "virtualbox-ovf") },
new [] { PackerProvisioner_Create("chef") },
new PackerPostProcessor[] {},
parents != null ? parents.First(item => item.IsMatching("virtualbox-core")) : null
);
var virtualBoxSysprep = PackerTemplate_Create(
type,
name,
"virtualbox-sysprep",
new [] { PackerBuilder_Create("virtualbox-ovf") },
new [] { PackerProvisioner_Create("sysprep") },
Expand All @@ -64,15 +68,15 @@ IEnumerable<PackerTemplate> PackerTemplates_CreateWindows(string type, bool amaz
items.Add(virtualBoxSysprep);

var hyperVCore = PackerTemplate_Create(
type,
name,
"hyperv-core",
new [] { PackerBuilder_Create(parents == null ? "hyperv-iso" : "hyperv-vmcx") },
new [] { PackerProvisioner_Create("chef") },
new PackerPostProcessor[] {},
parents != null ? parents.First(item => item.IsMatching("hyperv-core")) : null
);
var hyperVSysprep = PackerTemplate_Create(
type,
name,
"hyperv-sysprep",
new [] { PackerBuilder_Create("hyperv-vmcx") },
new [] { PackerProvisioner_Create("sysprep") },
Expand All @@ -82,58 +86,46 @@ IEnumerable<PackerTemplate> PackerTemplates_CreateWindows(string type, bool amaz
items.Add(hyperVCore);
items.Add(hyperVSysprep);

if (amazon) {
var amazonSysprep = PackerTemplate_Create(
type,
"amazon-sysprep",
new [] { PackerBuilder_Create("amazon-ebs") },
new [] { PackerProvisioner_Create("chef"), PackerProvisioner_Create("amazon-shutdown") },
new [] { PackerPostProcessor_Create("vagrant-amazon") },
null
);
items.Add(amazonSysprep);
}

packerTemplates.AddRange(items);

return items;
}

IEnumerable<PackerTemplate> PackerTemplates_CreateLinux(string type, bool amazon = false, IEnumerable<PackerTemplate> parents = null) {
IEnumerable<PackerTemplate> PackerTemplates_CreateLinux(string name, bool amazon = true, bool azure = true, IEnumerable<PackerTemplate> parents = null) {
var items = new List<PackerTemplate>();

var virtualBoxCore = PackerTemplate_Create(
type,
name,
"virtualbox-core",
new [] { PackerBuilder_Create(parents == null ? "virtualbox-iso" : "virtualbox-ovf") },
new [] { PackerProvisioner_Create("shell") },
new [] { PackerProvisioner_Create("shell-prepare"), PackerProvisioner_Create("shell-configure"), PackerProvisioner_Create("shell-install"), PackerProvisioner_Create("shell-cleanup") },
new PackerPostProcessor[] {},
parents != null ? parents.First(item => item.IsMatching("virtualbox-core")) : null
);
var virtualBoxSysprep = PackerTemplate_Create(
type,
name,
"virtualbox-sysprep",
new [] { PackerBuilder_Create("virtualbox-ovf") },
new PackerProvisioner[] {},
new [] { PackerProvisioner_Create("shell-vagrant") },
new [] { PackerPostProcessor_Create("vagrant-virtualbox") },
virtualBoxCore
);
items.Add(virtualBoxCore);
items.Add(virtualBoxSysprep);

var hyperVCore = PackerTemplate_Create(
type,
name,
"hyperv-core",
new [] { PackerBuilder_Create(parents == null ? "hyperv-iso" : "hyperv-vmcx") },
new [] { PackerProvisioner_Create("shell") },
new [] { PackerProvisioner_Create("shell-prepare"), PackerProvisioner_Create("shell-configure"), PackerProvisioner_Create("shell-install"), PackerProvisioner_Create("shell-cleanup") },
new PackerPostProcessor[] {},
parents != null ? parents.First(item => item.IsMatching("hyperv-core")) : null
);
var hyperVSysprep = PackerTemplate_Create(
type,
name,
"hyperv-sysprep",
new [] { PackerBuilder_Create("hyperv-vmcx") },
new PackerProvisioner[] {},
new [] { PackerProvisioner_Create("shell-vagrant") },
new [] { PackerPostProcessor_Create("vagrant-hyperv") },
hyperVCore
);
Expand All @@ -142,16 +134,30 @@ IEnumerable<PackerTemplate> PackerTemplates_CreateLinux(string type, bool amazon

if (amazon) {
var amazonSysprep = PackerTemplate_Create(
type,
"amazon-sysprep",
new [] { PackerBuilder_Create("amazon-ebs") },
new [] { PackerProvisioner_Create("shell") },
new [] { PackerPostProcessor_Create("vagrant-amazon") },
null
name,
"amazon",
new [] { PackerBuilder_Create("amazon") },
new [] { PackerProvisioner_Create("shell-prepare"), PackerProvisioner_Create("shell-configure"), PackerProvisioner_Create("shell-install"), PackerProvisioner_Create("shell-cleanup") },
new PackerPostProcessor[] {},
// new [] { PackerPostProcessor_Create("vagrant-amazon") },
parents != null ? parents.First(item => item.IsMatching("amazon")) : null
);
items.Add(amazonSysprep);
}

if (azure) {
var azureSysprep = PackerTemplate_Create(
name,
"azure",
new [] { PackerBuilder_Create(parents == null ? "azure-marketplace" : "azure-custom") },
new [] { PackerProvisioner_Create("shell-prepare"), PackerProvisioner_Create("shell-configure"), PackerProvisioner_Create("shell-install"), PackerProvisioner_Create("shell-cleanup") },
new PackerPostProcessor[] {},
parents != null ? parents.First(item => item.IsMatching("azure")) : null
);

items.Add(azureSysprep);
}

packerTemplates.AddRange(items);

return items;
Expand Down
2 changes: 1 addition & 1 deletion lib/gusztavvargadr/chef
Submodule chef updated 27 files
+1 −1 lib/gusztavvargadr/vagrant
+13 −6 samples/cookbooks/iis/attributes/server.rb
+1 −0 samples/cookbooks/mssql/attributes/2014_developer.rb
+1 −1 samples/cookbooks/mssql/attributes/2017_developer.rb
+0 −3 samples/cookbooks/visualstudio/attributes/2015_community.rb
+0 −3 samples/cookbooks/visualstudio/attributes/2015_professional.rb
+0 −5 samples/cookbooks/visualstudio/attributes/2015_requirements.rb
+2 −2 samples/cookbooks/visualstudio/attributes/2017_community.rb
+2 −2 samples/cookbooks/visualstudio/attributes/2017_professional.rb
+24 −0 samples/cookbooks/visualstudio/attributes/2019_community.rb
+24 −0 samples/cookbooks/visualstudio/attributes/2019_professional.rb
+5 −0 samples/cookbooks/visualstudio/attributes/2019_requirements.rb
+0 −84 samples/cookbooks/visualstudio/files/2015_community.xml
+0 −85 samples/cookbooks/visualstudio/files/2015_professional.xml
+0 −3 samples/cookbooks/visualstudio/recipes/2015_community.rb
+0 −3 samples/cookbooks/visualstudio/recipes/2015_professional.rb
+0 −3 samples/cookbooks/visualstudio/recipes/2015_requirements.rb
+3 −0 samples/cookbooks/visualstudio/recipes/2019_community.rb
+3 −0 samples/cookbooks/visualstudio/recipes/2019_professional.rb
+3 −0 samples/cookbooks/visualstudio/recipes/2019_requirements.rb
+0 −34 samples/cookbooks/visualstudio/resources/2010.rb
+0 −34 samples/cookbooks/visualstudio/resources/2015.rb
+7 −0 samples/cookbooks/visualstudio/resources/2019.rb
+6 −0 samples/cookbooks/visualstudio_test/.kitchen.yml
+6 −0 samples/cookbooks/visualstudio_test/recipes/2019_community.rb
+6 −0 samples/cookbooks/visualstudio_test/recipes/2019_professional.rb
+11 −9 src/kitchen.vagrant.rb
Loading

0 comments on commit 5b694cf

Please sign in to comment.