Environment:
- PE Server: rich-tandem.delivery.puppetlabs.net (RedHat 8)
- Windows Agent: alma-woomera.delivery.puppetlabs.net (Windows 2022)
- Module: poc_dsc_replacement (MinimumPasswordLength implementation)
cd /Users/mehul.jain/work/modules/poc_dsc_replacement
# Build the tarball
pdk build
# Output should show:
# pdk (INFO): Building poc_dsc_replacement with pdk ...
# pdk (INFO): Module built: pkg/puppet-poc_dsc_replacement-0.1.0.tar.gz# Check what was packaged
tar -tzf pkg/puppet-poc_dsc_replacement-0.1.0.tar.gz | head -20
# Should include:
# - lib/puppet/type/securityoption.rb
# - lib/puppet/provider/securityoption/ruby.rb
# - lib/puppet_x/secedit.rb
# - lib/puppet_x/inf.rb
# - lib/puppet_x/security_policy/data.rb
# - spec/ (unit tests)# From your local machine, copy to the PE server
scp pkg/puppet-poc_dsc_replacement-0.1.0.tar.gz \
mehul.jain@rich-tandem.delivery.puppetlabs.net:/tmp/
# Verify transfer
ssh mehul.jain@rich-tandem.delivery.puppetlabs.net \
"ls -lh /tmp/puppet-poc_dsc_replacement-0.1.0.tar.gz"# SSH into PE server
ssh mehul.jain@rich-tandem.delivery.puppetlabs.net
# Extract to modules directory
sudo tar -xzf /tmp/puppet-poc_dsc_replacement-0.1.0.tar.gz -C /etc/puppetlabs/code/environments/production/modules/
# Verify installation
ls -la /etc/puppetlabs/code/environments/production/modules/poc_dsc_replacement/
# Should show:
# lib/
# spec/
# metadata.json
# README.md
# etc.# Run PDK validate on the installed module
cd /etc/puppetlabs/code/environments/production/modules/poc_dsc_replacement
sudo pdk validate
# Expected output:
# pdk (INFO): Running all available validators...
# pdk (INFO): Validator 'ruby-syntax' completed successfully
# pdk (INFO): Validator 'rubocop' completed successfully# From PE server, test agent connectivity
sudo puppet node list | grep alma-woomera
# Or from Windows agent (via SSH or WinRM):
# Test SSL certificate is trusted:
# Run on Windows agent:
# C:\Program Files\Puppet Labs\Puppet\bin\puppet agent --testOn PE Server, create test manifest:
# Create or edit the Windows agent's node classifier
# Option A: Using node classification (GUI)
# - Log into PE Console
# - Navigate to: Configuration > Classification
# - Find or create node group for alma-woomera
# Option B: Using code (preferred for testing)
cat > /etc/puppetlabs/code/environments/production/manifests/windows_test.pp << 'EOF'
# Test manifest for Windows security options
node 'alma-woomera.delivery.puppetlabs.net' {
# Include the poc_dsc_replacement module
include poc_dsc_replacement
# Test Case 1: Set MinimumPasswordLength to 14
securityoption { 'MinimumPasswordLength':
ensure => present,
value => '14',
}
# Test Case 2: Set MaximumPasswordAge to 90 days
# (This tests the data.rb mapping works correctly)
securityoption { 'MaximumPasswordAge':
ensure => present,
value => '90',
}
# Test Case 3: Set PasswordHistorySize to 24
securityoption { 'PasswordHistorySize':
ensure => present,
value => '24',
}
}
EOF
# Verify syntax
sudo puppet parser validate /etc/puppetlabs/code/environments/production/manifests/windows_test.pp
sudo systemctl restart pe-puppetserver
puppet agent -t
/opt/puppetlabs/bin/puppet resource --types | grep securityoption# If using site.pp instead
cat >> /etc/puppetlabs/code/environments/production/manifests/site.pp << 'EOF'
# Windows Security Options Test
node 'alma-woomera.delivery.puppetlabs.net' {
securityoption { 'MinimumPasswordLength':
ensure => present,
value => '14',
}
}
EOF
# Verify
sudo puppet parser validate /etc/puppetlabs/code/environments/production/manifests/site.pp
sudo systemctl restart pe-puppetserver
puppet agent -t
/opt/puppetlabs/bin/puppet resource --types | grep securityoption# Option A: SSH into Windows agent (if SSH enabled)
ssh Administrator@alma-woomera.delivery.puppetlabs.net
rm -rf /cygdrive/c/ProgramData/PuppetLabs/puppet/cache/lib/*
puppet.bat plugin download --verbose
# Run puppet agent manually
C:\Program Files\Puppet Labs\Puppet\bin\puppet agent --test --verbose
# Expected output:
# Notice: Starting Puppet client version 8.x.x
# Info: Caching catalog for alma-woomera.delivery.puppetlabs.net
# Info: Applying configuration version '...'
# Notice: /Stage[main]/... [resource_title] (notice)
# Info: Creating state file /var/lib/puppet/state/state.yaml
# Notice: Applied catalog in X.XX seconds# From PE server, check agent reports
sudo tail -100 /var/log/puppetlabs/puppetserver/puppetserver.log | grep alma-woomera
# Or view in PE Console:
# - Navigate to: Nodes > alma-woomera.delivery.puppetlabs.net
# - Check last report statusOn Windows Agent (alma-woomera), verify the settings were applied:
# Export current security policy
secedit /export /cfg %TEMP%\secpol_export.inf /areas SECURITYPOLICY
# View the exported file
notepad %TEMP%\secpol_export.inf
# Look for:
# [System Access]
# MinimumPasswordLength = 14
# MaximumPasswordAge = 90
# PasswordHistorySize = 24# Test 1: Check if minimum password length was set
$policy = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters" -Name MinimumPasswordLength -ErrorAction SilentlyContinue
if ($policy) {
Write-Host "MinimumPasswordLength is set to: $($policy.MinimumPasswordLength)"
} else {
Write-Host "MinimumPasswordLength not found in registry"
}
# Test 2: Export and parse the security policy
secedit /export /cfg C:\temp\policy.inf /areas SECURITYPOLICY
$content = Get-Content C:\temp\policy.inf
$content | Select-String "MinimumPasswordLength" | ForEach-Object {
Write-Host "Found: $_"
}
# Test 3: Check using net accounts (only shows local account policy)
net accounts
# Look for "Minimum password length"1. Open: Settings > Security Settings > Account Policies > Password Policy
2. Look for "Minimum password length"
3. Verify it shows "14 characters"
OR using secpol.msc:
1. Run: secpol.msc
2. Navigate: Security Settings > Account Policies > Password Policy
3. Verify: "Minimum password length" = 14
# Check if temporary INF files were created during Puppet run
dir C:\Windows\Temp\puppet*.inf
# If no longer present (cleaned up), check Puppet logs:
dir C:\ProgramData\PuppetLabs\puppet\var\log\puppet.log# View Puppet agent log
Get-Content C:\ProgramData\PuppetLabs\puppet\var\log\puppet.log -Tail 50
# Look for:
# Info: Applying configuration
# Notice: [resource_title] (notice)
# Notice: Applied catalog in X.XX seconds# From Windows agent (second run)
C:\Program Files\Puppet Labs\Puppet\bin\puppet agent --test
# Expected output:
# Notice: Using cached catalog
# Notice: Applied catalog in X.XX seconds
# (No resource changes should appear - idempotency confirmed)# Export policy again
secedit /export /cfg C:\temp\policy2.inf /areas SECURITYPOLICY
# Compare the exports
diff C:\temp\policy.inf C:\temp\policy2.inf
# Should show no differences (or only date/time stamps)On PE Server, update the manifest:
# Edit the manifest to change the password length
sudo cat > /etc/puppetlabs/code/environments/production/manifests/windows_test.pp << 'EOF'
node 'alma-woomera.delivery.puppetlabs.net' {
securityoption { 'MinimumPasswordLength':
ensure => present,
value => '12', # Changed from 14 to 12
}
}
EOF
# Verify syntax
sudo puppet parser validate /etc/puppetlabs/code/environments/production/manifests/windows_test.pp# Run Puppet agent on Windows
C:\Program Files\Puppet Labs\Puppet\bin\puppet agent --test
# Verify change in secedit
secedit /export /cfg C:\temp\policy3.inf /areas SECURITYPOLICY
findstr "MinimumPasswordLength" C:\temp\policy3.inf
# Should now show: MinimumPasswordLength = 12# Restore to original setting
sudo cat > /etc/puppetlabs/code/environments/production/manifests/windows_test.pp << 'EOF'
node 'alma-woomera.delivery.puppetlabs.net' {
securityoption { 'MinimumPasswordLength':
ensure => present,
value => '14', # Back to 14
}
}
EOF
# Apply
C:\Program Files\Puppet Labs\Puppet\bin\puppet agent --test
# Verify
secedit /export /cfg C:\temp\policy4.inf /areas SECURITYPOLICY
findstr "MinimumPasswordLength" C:\temp\policy4.inf
# Should show: MinimumPasswordLength = 14On PE Server:
# Create a manifest with invalid value (out of range)
cat > /etc/puppetlabs/code/environments/production/manifests/windows_test.pp << 'EOF'
node 'alma-woomera.delivery.puppetlabs.net' {
securityoption { 'MinimumPasswordLength':
ensure => present,
value => '999', # Invalid - too large
}
}
EOF# Run Puppet agent
C:\Program Files\Puppet Labs\Puppet\bin\puppet agent --test
# Expected: Puppet should handle gracefully (error message in logs)
# Check: C:\ProgramData\PuppetLabs\puppet\var\log\puppet.log
# Look for error message about invalid valueOn PE Server:
cat > /etc/puppetlabs/code/environments/production/manifests/windows_test.pp << 'EOF'
node 'alma-woomera.delivery.puppetlabs.net' {
# Password Policy Settings
securityoption { 'MinimumPasswordLength':
ensure => present,
value => '14',
}
securityoption { 'MaximumPasswordAge':
ensure => present,
value => '90',
}
securityoption { 'PasswordHistorySize':
ensure => present,
value => '24',
}
securityoption { 'LockoutBadCount':
ensure => present,
value => '3',
}
securityoption { 'LockoutDuration':
ensure => present,
value => '30',
}
}
EOF# On Windows agent
C:\Program Files\Puppet Labs\Puppet\bin\puppet agent --test
# Verify all settings
secedit /export /cfg C:\temp\comprehensive.inf /areas SECURITYPOLICY
findstr /E "MinimumPasswordLength MaximumPasswordAge PasswordHistorySize LockoutBadCount LockoutDuration" C:\temp\comprehensive.inf
# Should show all values set correctly# If you want to revert to original Windows defaults:
cat > /etc/puppetlabs/code/environments/production/manifests/windows_test.pp << 'EOF'
node 'alma-woomera.delivery.puppetlabs.net' {
# Empty - no securityoption resources
}
EOF# Collect results from Puppet Enterprise Console
# Path: https://rich-tandem.delivery.puppetlabs.net
# Navigate to: Nodes > alma-woomera.delivery.puppetlabs.net > Reports
# Download/screenshot the successful run report# Create a test results file
cat > TEST_RESULTS.md << 'EOF'
# Integration Test Results
Date: $(date)
Module: poc_dsc_replacement
Version: 0.1.0
PE Server: rich-tandem.delivery.puppetlabs.net
Windows Agent: alma-woomera.delivery.puppetlabs.net
OS: Windows Server 2022
## Test Cases
### Test 1: Module Installation
- [ ] Module packaged successfully
- [ ] Module deployed to PE server
- [ ] Module syntax validated
### Test 2: Basic Application
- [ ] Puppet catalog compiled
- [ ] Puppet applied without errors
- [ ] MinimumPasswordLength set to 14
### Test 3: Windows Verification
- [ ] secedit shows correct value
- [ ] Security policy updated
- [ ] Registry reflects change (if applicable)
### Test 4: Idempotency
- [ ] Second run shows no changes
- [ ] Configuration stable
### Test 5: Modification
- [ ] Value updated to 12
- [ ] Windows policy reflects change
- [ ] Rollback to 14 succeeds
### Test 6: Multiple Settings
- [ ] All 5 settings applied
- [ ] All verified in secedit export
## Notes
[Add any observations, issues, or additional findings]
EOF# On PE Server, accept the Windows agent certificate
sudo puppetserver ca list
sudo puppetserver ca sign --certname alma-woomera.delivery.puppetlabs.net# Verify module is in correct location
sudo ls /etc/puppetlabs/code/environments/production/modules/ | grep poc_dsc_replacement
# If missing, reinstall:
sudo tar -xzf /tmp/puppet-poc_dsc_replacement-0.1.0.tar.gz -C /etc/puppetlabs/code/environments/production/modules/# Check Puppet server logs
sudo tail -100 /var/log/puppetlabs/puppetserver/puppetserver.log | grep -i error
# Check catalog compilation
sudo puppet catalog compile alma-woomera.delivery.puppetlabs.net
# Check module syntax on server
cd /etc/puppetlabs/code/environments/production/modules/poc_dsc_replacement
sudo pdk validate# Run CMD as Administrator
# Verify secedit is available
where secedit
# Check permissions
icacls "C:\Windows\System32\secedit.exe"
# Try manual secedit export
secedit /export /cfg C:\temp\test.inf /areas SECURITYPOLICY /log C:\temp\secedit.log /verbose# Check Puppet agent logs on Windows
Get-Content C:\ProgramData\PuppetLabs\puppet\var\log\puppet.log -Tail 200 | Select-String -Pattern "securityoption|error" -Context 2,2
# Check if INF file was created
dir C:\Windows\Temp\puppet*.inf
# Manually run the secedit command that Puppet would run:
secedit /configure /db C:\Windows\Security\Database\secedit.sdb /cfg C:\temp\puppet_policy.inf /overwrite /log C:\temp\secedit_manual.log /verbose✅ All tests pass when:
- Module packages without errors
- Module deploys to PE server successfully
- Puppet manifest syntax validates
- Puppet agent run succeeds with no errors
- secedit export shows correct values
- Second Puppet run shows no changes (idempotency)
- Modified values apply correctly
- Rollback succeeds
- Multiple settings work together
- Error conditions handled gracefully
- Create accountpolicy resource type (following same pattern)
- Expand to all ~100 security settings in data.rb
- Create integration tests that verify secedit output
- Package as Puppet module for distribution
- Document for production use