vagrant-em-demos 0.1.2 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21c3e538f2ab4b80fa8a4cbf1dcdaed90e7e5fc560d69f9ed7296b35927c601a
4
- data.tar.gz: 492105d1889db7d7ac78a3845600f501c02f178c255875338a8c49bf3c8a750e
3
+ metadata.gz: d93441ea0a868529a8c1a23ca4a1e707eae1b6f9b5e876444a0c3fc307f5b5a6
4
+ data.tar.gz: fd57329ddbdd16ac09af4ddc27c9490527861372f2180d2f6ea2d414dbe07b26
5
5
  SHA512:
6
- metadata.gz: eb4d0df0a36f2cad0919bfb2f9c6c0830cd93bd97a9adf3dc6f91a8b0af15edb6e88f337324840f06b912c54ff19bef35adf16d14b64aa75cf0eecc7317a0c2c
7
- data.tar.gz: 51534f0bf9994a5e92cbb5595b66e0df8194baca7e699da6326a0f998c997c4898a0184121df920daabab684d99300bb3140815f0a4cbd0c94921d11c8319139
6
+ metadata.gz: f444b085abd617f086ff33f7cf07f08922150d33e2738464f9205c7762ec485681a0f5ef59eb1ed655586b352868b00c52a41acb4b8125c6eb296237032109d1
7
+ data.tar.gz: dc56f114fbccfba673747ebb869fd356683f3d6a35615142954d68f643e4d78b99a95a766cde4d9c4655f2154d834bab7ce365e2f9dc263725504732d6f53f65
@@ -4,6 +4,7 @@ module Vagrant
4
4
  class ConfigReader
5
5
  VALID_KEYS = [
6
6
  "dhcp_fix",
7
+ "own_dns"
7
8
  "public_ip",
8
9
  "private_ip",
9
10
  "domain_name",
@@ -13,6 +13,7 @@ defaults:
13
13
  virtualboxorafix: false
14
14
  required_plugins: []
15
15
  run_r10k: true
16
+ own_dns: false
16
17
  custom_facts:
17
18
  deployment_zone: vagrant
18
19
  #
@@ -33,7 +33,7 @@ module Vagrant
33
33
  :protocol, :disks, :additional_hosts, :custom_facts,
34
34
  :required_plugins, :software_files, :needs_storage,
35
35
  :virtualboxorafix, :dhcp_fix, :cluster, :run_r10k, :mount_uid,
36
- :mount_gid, :prefix, :ip_start_address, :ipaddress
36
+ :mount_gid, :prefix, :ip_start_address, :ipaddress, :own_dns
37
37
  ]
38
38
  attr_reader(*ATTRIBUTES)
39
39
  attr_accessor :generated_ip, :index, :vmname
@@ -51,13 +51,13 @@ module Vagrant
51
51
  end
52
52
  @name = name
53
53
  @index = index
54
- if ip_start_address
54
+ if public_ip
55
+ @ipaddress = @public_ip
56
+ else
57
+ fail "public_ip or ip_start_address is required for #{name}" unless ip_start_address
55
58
  adress_manager = VagrantPlugins::AdressManager.instance(ip_start_address)
56
59
  @generated_ip = adress_manager.register_node(fqdn)
57
60
  @ipaddress = @generated_ip
58
- else
59
- fail "priate_ip or ip_start_address is required"
60
- @ipaddress = @private_ip
61
61
  end
62
62
 
63
63
  initialize_disks(attributes["disks"])
@@ -23,10 +23,11 @@ module Vagrant
23
23
  configure_networking(@config, @vm, @model)
24
24
  if @model.protocol == "ssh"
25
25
  add_inline_shell_provisioner(hosts_file(@models, "linux"),"hosts_file")
26
+ add_inline_shell_provisioner(facter_overrides(@model.custom_facts, "linux"), 'facter_overrides') if @model.custom_facts
26
27
  else
27
28
  add_inline_shell_provisioner(hosts_file(@models, "windows"),"hosts_file")
29
+ facter_overrides(@model.custom_facts, "windows") if @model.custom_facts
28
30
  end
29
- add_inline_shell_provisioner(facter_overrides(@model.custom_facts, "linux"), 'facter_overrides') if @model.custom_facts
30
31
  end
31
32
 
32
33
  # Return a shell command that ensures that all vagrant hosts are in /etc/hosts
@@ -51,26 +52,54 @@ module Vagrant
51
52
  end
52
53
  commands << "echo 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 >> /etc/hosts"
53
54
  else
54
- commands = 'puppet apply c:\vagrant\windows_hosts_file.pp'
55
- win_hosts = ""
56
- vms.each do |vm|
57
- hostname = vm.hostname
58
- domain = vm.domain_name
59
- fqdn = "#{hostname}.#{domain}"
60
- win_hosts << "host { '#{fqdn}': ip => '#{vm.ipaddress}', host_aliases => '#{hostname}' }\n" if vm.ipaddress
61
- vm.additional_hosts&.each do |host|
62
- fqdn = "#{host.name}.#{host.domain_name}"
63
- win_hosts << "host { '#{fqdn}': ip => '#{host.ip}', host_aliases => '#{host.name}' }\n"
64
- end
55
+ # Create a PowerShell script with all commands
56
+ script_content = <<-EOT
57
+ # Remove existing 127.0.*.1 entries
58
+ $content = Get-Content 'C:\\Windows\\System32\\drivers\\etc\\hosts'
59
+ $newContent = $content | Where-Object { $_ -notmatch '127\\.0\\..*\\.1.*' }
60
+ $newContent | Set-Content 'C:\\Windows\\System32\\drivers\\etc\\hosts'
61
+ EOT
62
+
63
+ # Add each VM host entry
64
+ vms.each do |vm|
65
+ hostname = vm.hostname
66
+ domain = vm.domain_name
67
+ fqdn = "#{hostname}.#{domain}"
68
+ if vm.ipaddress
69
+ script_content += <<-EOT
70
+ # Add entry for #{fqdn}
71
+ if (-not (Select-String -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Pattern '#{fqdn}' -Quiet)) {
72
+ Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '#{vm.ipaddress} #{fqdn} #{hostname}'
73
+ }
74
+ EOT
75
+ end
76
+
77
+ # Add additional hosts
78
+ vm.additional_hosts&.each do |host|
79
+ fqdn = "#{host.name}.#{host.domain_name}"
80
+ script_content += <<-EOT
81
+ # Add entry for #{fqdn}
82
+ if (-not (Select-String -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Pattern '#{fqdn}' -Quiet)) {
83
+ Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '#{host.ip} #{fqdn} #{host.name}'
84
+ }
85
+ EOT
65
86
  end
66
- win_hosts = win_hosts.split("\n").uniq.join("\n")
67
- File.write(File.join(Dir.pwd, "windows_hosts_file.pp"), win_hosts)
87
+ end
88
+ # Add localhost entry at the end
89
+ script_content += <<-EOT
90
+ # Add localhost entry
91
+ Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4'
92
+ EOT
93
+
94
+ # Set the commands to just run this script
95
+ commands = script_content
68
96
  end
69
97
  commands
70
98
  end
71
99
 
72
100
  def add_inline_shell_provisioner(command, name=nil, env = nil)
73
101
  provisioner = {shell: {inline: command}}
102
+ provisioner[:shell][:privileged] = true
74
103
  provisioner[:shell][:env] = env if env
75
104
  provisioner[:shell][:name] = name if name
76
105
  @provisioners << provisioner
@@ -99,11 +128,23 @@ module Vagrant
99
128
  facter_overrides = facts.map { |key, value| "export FACTER_#{key}=\\\"#{value}\\\"" }.join('\n')
100
129
  'echo -e "' + facter_overrides + '" > /etc/profile.d/facter_overrides.sh'
101
130
  else
102
- facter_overrides = facts.map { |key, value| "Write-Host #{key}=#{value}" }.join("`r")
103
- 'echo "' + facter_overrides + '" > C:\ProgramData\PuppetLabs\facter\facts.d\facter_overrides.ps1'
131
+ facts.each do |key, value|
132
+ add_inline_shell_provisioner("[Environment]::SetEnvironmentVariable(\"FACTER_#{key}\", \"#{value}\", \"Machine\")")
133
+ end
104
134
  end
105
135
  end
106
136
 
137
+ # Fix setup for Oracle applications
138
+ def virtualboxorafix(vb)
139
+ vb.customize ['setextradata', :id, 'VBoxInternal/CPUM/HostCPUID/Cache/Leaf', '0x4']
140
+ vb.customize ['setextradata', :id, 'VBoxInternal/CPUM/HostCPUID/Cache/SubLeaf', '0x4']
141
+ vb.customize ['setextradata', :id, 'VBoxInternal/CPUM/HostCPUID/Cache/eax', '0']
142
+ vb.customize ['setextradata', :id, 'VBoxInternal/CPUM/HostCPUID/Cache/ebx', '0']
143
+ vb.customize ['setextradata', :id, 'VBoxInternal/CPUM/HostCPUID/Cache/ecx', '0']
144
+ vb.customize ['setextradata', :id, 'VBoxInternal/CPUM/HostCPUID/Cache/edx', '0']
145
+ vb.customize ['setextradata', :id, 'VBoxInternal/CPUM/HostCPUID/Cache/SubLeafMask', '0xffffffff']
146
+ end
147
+
107
148
  # Configure VirtualBox disks attached to the virtual machine
108
149
  def configure_disks(vb, model)
109
150
  vminfo = vm_info(model.name)
@@ -268,10 +309,15 @@ module Vagrant
268
309
  vb.cpus = model.cpucount || 1
269
310
  vb.memory = model.ram || 4096
270
311
  vb.name = model.vmname
271
- vb.auto_nat_dns_proxy = false
272
- vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
273
- vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
274
-
312
+ if model.own_dns
313
+ vb.auto_nat_dns_proxy = false
314
+ vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
315
+ vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
316
+ else
317
+ vb.auto_nat_dns_proxy = true
318
+ vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
319
+ vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
320
+ end
275
321
  virtualboxorafix(vb) if model.virtualboxorafix
276
322
 
277
323
  configure_disks(vb, model) if model.needs_storage
@@ -20,14 +20,11 @@ module Vagrant
20
20
  end
21
21
 
22
22
  def setup_windows
23
- add_shell_script_provisioner(facter_overrides(@model.custom_facts, "windows"), "always") if @model.custom_facts
24
- add_shell_script_provisioner(hosts_file(@models, "windows"))
25
- add_shell_script_provisioner(%(Set-ExecutionPolicy Bypass -Scope Process -Force
26
- cd c:\\vagrant\\vm-scripts
27
- .\\install_puppet.ps1
28
- cd c:\\vagrant\\vm-scripts
29
- .\\setup_puppet.ps1
30
- iex "& 'C:\\Program Files\\Puppet Labs\\Puppet\\bin\\puppet' resource service puppet ensure=stopped"))
23
+ configure_synced_folders(@config, @vm, @model, @model.mount_uid, @model.mount_gid)
24
+ facter_overrides(@model.custom_facts, "windows") if @model.custom_facts
25
+ add_shell_script_provisioner("install_puppet.ps1", [], environment_variables)
26
+ add_shell_script_provisioner("setup_puppet.ps1", [], environment_variables)
27
+ add_shell_script_provisioner("stop_puppet_service.ps1", [], environment_variables)
31
28
  add_puppet_provisioner(["vm", "c:\\vagrant\\manifests"], "site.pp", "--test")
32
29
  end
33
30
 
@@ -0,0 +1 @@
1
+ iex "& 'C:\\Program Files\\Puppet Labs\\Puppet\\bin\\puppet' resource service puppet ensure=stopped"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-em-demos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enterprise Modules
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-19 00:00:00.000000000 Z
11
+ date: 2025-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vagrant
@@ -85,7 +85,7 @@ files:
85
85
  - vm-scripts/run_puppet.ps1
86
86
  - vm-scripts/setup_puppet.ps1
87
87
  - vm-scripts/setup_puppet.sh
88
- - vm-scripts/setup_puppet_raw.ps1
88
+ - vm-scripts/stop_puppet_service.ps1
89
89
  homepage: https://github.com/enterprisemodules/vagrant-em-demos
90
90
  licenses:
91
91
  - MIT
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubygems_version: 3.5.23
110
+ rubygems_version: 3.5.16
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Custom provisioning Enterprise Modules demo's
@@ -1 +0,0 @@
1
- # To be implemented