Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36495 - Extend Windows templates for Puppet and Ansible #9732

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

nadjaheitmann
Copy link
Contributor

No description provided.

@nadjaheitmann nadjaheitmann force-pushed the 36495_extend_windows_support branch 4 times, most recently from 84db3dc to e589d01 Compare June 9, 2023 11:30
@nadjaheitmann nadjaheitmann changed the title Fixes #36945 - Extend Windows templates for Puppet and Ansible Fixes #36495 - Extend Windows templates for Puppet and Ansible Jun 9, 2023
@nadjaheitmann nadjaheitmann force-pushed the 36495_extend_windows_support branch 4 times, most recently from 1cf378d to fdee96a Compare June 29, 2023 12:19
-%>
<%
system_locale = host_param('systemLocale') ? host_param('systemLocale') : 'en-US'
system_ui_lang = host_param('systemUILanguage') ? host_param('systemUILanguage') : 'en-US'
setup_ui_lang = 'en-US'
input_locale = host_param('inputLocale') ? host_param('inputLocale'): 'de-DE'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really want to set the german keyboard-layout as the default?
I would use the en-US one as default for the foreman-community

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, thanks!

@nadjaheitmann
Copy link
Contributor Author

@ekohl Anything else that should be improved?

@nadjaheitmann nadjaheitmann force-pushed the 36495_extend_windows_support branch 2 times, most recently from cf9b139 to 46f0184 Compare October 26, 2023 12:02
@nadjaheitmann
Copy link
Contributor Author

@ekohl @sbernhard Can we move forward here?

echo Configuring Puppet
mkdir "C:\ProgramData\PuppetLabs\puppet\etc"
echo [main] > "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
echo server=http://<%= @host.puppetmaster %> >> "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shouldn't be needed (see below), but if it is: server is the hostname, there's no protocol. Also, puppet_puppet_server is the current macro. `@host.puppetmaster is deprecated.

Suggested change
echo server=http://<%= @host.puppetmaster %> >> "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
echo server=<%= host_puppet_server %> >> "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"

Comment on lines 115 to 116
mkdir "C:\ProgramData\PuppetLabs\puppet\etc"
echo [main] > "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed now? I suspected the puppet.msi (which is still there) would be sufficient.

echo [main] > "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
echo server=http://<%= @host.puppetmaster %> >> "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
echo autoflush=true >> "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
echo Installing Puppet
start /w "" msiexec /qn /i C:\extras\puppet.msi PUPPET_AGENT_STARTUP_MODE=Manual PUPPET_MASTER_SERVER=<%= host_puppet_server -%> PUPPET_AGENT_ACCOUNT_DOMAIN=<%= @host.domain -%> PUPPET_AGENT_ACCOUNT_USER=administrator PUPPET_AGENT_ACCOUNT_PASSWORD="<%= host_param('domainAdminAccountPasswd') -%>"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect PUPPET_MASTER_SERVER is wrong here. Reading https://www.puppet.com/docs/puppet/7/install_agents#msi_properties I think it should be:

Suggested change
start /w "" msiexec /qn /i C:\extras\puppet.msi PUPPET_AGENT_STARTUP_MODE=Manual PUPPET_MASTER_SERVER=<%= host_puppet_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:\extras\puppet.msi PUPPET_AGENT_STARTUP_MODE=Manual PUPPET_SERVER=<%= host_puppet_server -%> PUPPET_AGENT_ACCOUNT_DOMAIN=<%= @host.domain -%> PUPPET_AGENT_ACCOUNT_USER=administrator PUPPET_AGENT_ACCOUNT_PASSWORD="<%= host_param('domainAdminAccountPasswd') -%>"

It should also set PUPPET_CA_SERVER=<%= host_puppet_ca_server>%.

mkdir "C:\ProgramData\PuppetLabs\puppet\etc"
echo [main] > "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
echo server=http://<%= @host.puppetmaster %> >> "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
echo autoflush=true >> "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to look this up, but https://www.puppet.com/docs/puppet/7/configuration.html#autoflush says this should be default:

Suggested change
echo autoflush=true >> "C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf"

<% if puppet_enabled %>
echo Installing puppet
echo Downloading Puppet installer
wget "<%= host_param('win_puppet_source') %>" -O C:\puppet-agent-x64-latest.msi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match the path below (C:\extras\puppet.msi) so likely to cause problems.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consistently use -%>, at least for newly added blocks.

Comment on lines 73 to 76
<%#
Adjust power setting to 'High performance'
-%>
powershell /c "powercfg /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really appropriate for this PR? I can't speak for Windows admins since I rarely touch it, but doing this unconditionally may not be correct for users.

@nadjaheitmann
Copy link
Contributor Author

Please consistently use -%>, at least for newly added blocks.

Thanks, I'll try to unify the templates. Working on the other changes as well, thank you for your input! Highly appreciated!

@nadjaheitmann nadjaheitmann force-pushed the 36495_extend_windows_support branch 2 times, most recently from 2110b99 to 8f86591 Compare November 14, 2023 09:58
@nadjaheitmann
Copy link
Contributor Author

@ekohl I cleaned up the tags (hope I got them all) and modified the configurations in question. Right now, there are three commits for better visibility of the changes. Do you mind having another look?

@nadjaheitmann
Copy link
Contributor Author

@ekohl Anything else that needs fixing?

Nadja Heitmann and others added 4 commits June 10, 2024 12:52
Co-authored-by: Fabrice Brimioulle <brimioulle@atix.de>
Co-authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
Comment on lines +1 to +79


@echo off
echo Activating administrator
net user administrator /active:yes

set ctr=0
set nettimeout=10

@echo off
setlocal enableDelayedExpansion

for /f "delims=" %%a in ('ipconfig /all') do (
set line=%%a
if not "!line:~0,1!"==" " if not "!line:adapter=!"=="!line!" (
set name=!line:*adapter =!
set name=!name::=!
)

for /f "tokens=1,2,*" %%b in ("%%a") do (
if "%%b %%c"=="Physical Address." (
set mac=%%d
set mac=!mac:*: =!
set mac=!mac:-=:!
call :tolower mac

)
)
)
call :done

:tolower
for %%L IN (a b c d e f g h i j k l m n o p q r s t u v w x y z) DO SET %1=!%1:%%L=%%L!
goto :EOF

:done



echo Syncing time
w32tm /resync
w32tm /resync




powershell /c "Get-NetConnectionProfile -InterfaceAlias \"Ethernet0\" | Set-NetConnectionProfile -NetworkCategory Private"




echo Downloading Puppet installer
wget "" -O C:\puppet-agent-x64-latest.msi
echo Installing Puppet
start /w "" msiexec /qn /i C:\puppet-agent-x64-latest.msi PUPPET_AGENT_STARTUP_MODE=Manual PUPPET_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

echo Rebooting in 60 sec
shutdown /r /t 60

echo Removing wimaging files
rd /s /q c:\wimaging
sdelete.exe -accepteula -p 2 c:\Windows\Panther\unattend.xml
sdelete.exe -accepteula -p 2 C:\Windows\Setup\Scripts\SetupComplete.cmd

echo Removing leftover directories
rd /s /q c:\MININT
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

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


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation-wise, this template snapshot looks kind of funny....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants