daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Mar 16th, 2018 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. user { $username:
  2.     comment => "$name",
  3.     shell   => "$shell",
  4.     managehome => false,
  5.     password  => "$password",
  6.     groups => $groups
  7. }
  8.    
  9. $key = "${homedir}/${name}/file"
  10.  
  11.     file { $key:
  12.     ensure => present,
  13.     owner  => $username,
  14.     group  => $username,
  15.     mode   => 600,
  16.     content => "$keyvalue",
  17.     subscribe => User[$username],
  18. }
  19.    
  20. require 'etc'
  21.  
  22. Etc.passwd { |user|
  23.  
  24.    Facter.add("home_#{user.name}") do
  25.       setcode do
  26.          user.dir
  27.       end
  28.    end
  29.  
  30. }
  31.    
  32. $username = "root"
  33. $home = "home_$username"
  34. $home_path = inline_template("<%= scope.lookupvar('::$home') %>")
  35.  
  36. file { "$home_path/test.txt":
  37.    content => "huhu",
  38. }
  39.    
  40. user { $username:
  41.     comment    => "comment",
  42.     home       => "/home/${username}",
  43.     managehome => false,
  44.     # ...
  45. }
  46.    
  47. define custom_user($username, $password) {
  48.     user { $username:
  49.         home     => "/home/${username}",
  50.         password => $password,
  51.         # etc.
  52.     }
  53.     file { "/home/${username}":
  54.         ensure  => directory,
  55.         owner   => $username,
  56.         require => User[$username],
  57.         # etc.
  58.     }
  59. }
  60.    
  61. $home = {
  62.     normal_user => '/home/normal_user',
  63.     backup      => '/var/backup',
  64.     mysql       => '/var/lib/mysql'
  65. }
  66.    
  67. $home = { ... }
  68. $default_home = '/home'
  69.  
  70. user {$username:
  71.     home => has_key($home, $username) ? {
  72.                 true => $home[$username],
  73.                 false => "${default_home}/${username}"
  74.             }
  75.     # ...
  76. }
  77.    
  78. require 'etc'
  79.  
  80. Facter.add(:home_dirs) do
  81.   setcode do
  82.  
  83.     home_dirs = {}  
  84.     Etc.passwd { |user|
  85.       home_dirs[user.name] = user.dir
  86.     }
  87.  
  88.     home_dirs
  89.  
  90.   end
  91. end
  92.    
  93. $facts['home_dirs']['some_username']
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top