Ask Your Question
0

.ssh directory doesn't get created

asked 2015-04-08 14:56:24 -0500

dmcewen gravatar image

updated 2015-04-08 15:09:50 -0500

csharpsteen gravatar image

I'm trying to create an authorized_keys file and need the .ssh directory to exist. When I make it by hand, authorized_keys file is created but I need to have puppet create the directory. Here is my manifest file for this user:

class prtgadmin {

  file { "/home/prtgadmin/.ssh":
    owner => "prtgadmin",
    group => "prtgadmin",
    ensure => directory,
    ensure => present,
    mode => 600,
    target => "/home/prtgadmin/.ssh",
  }
  file { "/home/prtgadmin/.ssh/authorized_keys":
    owner => "prtgadmin",
    group => "prtgadmin",
    mode => 400,
    source => "puppet:///modules/prtgadmin/authorized_keys",
    ensure => present,
  }
}
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2015-04-08 15:42:15 -0500

updated 2015-04-08 17:58:01 -0500

There are multiple issues:

You're specifying the ensure-attribute twice where the most recent wins:

It is not ensure => directory AND ensure => present.
It is just ensure => directory (ONLY!).

The target-attribute's only used for symbolic links.

You want the execute-bit set on directories. AFAIK it is a “feature” that puppet automatically does this. IMO that's a terrible “feature” and I advise not to use it.

ensure => present on a file just means: accept any existance of the file. You probably want, that this file's populated with the content of the specified source thus it's ensure => file.

To sum things up:

class prtgadmin {
  file { '/home/prtgadmin/.ssh/':
    ensure => directory,
    mode   => '0700'
    owner  => 'prtgadmin',
    group  => 'prtgadmin',
  }
  
  file { '/home/prtgadmin/.ssh/authorized_keys':
    ensure => file,
    mode   => '0400',
    owner  => 'prtgadmin',
    group  => 'prtgadmin',
    source => 'puppet:///modules/prtgadmin/authorized_keys',
  }
}

It is best practice to double quote strings with variable(s) in 'em only – single quote around strings which don't need any further inspection.

For all further questions the type reference's your friend.

edit flag offensive delete link more

Comments

Thanks for the post!! working now

dmcewen gravatar imagedmcewen ( 2015-04-09 05:46:16 -0500 )edit
0

answered 2015-04-09 08:22:02 -0500

rnelson0 gravatar image

Have you tried using the sshauthorizedkeys resource type?

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2015-04-08 14:56:24 -0500

Seen: 348 times

Last updated: Apr 09 '15