I have some Windows systems that I need to configure a user's profile. The user has to be logged into for the profile to be created. I came up with the solution below but it seems kinda hacky. I assume there is a better way to get the same effect without having a class inside a class? Is there a way to set a stage on a class when using hiera?
I am using Windows 7 x64, Puppet Open Source 3.4.2, and Hiera 1.3.1
autologon.pp manifest
class autologon ($username, $password) {
stage { 'user-creation':
before => Stage['main'],
}
class {'autologon-internal':
stage => user-creation,
username => $username,
password => $password,
}
reboot { 'user-creation':
subscribe => Stage['user-creation']
}
class autologon-internal ($username, $password) {
user { $username:
ensure => present,
groups => 'Users',
membership => inclusive,
password => $password,
}
registry_value { "HKLM\\software\\microsoft\\windows nt\\currentversion\\winlogon\\defaultusername":
ensure => present,
type => string,
data => $username,
}
registry_value { "HKLM\\software\\microsoft\\windows nt\\currentversion\\winlogon\\defaultdomainname":
ensure => present,
type => string,
data => $hostname,
}
registry_value { "HKLM\\software\\microsoft\\windows nt\\currentversion\\winlogon\\defaultpassword":
ensure => present,
type => string,
data => $password,
}
registry_value { "HKLM\\software\\microsoft\\windows nt\\currentversion\\winlogon\\autoadminlogon":
ensure => present,
type => string,
data => '1',
}
}
}
hiera yaml file
---
classes:
- autologon
autologon::username: "myusername"
autologon::password: "mypassword"