I need to do the same process over and over again for numerous users. What would be the easy way to create a class or function to wrap the following code so that each time I need to do the following it's a single line of code. Currently what' I've been doing is copying the 35 lines of code and duplicating it for hundreds of users.
$username_john = hiera ( 'ftp_username_john' )
$password_john = hiera ( 'ftp_password_john' )
user { "${username_john}":
ensure => present,
password => "${password_john}",
managehome => false,
home => '/incoming',
groups => 'sftpusers',
shell => '/sbin/nologin',
}
file { "/sftp/${username_john}":
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
require => File['/sftp'],
}
file { "/sftp/${username_john}/incoming":
ensure => directory,
owner => $username_john,
group => 'sftpusers',
mode => '0755',
require => File["/sftp/${username_john}"],
}
file { "/sftp/${username_john}/outgoing":
ensure => directory,
owner => $username_john,
group => 'sftpusers',
mode => '0755',
require => File["/sftp/${username_john}"],
}