Skip to content

Commit

Permalink
fixup Fixes #36495 - Extend Windows templates for Puppet and Ansible
Browse files Browse the repository at this point in the history
Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
  • Loading branch information
nadjaheitmann and ekohl committed Jul 3, 2024
1 parent 7b81e5e commit bf8664d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ w32tm /resync
<% if host_param('computerDomain') -%>
<% if host_param('domainAdminAccount').present? && host_param('domainAdminAccountPasswd').present? -%>
echo Performing secure domain join
powershell.exe -OutputFormat text -command Add-Computer -DomainName '<%= host_param('computerDomain') -%>' -Credential (New-Object -TypeName System.Management.Automation.PSCredential '<%= host_param('domainAdminAccount') -%>', (ConvertTo-SecureString -String '<%= host_param('domainAdminAccountPasswd') -%>' -AsPlainText -Force)) <% if host_param('computerOU').present? -%>-OUPath '<%= host_param('computerOU') -%>'<% end -%>
powershell.exe -OutputFormat text -command Add-Computer -DomainName '<%= host_param('computerDomain') -%>' -Credential (New-Object -TypeName System.Management.Automation.PSCredential '<%= host_param('domainAdminAccount') -%>', (ConvertTo-SecureString -String '<%= host_param('domainAdminAccountPasswd') -%>' -AsPlainText -Force))<% if host_param('computerOU').present? -%> -OUPath '<%= host_param('computerOU') -%>'<% end -%>
<% else -%>
<% if host_param('machinePassword').present? -%>
echo Performing unsecure domain join
Expand Down Expand Up @@ -106,9 +106,9 @@ cmd /c "netsh advfirewall firewall set rule group=\"remotedesktop\" new enable=Y
<% if puppet_enabled -%>
echo Downloading Puppet installer
wget "<%= host_param('win_puppet_source') %>" -O C:\puppet-agent-x64-latest.msi
wget "<%= host_param('win_puppet_source') %>" -O C:\puppet-agent-latest.msi
echo Installing Puppet
start /w "" msiexec /qn /i C:\puppet-agent-x64-latest.msi PUPPET_AGENT_STARTUP_MODE=Manual PUPPET_SERVER=<%= host_puppet_server -%> PUPPET_CA_SERVER=<%= host_puppet_ca_server -%> PUPPET_AGENT_ACCOUNT_DOMAIN=<%= @host.domain -%> PUPPET_AGENT_ACCOUNT_USER=administrator PUPPET_AGENT_ACCOUNT_PASSWORD="<%= host_param('domainAdminAccountPasswd') -%>"
start /w "" msiexec /qn /i C:\puppet-agent-latest.msi PUPPET_AGENT_STARTUP_MODE=Manual PUPPET_SERVER=<%= host_puppet_server -%> PUPPET_CA_SERVER=<%= host_puppet_ca_server -%> PUPPET_AGENT_ACCOUNT_DOMAIN=<%= @host.domain -%> PUPPET_AGENT_ACCOUNT_USER=administrator PUPPET_AGENT_ACCOUNT_PASSWORD="<%= host_param('domainAdminAccountPasswd') -%>"
echo Setting Puppet to auto start
sc config puppet start= auto
sc query puppet
Expand All @@ -130,7 +130,7 @@ rd /s /q c:\updates

<% if puppet_enabled -%>
echo Removing Puppet installer
sdelete.exe -accepteula -p 2 C:\puppet-agent-x64-latest.msi
sdelete.exe -accepteula -p 2 C:\puppet-agent-latest.msi
<% end -%>

echo Removing deploy directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ description: |
<Value><%= root_pass %></Value>
<PlainText>false</PlainText>
</AdministratorPassword>
<% if host_param('ansible_user') and host_param('create_ansible_user') -%>
<% if host_param('ansible_user') && host_param('create_ansible_user') -%>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ description: |
-%>
<%
iface = @host.provision_interface
proxy_uri = host_param('http-proxy') ? "#{host_param('http-proxy')}:#{host_param('http-proxy-port')}" : nil
proxy_uri = host_param('http-proxy') ? "#{host_param('http-proxy')}:#{host_param('http-proxy-port', 3128)}" : nil
proxy_string = proxy_uri ? "-e http_proxy=#{proxy_uri}" : ''
%>
@setlocal enableextensions enabledelayedexpansion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ identity:
- "<%= powershell %> -NonInteractive -Command \"winrm set winrm/config/service/auth '@{Certificate=\\\"true\\\"}'\""
<% end %>
<% if puppet_enabled %>
- "<%= powershell %> -Command \"invoke-webrequest -Uri <%= host_param('win_puppet_source') %> -OutFile C:\\puppet-agent-x64-latest.msi\""
- "<%= powershell %> -Command \"invoke-webrequest -Uri <%= host_param('win_puppet_source') %> -OutFile C:\\puppet-agent-latest.msi\""
- "<%= powershell %> -Command \"md C:\\ProgramData\\PuppetLabs\\puppet\\etc\""
- "<%= powershell %> -Command \"echo \"[main]\" | out-file C:\\ProgramData\\PuppetLabs\\puppet\\etc\\puppet.conf -encoding utf8\""
- "<%= powershell %> -Command \"echo \"server=http://<%= foreman_server_fqdn %>:8000/unattended/built?token=cae2cc74-1394-4acb-ad16-1011020b9bbe\" | add-content C:\\ProgramData\\PuppetLabs\\puppet\\etc\\puppet.conf -encoding utf8\""
- "<%= powershell %> -Command \"echo \"autoflush=true\" | add-content C:\\ProgramData\\PuppetLabs\\puppet\\etc\\puppet.conf -encoding utf8\""
- "<%= powershell %> -Command \"start /wait \"\" msiexec /qn /norestart /i C:\\puppet-agent-x64-latest.msi PUPPET_MASTER_SERVER=<%= @host.puppet_server %>\""
- "<%= powershell %> -Command \"sdelete.exe -accepteula -p 2 C:\\puppet-agent-x64-latest.msi\""
- "<%= powershell %> -Command \"start /wait \"\" msiexec /qn /norestart /i C:\\puppet-agent-latest.msi PUPPET_MASTER_SERVER=<%= @host.puppet_server %>\""
- "<%= powershell %> -Command \"sdelete.exe -accepteula -p 2 C:\\puppet-agent-latest.msi\""
<% end %>
guiUnattended:
autoLogon: true
Expand Down
2 changes: 1 addition & 1 deletion test/factories/operatingsystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
title { 'Windows 10' }
architectures { [FactoryBot.build(:architecture, :for_snapshots_x86_64)] }
media { [FactoryBot.build(:windows_for_snapshots)] }
ptables { [FactoryBot.build(:ptable, name: 'ptable')] }
ptables { [FactoryBot.build(:ptable, :windows)] }
end

factory :altlinux, class: Altlinux do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ powershell /c "Get-NetConnectionProfile -InterfaceAlias \"Ethernet0\" | Set-NetC


echo Downloading Puppet installer
wget "" -O C:\puppet-agent-x64-latest.msi
wget "" -O C:\puppet-agent-latest.msi
echo Installing Puppet
start /w "" msiexec /qn /i C:\puppet-agent-x64-latest.msi PUPPET_AGENT_STARTUP_MODE=Manual PUPPET_SERVER= PUPPET_CA_SERVER= PUPPET_AGENT_ACCOUNT_DOMAIN=snap.example.com PUPPET_AGENT_ACCOUNT_USER=administrator PUPPET_AGENT_ACCOUNT_PASSWORD=""
start /w "" msiexec /qn /i C:\puppet-agent-latest.msi PUPPET_AGENT_STARTUP_MODE=Manual PUPPET_SERVER= PUPPET_CA_SERVER= PUPPET_AGENT_ACCOUNT_DOMAIN=snap.example.com PUPPET_AGENT_ACCOUNT_USER=administrator PUPPET_AGENT_ACCOUNT_PASSWORD=""
echo Setting Puppet to auto start
sc config puppet start= auto
sc query puppet
Expand All @@ -70,7 +70,7 @@ rd /s /q c:\drivers
rd /s /q c:\updates

echo Removing Puppet installer
sdelete.exe -accepteula -p 2 C:\puppet-agent-x64-latest.msi
sdelete.exe -accepteula -p 2 C:\puppet-agent-latest.msi

echo Removing deploy directory
rd /s /q c:\deploy
Expand Down

0 comments on commit bf8664d

Please sign in to comment.