PackerFiles 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/PackerFiles.gemspec +36 -0
- data/README.md +32 -0
- data/Rakefile +21 -0
- data/bin/pkf +5 -0
- data/lib/PackerFiles/CLI/OS.rb +44 -0
- data/lib/PackerFiles/CLI/Root.rb +41 -0
- data/lib/PackerFiles/Core/Base.rb +23 -0
- data/lib/PackerFiles/Core/CDImage.rb +185 -0
- data/lib/PackerFiles/Core/Disk.rb +135 -0
- data/lib/PackerFiles/Core/Exceptions.rb +65 -0
- data/lib/PackerFiles/Core/Hypervisor.rb +96 -0
- data/lib/PackerFiles/Core/Keyboard.rb +38 -0
- data/lib/PackerFiles/Core/Locale.rb +62 -0
- data/lib/PackerFiles/Core/LogicalVolume.rb +41 -0
- data/lib/PackerFiles/Core/Network.rb +67 -0
- data/lib/PackerFiles/Core/Packages.rb +30 -0
- data/lib/PackerFiles/Core/Partition.rb +41 -0
- data/lib/PackerFiles/Core/TimeZone.rb +45 -0
- data/lib/PackerFiles/Core/User.rb +46 -0
- data/lib/PackerFiles/Core/VolumeGroup.rb +50 -0
- data/lib/PackerFiles/Core/example/CDImage.txt +75 -0
- data/lib/PackerFiles/Core/example/Disk.txt +29 -0
- data/lib/PackerFiles/Core/example/Hypervisor.txt +111 -0
- data/lib/PackerFiles/Core/example/Keyboard.txt +28 -0
- data/lib/PackerFiles/Core/example/Locale.txt +31 -0
- data/lib/PackerFiles/Core/example/Network.txt +68 -0
- data/lib/PackerFiles/Core/example/Packages.txt +22 -0
- data/lib/PackerFiles/Core/example/TimeZone.txt +36 -0
- data/lib/PackerFiles/Core/example/User.txt +48 -0
- data/lib/PackerFiles/OS/Builder.rb +116 -0
- data/lib/PackerFiles/OS/CentOS/CD.rb +81 -0
- data/lib/PackerFiles/OS/CentOS/Kickstart.rb +64 -0
- data/lib/PackerFiles/OS/CentOS/Server.rb +170 -0
- data/lib/PackerFiles/OS/CentOS/Templates/Base_erb.rb +4 -0
- data/lib/PackerFiles/OS/CentOS/Templates/Disk_erb.rb +35 -0
- data/lib/PackerFiles/OS/CentOS/Templates/Keyboard_erb.rb +4 -0
- data/lib/PackerFiles/OS/CentOS/Templates/Locale_erb.rb +4 -0
- data/lib/PackerFiles/OS/CentOS/Templates/Network_erb.rb +17 -0
- data/lib/PackerFiles/OS/CentOS/Templates/Packages_erb.rb +34 -0
- data/lib/PackerFiles/OS/CentOS/Templates/Tail_erb.rb +15 -0
- data/lib/PackerFiles/OS/CentOS/Templates/TimeZone_erb.rb +10 -0
- data/lib/PackerFiles/OS/CentOS/Templates/User_erb.rb +20 -0
- data/lib/PackerFiles/OS/CentOS/Templates/boot_command_erb.rb +16 -0
- data/lib/PackerFiles/OS/CentOS/Templates/command_as_root_erb.rb +1 -0
- data/lib/PackerFiles/OS/CentOS/Templates/disable_root_erb.rb +1 -0
- data/lib/PackerFiles/OS/CentOS/Templates/enable_root_erb.rb +1 -0
- data/lib/PackerFiles/OS/CentOS/Templates/shutdown_command_erb.rb +1 -0
- data/lib/PackerFiles/OS/Debian/Apt.rb +42 -0
- data/lib/PackerFiles/OS/Debian/CD.rb +65 -0
- data/lib/PackerFiles/OS/Debian/Mirrors.rb +73 -0
- data/lib/PackerFiles/OS/Debian/Preseed.rb +64 -0
- data/lib/PackerFiles/OS/Debian/Server.rb +169 -0
- data/lib/PackerFiles/OS/Debian/Templates/Apt_erb.rb +18 -0
- data/lib/PackerFiles/OS/Debian/Templates/Disk_erb.rb +69 -0
- data/lib/PackerFiles/OS/Debian/Templates/Keyboard_erb.rb +5 -0
- data/lib/PackerFiles/OS/Debian/Templates/Locale_erb.rb +7 -0
- data/lib/PackerFiles/OS/Debian/Templates/Mirrors_erb.rb +9 -0
- data/lib/PackerFiles/OS/Debian/Templates/Network_erb.rb +19 -0
- data/lib/PackerFiles/OS/Debian/Templates/Packages_erb.rb +6 -0
- data/lib/PackerFiles/OS/Debian/Templates/TimeZone_erb.rb +6 -0
- data/lib/PackerFiles/OS/Debian/Templates/User_erb.rb +14 -0
- data/lib/PackerFiles/OS/Debian/Templates/boot_command_erb.rb +24 -0
- data/lib/PackerFiles/OS/Debian/Templates/command_as_root_erb.rb +1 -0
- data/lib/PackerFiles/OS/Debian/Templates/disable_root_erb.rb +5 -0
- data/lib/PackerFiles/OS/Debian/Templates/enable_root_erb.rb +1 -0
- data/lib/PackerFiles/OS/Debian/Templates/shutdown_command_erb.rb +1 -0
- data/lib/PackerFiles/OS/Debian/example/Apt.txt +55 -0
- data/lib/PackerFiles/OS/DocGenerator.rb +51 -0
- data/lib/PackerFiles/OS/Finder.rb +96 -0
- data/lib/PackerFiles/OS/RHEL/CD.rb +32 -0
- data/lib/PackerFiles/OS/RHEL/Fedora.rb +59 -0
- data/lib/PackerFiles/OS/RHEL/FedoraCD.rb +68 -0
- data/lib/PackerFiles/OS/RHEL/Server.rb +32 -0
- data/lib/PackerFiles/OS/RHEL/Templates/Fedora_Tail_erb.rb +14 -0
- data/lib/PackerFiles/OS/RHEL/Templates/boot_command_fedora_erb.rb +16 -0
- data/lib/PackerFiles/OS/SUSE/Templates/Base_erb.xml +32 -0
- data/lib/PackerFiles/OS/SUSE/Templates/Disk_erb.xml +110 -0
- data/lib/PackerFiles/OS/SUSE/Templates/Keyboard_erb.xml +7 -0
- data/lib/PackerFiles/OS/SUSE/Templates/Locale_erb.xml +18 -0
- data/lib/PackerFiles/OS/SUSE/Templates/Network_erb.xml +143 -0
- data/lib/PackerFiles/OS/SUSE/Templates/Packages_erb.xml +29 -0
- data/lib/PackerFiles/OS/SUSE/Templates/Tail_erb.xml +4 -0
- data/lib/PackerFiles/OS/SUSE/Templates/TimeZone_erb.xml +15 -0
- data/lib/PackerFiles/OS/SUSE/Templates/User_erb.xml +57 -0
- data/lib/PackerFiles/OS/SUSE/Templates/boot_command_erb.rb +23 -0
- data/lib/PackerFiles/OS/SUSE/Templates/command_as_root_erb.rb +1 -0
- data/lib/PackerFiles/OS/SUSE/Templates/disable_root_erb.rb +1 -0
- data/lib/PackerFiles/OS/SUSE/Templates/enable_root_erb.rb +1 -0
- data/lib/PackerFiles/OS/SUSE/Templates/shutdown_command_erb.rb +1 -0
- data/lib/PackerFiles/OS/Ubuntu/CD.rb +81 -0
- data/lib/PackerFiles/OS/Ubuntu/Desktop.rb +50 -0
- data/lib/PackerFiles/OS/Ubuntu/DesktopCD.rb +16 -0
- data/lib/PackerFiles/OS/Ubuntu/Mirrors.rb +103 -0
- data/lib/PackerFiles/OS/Ubuntu/Server.rb +78 -0
- data/lib/PackerFiles/OS/Ubuntu/Templates/Apt_erb.rb +18 -0
- data/lib/PackerFiles/OS/Ubuntu/Templates/boot_command_desktop_erb.rb +36 -0
- data/lib/PackerFiles/OS/Ubuntu/Templates/boot_command_erb.rb +30 -0
- data/lib/PackerFiles/OS/Ubuntu/Templates/ubiquity_erb.rb +8 -0
- data/lib/PackerFiles/OS/example/Doc.txt +8 -0
- data/lib/PackerFiles/Provision/Base.rb +20 -0
- data/lib/PackerFiles/Provision/ChefSolo.rb +90 -0
- data/lib/PackerFiles/Provision/ChefSoloHelper.rb +72 -0
- data/lib/PackerFiles/Provision/Copy.rb +22 -0
- data/lib/PackerFiles/Provision/ExternalScript.rb +43 -0
- data/lib/PackerFiles/Provision/InlineScript.rb +37 -0
- data/lib/PackerFiles/Provision/Provisioners.rb +87 -0
- data/lib/PackerFiles/Provision/example/Provisioners.txt +21 -0
- data/lib/PackerFiles/Utils/AutoZone.rb +96 -0
- data/lib/PackerFiles/Utils/FastestURL.rb +73 -0
- data/lib/PackerFiles/Utils/Generator.rb +34 -0
- data/lib/PackerFiles/Utils/HashSerializer.rb +110 -0
- data/lib/PackerFiles/Utils/Size.rb +44 -0
- data/lib/PackerFiles/Utils/TypeAccessor.rb +71 -0
- data/lib/PackerFiles/Virtual/Hypervisors.rb +72 -0
- data/lib/PackerFiles/Virtual/KVM.rb +119 -0
- data/lib/PackerFiles/Virtual/KVMConverter.rb +79 -0
- data/lib/PackerFiles/Virtual/VMWare.rb +108 -0
- data/lib/PackerFiles/Virtual/VMWareConverter.rb +78 -0
- data/lib/PackerFiles/Virtual/VirtualBox.rb +98 -0
- data/lib/PackerFiles/Virtual/VirtualBoxConverter.rb +75 -0
- data/lib/PackerFiles/Virtual/example/Hypervisors.txt +23 -0
- data/lib/PackerFiles/version.rb +3 -0
- data/lib/PackerFiles.rb +44 -0
- data/spec/core/builder_spec.rb +84 -0
- data/spec/core/cdimage_spec.rb +159 -0
- data/spec/core/disk_spec.rb +191 -0
- data/spec/core/keyboard_spec.rb +36 -0
- data/spec/core/locale_spec.rb +73 -0
- data/spec/core/network_spec.rb +96 -0
- data/spec/core/packages_spec.rb +18 -0
- data/spec/core/timezone_spec.rb +43 -0
- data/spec/core/user_spec.rb +44 -0
- data/spec/core/volume_group_spec.rb +53 -0
- data/spec/os/centos/cd_spec.rb +12 -0
- data/spec/os/centos/data/Server-Script-Provisioner.rb +57 -0
- data/spec/os/centos/data/Server.rb +55 -0
- data/spec/os/centos/data/chef-solo-provisioner.rb +58 -0
- data/spec/os/centos/finder_spec.rb +22 -0
- data/spec/os/centos/templates/boot_command_spec.rb +57 -0
- data/spec/os/centos/templates/disk_spec.rb +79 -0
- data/spec/os/centos/templates/keyboard_spec.rb +18 -0
- data/spec/os/centos/templates/locale_spec.rb +26 -0
- data/spec/os/centos/templates/network_spec.rb +38 -0
- data/spec/os/centos/templates/packages_spec.rb +18 -0
- data/spec/os/centos/templates/timezone_spec.rb +37 -0
- data/spec/os/centos/templates/user_spec.rb +24 -0
- data/spec/os/debian/apt_spec.rb +50 -0
- data/spec/os/debian/cd_spec.rb +30 -0
- data/spec/os/debian/data/7zip.tar.gz +0 -0
- data/spec/os/debian/data/All-sections.rb +60 -0
- data/spec/os/debian/data/Chef-Solo-Provisioner.rb +60 -0
- data/spec/os/debian/data/Copy-Provisioner.rb +61 -0
- data/spec/os/debian/data/External-Script-Provisioner.rb +69 -0
- data/spec/os/debian/data/Missing-CDImage.rb +53 -0
- data/spec/os/debian/data/Missing-VMWare-KVM-sections.rb +51 -0
- data/spec/os/debian/data/Missing-sections.rb +53 -0
- data/spec/os/debian/data/Script-Provisioner.rb +62 -0
- data/spec/os/debian/data/chef-solo-cookbooks/git_setup/Berksfile.lock +32 -0
- data/spec/os/debian/data/chef-solo-cookbooks/git_setup/README.md +81 -0
- data/spec/os/debian/data/chef-solo-cookbooks/git_setup/attributes/default.rb +3 -0
- data/spec/os/debian/data/chef-solo-cookbooks/git_setup/metadata.rb +11 -0
- data/spec/os/debian/data/chef-solo-cookbooks/git_setup/recipes/default.rb +30 -0
- data/spec/os/debian/data/chef-solo.json +5 -0
- data/spec/os/debian/data/test-script.sh +4 -0
- data/spec/os/debian/finder_spec.rb +59 -0
- data/spec/os/debian/mirrors_spec.rb +18 -0
- data/spec/os/debian/preseed_spec.rb +56 -0
- data/spec/os/debian/server_spec.rb +59 -0
- data/spec/os/debian/templates/apt_spec.rb +20 -0
- data/spec/os/debian/templates/boot_command_spec.rb +56 -0
- data/spec/os/debian/templates/disk_spec.rb +81 -0
- data/spec/os/debian/templates/keyboard_spec.rb +18 -0
- data/spec/os/debian/templates/locale_spec.rb +36 -0
- data/spec/os/debian/templates/mirrors_spec.rb +16 -0
- data/spec/os/debian/templates/network_spec.rb +38 -0
- data/spec/os/debian/templates/packages_spec.rb +17 -0
- data/spec/os/debian/templates/timezone_spec.rb +36 -0
- data/spec/os/debian/templates/user_spec.rb +25 -0
- data/spec/os/finder_spec.rb +21 -0
- data/spec/os/rhel/data/Fedora.rb +45 -0
- data/spec/os/rhel/data/Server-Custom.rb +54 -0
- data/spec/os/rhel/data/Server.rb +45 -0
- data/spec/os/rhel/finder_spec.rb +21 -0
- data/spec/os/ubuntu/cd_spec.rb +28 -0
- data/spec/os/ubuntu/data/Desktop.rb +61 -0
- data/spec/os/ubuntu/data/Server.rb +61 -0
- data/spec/os/ubuntu/finder_spec.rb +17 -0
- data/spec/os/ubuntu/mirrors_spec.rb +18 -0
- data/spec/utils/autozone_spec.rb +33 -0
- data/spec/virtual/virtual_box_spec.rb +16 -0
- metadata +405 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
# Requires
|
|
3
|
+
|
|
4
|
+
module PackerFiles
|
|
5
|
+
|
|
6
|
+
module Core
|
|
7
|
+
|
|
8
|
+
# The Hypervisor class just abstracts out various settings that are
|
|
9
|
+
# applicable on Hypervisors. It is upto the providers to ensure that
|
|
10
|
+
# the appropriate Packer variables are generated for these settings.
|
|
11
|
+
class Hypervisor
|
|
12
|
+
|
|
13
|
+
# CPU count
|
|
14
|
+
attr_accessor :cpu_count
|
|
15
|
+
|
|
16
|
+
# CPU Speed
|
|
17
|
+
attr_accessor :cpu_speed
|
|
18
|
+
|
|
19
|
+
# Enable CPU Hot plug?
|
|
20
|
+
attr_accessor :cpu_hot_plug
|
|
21
|
+
|
|
22
|
+
# CPU Execution Cap
|
|
23
|
+
attr_accessor :cpu_execution_cap
|
|
24
|
+
|
|
25
|
+
# RAM Size
|
|
26
|
+
attr_accessor :ram_size
|
|
27
|
+
|
|
28
|
+
# Video ram size
|
|
29
|
+
attr_accessor :video_ram_size
|
|
30
|
+
|
|
31
|
+
# Is ACPI enabled?
|
|
32
|
+
attr_accessor :acpi_enabled
|
|
33
|
+
|
|
34
|
+
# Should PAE (Processor Address Extensions) enabled?
|
|
35
|
+
attr_accessor :pae_enabled
|
|
36
|
+
|
|
37
|
+
# Should H/w Virtualization for Guest be enabled
|
|
38
|
+
attr_accessor :hw_virt_enabled
|
|
39
|
+
|
|
40
|
+
# Should nested paging for guest be enabled
|
|
41
|
+
attr_accessor :hw_nested_pages
|
|
42
|
+
|
|
43
|
+
# Should Hypervisor use large pages for this guest
|
|
44
|
+
attr_accessor :use_large_pages
|
|
45
|
+
|
|
46
|
+
# Should the guest run in unrestricted mode
|
|
47
|
+
attr_accessor :unrestricted_guest_mode
|
|
48
|
+
|
|
49
|
+
# Should 3d acceleration be enabled for Video
|
|
50
|
+
attr_accessor :video_3d_acceleration
|
|
51
|
+
|
|
52
|
+
# Should EFI firmware be used instead of bios
|
|
53
|
+
attr_accessor :use_efi
|
|
54
|
+
|
|
55
|
+
# Guest memory balloon size
|
|
56
|
+
attr_accessor :guest_balloon_size
|
|
57
|
+
|
|
58
|
+
# Custom object which can be used for whatever purpose
|
|
59
|
+
# it suits the caller
|
|
60
|
+
attr_reader :custom
|
|
61
|
+
|
|
62
|
+
# Documentation for this class
|
|
63
|
+
def self.doc_file
|
|
64
|
+
PackerFiles.DirPath('Core/example/Hypervisor.txt').first
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Constructor initializes some sane values for various parameters.
|
|
68
|
+
def initialize
|
|
69
|
+
@cpu_count = 1
|
|
70
|
+
@cpu_speed = '1GHz'
|
|
71
|
+
@cpu_hot_plug = false
|
|
72
|
+
@cpu_execution_cap = 100
|
|
73
|
+
@ram_size = '1GiB'
|
|
74
|
+
@video_ram_size = '64MiB'
|
|
75
|
+
@acpi_enabled = true
|
|
76
|
+
@pae_enabled = true
|
|
77
|
+
@hw_virt_enabled = true
|
|
78
|
+
@use_large_pages = true
|
|
79
|
+
@unrestricted_guest_mode = false
|
|
80
|
+
@video_3d_acceleration = false
|
|
81
|
+
@use_efi = false
|
|
82
|
+
@guest_balloon_size = '0MiB'
|
|
83
|
+
@custom = nil
|
|
84
|
+
yield self if block_given?
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# The Custom object is filled with whatever is the result of the block
|
|
88
|
+
def Custom(&block)
|
|
89
|
+
@custom = block.call(self)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end # class HyperVisor
|
|
93
|
+
|
|
94
|
+
end # Core
|
|
95
|
+
|
|
96
|
+
end # PackerFiles
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
# Requires
|
|
3
|
+
require_relative 'Base'
|
|
4
|
+
require_relative 'Exceptions'
|
|
5
|
+
|
|
6
|
+
module PackerFiles
|
|
7
|
+
module Core
|
|
8
|
+
|
|
9
|
+
# Define the Keyboard class that can handle Keyboards specified in a Packerfile.
|
|
10
|
+
# Just the barebones attributes that are required for this class are specified
|
|
11
|
+
# here. The conversion of these attributes into a OS build specific file is
|
|
12
|
+
# done by derived classes in the OS specific directories.
|
|
13
|
+
class Keyboard < Base
|
|
14
|
+
|
|
15
|
+
# Specify attributes
|
|
16
|
+
attr_accessor :layout
|
|
17
|
+
attr_accessor :variant
|
|
18
|
+
|
|
19
|
+
# Documentation for this class
|
|
20
|
+
def self.doc_file
|
|
21
|
+
PackerFiles.DirPath('Core/example/Keyboard.txt').first
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Constructor to just specify accessor varibales
|
|
25
|
+
def initialize
|
|
26
|
+
yield self if block_given?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Normalize the various values into something useful. The
|
|
30
|
+
# default implementation checks only errors
|
|
31
|
+
def normalize
|
|
32
|
+
raise NilException.new(self, 'layout') if @layout.nil?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end #Core
|
|
38
|
+
end # PackerFiles
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
# Requires
|
|
3
|
+
require_relative 'Base'
|
|
4
|
+
|
|
5
|
+
module PackerFiles
|
|
6
|
+
module Core
|
|
7
|
+
|
|
8
|
+
# Define the Locale class that can handle locales specified in a Packerfile.
|
|
9
|
+
# Just the barebones attributes that are required for this class are specified
|
|
10
|
+
# here. The conversion of these attributes into a OS build specific file is
|
|
11
|
+
# done by derived classes in the OS specific directories.
|
|
12
|
+
class Locale < Base
|
|
13
|
+
|
|
14
|
+
# Specify attributes
|
|
15
|
+
attr_accessor :default
|
|
16
|
+
attr_accessor :language
|
|
17
|
+
attr_accessor :country
|
|
18
|
+
attr_accessor :supported
|
|
19
|
+
|
|
20
|
+
# Documentation for this class
|
|
21
|
+
def self.doc_file
|
|
22
|
+
PackerFiles.DirPath('Core/example/Locale.txt').first
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Constructor to just specify accessor varibales
|
|
26
|
+
def initialize
|
|
27
|
+
@supported = []
|
|
28
|
+
yield self if block_given?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Normalize the various values into something useful. Usually
|
|
32
|
+
# this means adding UTF-8 into the default string. if desired
|
|
33
|
+
def normalize(utf = true, str='.UTF-8')
|
|
34
|
+
|
|
35
|
+
# Concatenate language and country if the detailed notation
|
|
36
|
+
# instead of the simpler one is preferred.
|
|
37
|
+
if (!@language.nil? && !@country.nil?)
|
|
38
|
+
@default = @language + '_' + @country
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# If you need to add UTF prefixes, then add them to the
|
|
42
|
+
# default locale.
|
|
43
|
+
if (utf && !@default.end_with?(str))
|
|
44
|
+
@default = @default + str
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# If you need to add UTF prefixes for all the supported
|
|
48
|
+
# locales, do the same.
|
|
49
|
+
@supported.map! {|x|
|
|
50
|
+
if (utf && !x.end_with?(str))
|
|
51
|
+
x + str
|
|
52
|
+
else
|
|
53
|
+
x
|
|
54
|
+
end
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end # Locale
|
|
59
|
+
|
|
60
|
+
end # Core
|
|
61
|
+
|
|
62
|
+
end # PackerFiles
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
# Requires
|
|
3
|
+
require 'Utils/Size'
|
|
4
|
+
require_relative 'Base'
|
|
5
|
+
require_relative 'Exceptions'
|
|
6
|
+
|
|
7
|
+
module PackerFiles
|
|
8
|
+
module Core
|
|
9
|
+
|
|
10
|
+
# Abstraction for Logical Volume
|
|
11
|
+
class LogicalVolume < Base
|
|
12
|
+
|
|
13
|
+
# Include MiB as a method inside Disk
|
|
14
|
+
include Utils::Size
|
|
15
|
+
|
|
16
|
+
# Specify attributes
|
|
17
|
+
attr_accessor :size
|
|
18
|
+
attr_accessor :mount_point
|
|
19
|
+
attr_accessor :file_system
|
|
20
|
+
attr_accessor :name
|
|
21
|
+
attr_accessor :vg_name
|
|
22
|
+
|
|
23
|
+
# Constructor to just specify accessor varibales
|
|
24
|
+
def initialize
|
|
25
|
+
@size = 0
|
|
26
|
+
yield self if block_given?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Normalize the values
|
|
30
|
+
def normalize
|
|
31
|
+
raise NilException.new(self, 'name') if @name.nil?
|
|
32
|
+
raise NilException.new(self, 'vg_name') if @vg_name.nil?
|
|
33
|
+
raise 'size cannot be zero' if @size == 0
|
|
34
|
+
@size = MiB(@size)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end # LogicalVolume
|
|
38
|
+
|
|
39
|
+
end # Core
|
|
40
|
+
end # PackerFiles
|
|
41
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
|
|
2
|
+
# Requires
|
|
3
|
+
require_relative 'Base'
|
|
4
|
+
require_relative 'Exceptions'
|
|
5
|
+
|
|
6
|
+
module PackerFiles
|
|
7
|
+
|
|
8
|
+
module Core
|
|
9
|
+
# Define the Network class that can handle Network specified in a Packerfile.
|
|
10
|
+
# Just the barebones attributes that are required for this class are specified
|
|
11
|
+
# here. The conversion of these attributes into a OS build specific file is
|
|
12
|
+
# done by derived classes in the OS specific directories.
|
|
13
|
+
class Network < Base
|
|
14
|
+
|
|
15
|
+
# Specify attributes
|
|
16
|
+
attr_accessor :interface
|
|
17
|
+
attr_accessor :ip
|
|
18
|
+
attr_accessor :mask
|
|
19
|
+
attr_accessor :gateway
|
|
20
|
+
attr_accessor :dns
|
|
21
|
+
attr_accessor :register
|
|
22
|
+
attr_accessor :type
|
|
23
|
+
|
|
24
|
+
# Constants
|
|
25
|
+
IPV4 = 1
|
|
26
|
+
IPV6 = 2
|
|
27
|
+
STATIC = 4
|
|
28
|
+
|
|
29
|
+
# Documentation for this class
|
|
30
|
+
def self.doc_file
|
|
31
|
+
PackerFiles.DirPath('Core/example/Network.txt').first
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Constructor to just specify accessor varibales
|
|
35
|
+
def initialize
|
|
36
|
+
@dns = []
|
|
37
|
+
yield self if block_given?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Helper function to check if a static IP address is configured.
|
|
41
|
+
def is_static?
|
|
42
|
+
return ((@type & STATIC) > 0 )
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Normalize the various values into something useful. The
|
|
46
|
+
# default implementation checks only errors
|
|
47
|
+
def normalize
|
|
48
|
+
raise NilException.new(self, 'interface') if @interface.nil?
|
|
49
|
+
raise NilException.new(self, 'type') if @type.nil?
|
|
50
|
+
raise 'Mixing IPV4 and IPV6' if ((@type & IPV4) > 0) && ((@type & IPV6) > 0)
|
|
51
|
+
if ( (@type & STATIC) > 0 )
|
|
52
|
+
raise NilException.new(self, 'ip') if @ip.nil?
|
|
53
|
+
raise NilException.new(self, 'mask') if @mask.nil?
|
|
54
|
+
raise NilException.new(self, 'gateway') if @gateway.nil?
|
|
55
|
+
raise NilException.new(self, 'dns') if @dns.nil?
|
|
56
|
+
raise EmptyArrayException.new(self, 'dns') if @dns.empty?
|
|
57
|
+
else
|
|
58
|
+
@register = true
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end # Core
|
|
65
|
+
|
|
66
|
+
end # PackerFiles
|
|
67
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Requires
|
|
2
|
+
require_relative 'Base'
|
|
3
|
+
|
|
4
|
+
module PackerFiles
|
|
5
|
+
|
|
6
|
+
module Core
|
|
7
|
+
|
|
8
|
+
# The Package class handles various packages that needs to be installed
|
|
9
|
+
# as part of the initial system setup
|
|
10
|
+
class Packages < Base
|
|
11
|
+
|
|
12
|
+
# Specify attributes
|
|
13
|
+
attr_accessor :list
|
|
14
|
+
|
|
15
|
+
# Documentation for this class
|
|
16
|
+
def self.doc_file
|
|
17
|
+
PackerFiles.DirPath('Core/example/Packages.txt').first
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Constructor to just specify accessor varibales
|
|
21
|
+
def initialize
|
|
22
|
+
@list = []
|
|
23
|
+
yield self if block_given?
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end # Core
|
|
29
|
+
|
|
30
|
+
end # PackerFiles
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
# Requires
|
|
3
|
+
require_relative 'Base'
|
|
4
|
+
require_relative 'Exceptions'
|
|
5
|
+
|
|
6
|
+
module PackerFiles
|
|
7
|
+
|
|
8
|
+
module Core
|
|
9
|
+
|
|
10
|
+
# Define the Partition class that can handle Partition specified in a Packerfile.
|
|
11
|
+
# Just the barebones attributes that are required for this class are specified
|
|
12
|
+
# here. The conversion of these attributes into a OS build specific file is
|
|
13
|
+
# done by derived classes in the OS specific directories.
|
|
14
|
+
class Partition < Base
|
|
15
|
+
|
|
16
|
+
# Specify attributes
|
|
17
|
+
attr_accessor :boot
|
|
18
|
+
attr_accessor :label
|
|
19
|
+
attr_accessor :size
|
|
20
|
+
attr_accessor :mount_point
|
|
21
|
+
attr_accessor :file_system
|
|
22
|
+
attr_accessor :name
|
|
23
|
+
|
|
24
|
+
# Constructor to just specify accessor varibales
|
|
25
|
+
def initialize
|
|
26
|
+
@boot = false
|
|
27
|
+
@size = 0
|
|
28
|
+
yield self if block_given?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Normalize the values
|
|
32
|
+
def normalize
|
|
33
|
+
raise NilException.new(self, 'name') if @name.nil?
|
|
34
|
+
raise 'size cannot be zero' if @size == 0
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end # Partition
|
|
38
|
+
|
|
39
|
+
end # Core
|
|
40
|
+
|
|
41
|
+
end # PackerFiles
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
# Requires
|
|
3
|
+
require_relative 'Base'
|
|
4
|
+
require_relative 'Exceptions'
|
|
5
|
+
require 'Utils/AutoZone'
|
|
6
|
+
|
|
7
|
+
module PackerFiles
|
|
8
|
+
module Core
|
|
9
|
+
|
|
10
|
+
# Define the TimeZone class that can handle TimeZone specified in a Packerfile.
|
|
11
|
+
# Just the barebones attributes that are required for this class are specified
|
|
12
|
+
# here. The conversion of these attributes into a OS build specific file is
|
|
13
|
+
# done by derived classes in the OS specific directories.
|
|
14
|
+
class TimeZone < Base
|
|
15
|
+
|
|
16
|
+
# Specify attributes
|
|
17
|
+
attr_accessor :utc
|
|
18
|
+
attr_accessor :zone
|
|
19
|
+
attr_accessor :auto
|
|
20
|
+
|
|
21
|
+
# Documentation for this class
|
|
22
|
+
def self.doc_file
|
|
23
|
+
PackerFiles.DirPath('Core/example/TimeZone.txt').first
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Constructor to just specify accessor varibales
|
|
27
|
+
def initialize
|
|
28
|
+
@utc = true
|
|
29
|
+
yield self if block_given?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Normalize the various values into something useful. The
|
|
33
|
+
# default implementation checks only errors
|
|
34
|
+
def normalize
|
|
35
|
+
raise NilException.new(self, 'zone') if @zone.nil? && @auto.nil?
|
|
36
|
+
if (@zone.nil? && @auto)
|
|
37
|
+
@zone = Utils::AutoZone.new.time_zone
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end # TimeZone
|
|
42
|
+
|
|
43
|
+
end # Core
|
|
44
|
+
|
|
45
|
+
end # PackerFiles
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
# Requires
|
|
3
|
+
require_relative 'Base'
|
|
4
|
+
require_relative 'Exceptions'
|
|
5
|
+
|
|
6
|
+
module PackerFiles
|
|
7
|
+
|
|
8
|
+
module Core
|
|
9
|
+
|
|
10
|
+
# Define the User class that can handle User specified in a Packerfile.
|
|
11
|
+
# Just the barebones attributes that are required for this class are specified
|
|
12
|
+
# here. The conversion of these attributes into a OS build specific file is
|
|
13
|
+
# done by derived classes in the OS specific directories.
|
|
14
|
+
class User < Base
|
|
15
|
+
|
|
16
|
+
# Specify attributes
|
|
17
|
+
attr_accessor :login
|
|
18
|
+
attr_accessor :name
|
|
19
|
+
attr_accessor :password
|
|
20
|
+
attr_accessor :uid
|
|
21
|
+
attr_accessor :groups
|
|
22
|
+
|
|
23
|
+
# Documentation for this class
|
|
24
|
+
def self.doc_file
|
|
25
|
+
PackerFiles.DirPath('Core/example/User.txt').first
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Constructor to just specify accessor varibales
|
|
29
|
+
def initialize
|
|
30
|
+
@groups = []
|
|
31
|
+
yield self if block_given?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Normalize the various values into something useful. The
|
|
35
|
+
# default implementation checks only errors
|
|
36
|
+
def normalize
|
|
37
|
+
raise NilException.new(self, 'login') if @login.nil?
|
|
38
|
+
raise NilException.new(self, 'name') if @name.nil?
|
|
39
|
+
raise NilException.new(self, 'password') if @password.nil?
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end # Core
|
|
45
|
+
|
|
46
|
+
end # PackerFiles
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
# Requires
|
|
3
|
+
require_relative 'Base'
|
|
4
|
+
require_relative 'LogicalVolume'
|
|
5
|
+
|
|
6
|
+
module PackerFiles
|
|
7
|
+
|
|
8
|
+
module Core
|
|
9
|
+
|
|
10
|
+
# Volume Group abstracts out LVM.
|
|
11
|
+
class VolumeGroup < Base
|
|
12
|
+
|
|
13
|
+
# Specify attributes
|
|
14
|
+
attr_accessor :name
|
|
15
|
+
attr_accessor :disk_names
|
|
16
|
+
attr_accessor :lvs
|
|
17
|
+
|
|
18
|
+
# Constructor to just specify accessor varibales
|
|
19
|
+
def initialize
|
|
20
|
+
@disk_names = []
|
|
21
|
+
@lvs = []
|
|
22
|
+
yield self if block_given?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Adds a Logical volume on this disk by doing an instance-eval
|
|
26
|
+
def LogicalVolume(&block)
|
|
27
|
+
if block_given?
|
|
28
|
+
lv = LogicalVolume.new
|
|
29
|
+
lv.instance_eval &block
|
|
30
|
+
lv.name = 'lv' + @lvs.size.to_s if (lv.name.nil?)
|
|
31
|
+
@lvs.push(lv)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Normalize the various values into something useful
|
|
36
|
+
def normalize
|
|
37
|
+
raise 'name is nil' if @name.nil?
|
|
38
|
+
raise 'Disk names is empty' if @disk_names.empty?
|
|
39
|
+
raise 'LVs is empty' if @lvs.empty?
|
|
40
|
+
@lvs.each {|lv|
|
|
41
|
+
lv.vg_name= @name
|
|
42
|
+
lv.normalize
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end # Core
|
|
49
|
+
|
|
50
|
+
end # PackerFiles
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
# Define CD Image Configuration for this OS
|
|
3
|
+
<% if @obj.nil? -%>
|
|
4
|
+
#os.<%= @name -%> do |CD|
|
|
5
|
+
<% else -%>
|
|
6
|
+
os.<%= @name -%> do |CD|
|
|
7
|
+
<% end -%>
|
|
8
|
+
|
|
9
|
+
# Architecture [i386, amd64..]. This is a mandatory Parameter.
|
|
10
|
+
<% if @obj.nil? || @obj.arch.nil? -%>
|
|
11
|
+
#CD.arch = 'amd64'
|
|
12
|
+
<% else -%>
|
|
13
|
+
CD.arch = '<%= @obj.arch -%>'
|
|
14
|
+
<% end -%>
|
|
15
|
+
|
|
16
|
+
# Release Version of the OS [current, 7.0.5, 6.0.9]
|
|
17
|
+
<% if @obj.nil? || @obj.release.nil? -%>
|
|
18
|
+
#CD.release = 'current'
|
|
19
|
+
<% else -%>
|
|
20
|
+
CD.release = '<%= @obj.release -%>'
|
|
21
|
+
<% end -%>
|
|
22
|
+
|
|
23
|
+
# ISO Name Pattern. It is a file pattern that can be matched by looking
|
|
24
|
+
# at the index URL.
|
|
25
|
+
# But it can be overriden.
|
|
26
|
+
<% if @obj.nil? || @obj.iso_name_pattern.nil? -%>
|
|
27
|
+
#CD.iso_name_pattern = "debian-.*-#{arch}-CD-1.iso"
|
|
28
|
+
<% else -%>
|
|
29
|
+
CD.iso_name_pattern = '<%= @obj.iso_name_pattern -%>'
|
|
30
|
+
<% end -%>
|
|
31
|
+
|
|
32
|
+
# Checksum Name Pattern. It is a file pattern that can be matched by looking
|
|
33
|
+
# at the index URL.
|
|
34
|
+
# But it can be overriden.
|
|
35
|
+
<% if @obj.nil? || @obj.check_sum_pattern.nil? -%>
|
|
36
|
+
#CD.check_sum_pattern = "MD5SUMS"
|
|
37
|
+
<% else -%>
|
|
38
|
+
CD.check_sum_pattern = '<%= @obj.check_sum_pattern -%>'
|
|
39
|
+
<% end -%>
|
|
40
|
+
|
|
41
|
+
# Checksum Name Type.
|
|
42
|
+
<% if @obj.nil? || @obj.check_sum_type.nil? -%>
|
|
43
|
+
#CD.check_sum_type = "md5"
|
|
44
|
+
<% else -%>
|
|
45
|
+
CD.check_sum_type = '<%= @obj.check_sum_type -%>'
|
|
46
|
+
<% end -%>
|
|
47
|
+
|
|
48
|
+
# Index URL. List of URLs that needs to be searched for the CheckSUm Name pattern
|
|
49
|
+
# and ISO Name Pattern.
|
|
50
|
+
<% if @obj.nil? || @obj.index_urls.nil? -%>
|
|
51
|
+
#CD.index_urls = ["http://cdimage.debian.org/debian-cd/#{release}/#{arch}/iso-cd/",
|
|
52
|
+
# "http://cdimage.debian.org/mirror/cdimage/archive/#{@release}/#{@arch}/iso-cd/"]
|
|
53
|
+
<% else -%>
|
|
54
|
+
CD.index_urls = <%= @obj.index_urls.to_s %>
|
|
55
|
+
<% end -%>
|
|
56
|
+
|
|
57
|
+
# ISO URL. This is deduced from other parameters above. But it can be overriden.
|
|
58
|
+
<% if @obj.nil? || @obj.iso_url.nil? -%>
|
|
59
|
+
#CD.iso_url = "http://cdimage.debian.org/debian-cd/#{release}/#{arch}/iso-cd/abc.iso"
|
|
60
|
+
<% else -%>
|
|
61
|
+
CD.iso_url = '<%= @obj.iso_url -%>'
|
|
62
|
+
<% end -%>
|
|
63
|
+
|
|
64
|
+
# Checksum. This is deduced from arch and release values, but can be overriden.
|
|
65
|
+
<% if @obj.nil? || @obj.check_sum.nil? -%>
|
|
66
|
+
#CD.check_sum = ''
|
|
67
|
+
<% else -%>
|
|
68
|
+
CD.check_sum = '<%= @obj.check_sum -%>'
|
|
69
|
+
<% end -%>
|
|
70
|
+
|
|
71
|
+
<% if @obj.nil? -%>
|
|
72
|
+
#end
|
|
73
|
+
<% else -%>
|
|
74
|
+
end
|
|
75
|
+
<% end -%>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
# Define Disks for this OS
|
|
3
|
+
<% if @obj.nil? -%>
|
|
4
|
+
#os.<%= @name -%> do |disk|
|
|
5
|
+
<% else -%>
|
|
6
|
+
os.<%= @name -%> do |disk|
|
|
7
|
+
<% end -%>
|
|
8
|
+
|
|
9
|
+
# The Name of the disk. This is mandatory, even though it is
|
|
10
|
+
# only useful for some Operating Systems.
|
|
11
|
+
<% if @obj.nil? || @obj.name.nil? -%>
|
|
12
|
+
#disk.name = 'sda'
|
|
13
|
+
<% else -%>
|
|
14
|
+
disk.name = '<%= @obj.name -%>'
|
|
15
|
+
<% end -%>
|
|
16
|
+
|
|
17
|
+
# The Size of the disk. It can be specified in the form
|
|
18
|
+
# 'GiB', 'GB', 'MB', 'MiB', 'TB', 'TiB'
|
|
19
|
+
<% if @obj.nil? || @obj.size.nil? -%>
|
|
20
|
+
#disk.size = '20GiB'
|
|
21
|
+
<% else -%>
|
|
22
|
+
disk.size = '<%= @obj.size -%>'
|
|
23
|
+
<% end -%>
|
|
24
|
+
|
|
25
|
+
<% if @obj.nil? -%>
|
|
26
|
+
#end
|
|
27
|
+
<% else -%>
|
|
28
|
+
end
|
|
29
|
+
<% end -%>
|