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"

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/fa44ad0a-dded-4234-a453-29ff1c57402b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to