From fb91550906645b707735f58c2908afa26b267503 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Tue, 17 Mar 2015 12:21:58 +0100 Subject: [PATCH] Ensure home and home/.ssh folders are created When creating a new user, ensure that the home folder, and the .ssh one is created with the right ownership and permissions. Change-Id: I25167179a1573c4dbbc4a8703f5bb200af9709f5 --- manifests/virtual/localuser.pp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/manifests/virtual/localuser.pp b/manifests/virtual/localuser.pp index 4822d07..23ef13f 100644 --- a/manifests/virtual/localuser.pp +++ b/manifests/virtual/localuser.pp @@ -33,11 +33,30 @@ define user::virtual::localuser( require => Group[$title], } + # ensure that home exists with the right permissions + file { $home: + ensure => directory, + owner => $title, + group => $title, + mode => '0755', + require => [ User[$title], Group[$title] ], + } + + # Ensure the .ssh directory exists with the right permissions + file { "${home}/.ssh": + ensure => directory, + owner => $title, + group => $title, + mode => '0700', + require => File[$home], + } + ssh_authorized_key { $key_id: ensure => present, key => $sshkeys, user => $title, type => 'ssh-rsa', + require => File[ "${home}/.ssh" ], } if ( $old_keys != [] ) {