vagrant-em-demos 0.1.1 → 0.1.3

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: 70f385ca856f975c9f6909252cbe797b70b84633fafd9bda8d488f95284dbcee
4
- data.tar.gz: caf5c2e2c578904372fa3f0d5d6593f2a269a73412dadbfdde63979bd74f3b18
3
+ metadata.gz: f4a5fd66288ee40ae7d33f431cddf6fb61c3774a245819b2283787da1fe41703
4
+ data.tar.gz: ea221549e9633223c828483fd03bb47d1122de446c6c2065f7a8343f5fb22413
5
5
  SHA512:
6
- metadata.gz: 0c09a1f155ff3decd1bd47f3dc961b6b855c7a460c5d3217edb70744ccb47d9c1960c7dc1d875034f851380b2a28e17b4538df7a3b1400f644d4538aa7378ce2
7
- data.tar.gz: f4a231c1a5c963bcf9e6d0d17cc18c90240662815847a20268366ad3c4d8c8eb1ec12306e3b8a10dbfa8b8a34716666cc4f027ce998060f99984d2bd8168cee5
6
+ metadata.gz: ebd25994d52628f7e8ba12888575f0f50028a9223b5e691deeceb20deb52737f535286b803a611c8ca9bf24018867f7316f8e6eecb7dc9b09340a0f2d352ab8f
7
+ data.tar.gz: e3307eb2d5d9038c2fa97055f48d2659f3566d1a1fd853806750b15692693eab3bc4fa4f5c2cb0204a81e01d970417f4ea5561539ff4097166c0ffe7075024c0
@@ -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
@@ -90,6 +119,7 @@ module Vagrant
90
119
  def environment_variables
91
120
  env = {}
92
121
  env.merge!("CI_TOKEN" => ENV["CI_JOB_TOKEN"]) if ENV["CI_JOB_TOKEN"]
122
+ env.merge!("RUN_R10K" => @model.run_r10k)
93
123
  env
94
124
  end
95
125
 
@@ -98,8 +128,9 @@ module Vagrant
98
128
  facter_overrides = facts.map { |key, value| "export FACTER_#{key}=\\\"#{value}\\\"" }.join('\n')
99
129
  'echo -e "' + facter_overrides + '" > /etc/profile.d/facter_overrides.sh'
100
130
  else
101
- facter_overrides = facts.map { |key, value| "Write-Host #{key}=#{value}" }.join("`r")
102
- '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
103
134
  end
104
135
  end
105
136
 
@@ -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
 
@@ -29,13 +29,19 @@ else
29
29
  echo "Using released versions of modules..."
30
30
  PUPPETFILE="Puppetfile"
31
31
  fi
32
- #
33
- # Check if the Puppetfile exists before installing
34
- #
35
- if [ -f ${PUPPETFILE} ]; then
36
- /opt/puppetlabs/puppet/bin/r10k puppetfile install --puppetfile ${PUPPETFILE} --force > /dev/null # 2>&1
32
+
33
+ # Check if RUN_R10K is set to true before proceeding
34
+ if [ "$RUN_R10K" = "true" ]; then
35
+ #
36
+ # Check if the Puppetfile exists before installing
37
+ #
38
+ if [ -f ${PUPPETFILE} ]; then
39
+ /opt/puppetlabs/puppet/bin/r10k puppetfile install --puppetfile ${PUPPETFILE} --force > /dev/null # 2>&1
40
+ else
41
+ echo "Warning: ${PUPPETFILE} not found. Proceeding without module installation."
42
+ fi
37
43
  else
38
- echo "Warning: ${PUPPETFILE} not found. Proceeding without module installation."
44
+ echo "RUN_R10K is not set to true. Skipping r10k puppetfile install."
39
45
  fi
40
46
 
41
47
  #
@@ -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.1
4
+ version: 0.1.3
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-18 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