Ask Your Question
0

require breaks when pointing on a resource with "ensure => absent"

asked 2014-01-09 06:58:04 -0600

gunzl1ng3r gravatar image

Hey there,

I'm currently having trouble with managing my users' home directories.

My the manifest to handle users looks like this:

user { $username:
  comment => "$full_name",
  home => "$home_dir",
  uid => "$uid",
  gid => "$gid",
  groups => "$groups",
  managehome => "true",
  ensure => "$action"
}

file { "${home_dir}":
  ensure => directory,
  owner => "${username}",
  group => "${gid}",
  require => User[$username],
}

All this takes place inside a define, and works pretty good, as long as the ensure on the user is on "present" - when removing a user by switching ensure to "absent" the "file" for his home directory breaks; I understand that the require is satisfied even though the user is on ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-01-10 04:19:40 -0600

doc75 gravatar image

Hello,

I usually do something like that for directory and files (syntax below not tested):

user { $username:
  comment => "$full_name",
  home => "$home_dir",
  uid => "$uid",
  gid => "$gid",
  groups => "$groups",
  managehome => "true",
  ensure => "$action"
}

$dir_ensure = $action ? {
    'present' => 'directory',
    default   => $action,
}

file { "${home_dir}":
  ensure => $dir_ensure,
  owner => "${username}",
  group => "${gid}",
  require => User[$username],
}

Hope this helps

edit flag offensive delete link more

Comments

Thank you very much :D

gunzl1ng3r gravatar imagegunzl1ng3r ( 2014-01-27 03:12:50 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-01-09 06:58:04 -0600

Seen: 63 times

Last updated: Jan 10 '14