Puppet root authorized_key文件

时间:2014-09-27 16:44:26

标签: ssh puppet authorized-keys

我一直在搞乱傀儡,我遇到了一个困扰我的问题。 也许有些人可以解决一些问题。我的想法是我有一个更新我的authorized_keys的rsync脚本 我的木偶大师的文件。每4个小时,木偶代理会抓取新的authorized_keys文件。

这是一个主清单

class policy1::sshkey {
  file { '/root/.ssh/':
    ensure  =>  directory,
    path    =>  '/root/.ssh/',
    owner   =>  'root',
    group   =>  'root',
    mode    =>   '0700',
  }

  file { '/root/.ssh/authorized_keys':
    require => File ["/root/.ssh/authorized_keys"],
    ensure  => file,
    owner   => 'root',
    group   => 'root',
    mode    => '0600',
    source  => "puppet:///modules/policy1/authorized_keys",
  }
}

我的代理人虽然收到了这个错误

  

错误:无法应用目录:不是目录 - /root/.ssh/authorized_keys

2 个答案:

答案 0 :(得分:0)

在您的清单中,特别是您需要自己的第二个资源定义。那就是说,你想做类似下面的事情:

class policy1::sshkey {
  file { '/root/.ssh/':
    ensure =>  directory,
    path   =>  '/root/.ssh/',
    owner  =>  'root',
    group  =>  'root',
    mode   =>   '0700',
  }

  file { '/root/.ssh/authorized_keys':
    # Require the parent directory to be created beforehand.
    require => File['/root/.ssh/'],
    ensure  => file,
    owner   => 'root',
    group   => 'root',
    mode    => '0600',
    source  => "puppet:///modules/policy1/authorized_keys",
  }
}

......或者我个人更喜欢:

class policy1::sshkey {
  file { '/root/.ssh':
    ensure => directory,
    path   => '/root/.ssh',
    owner  => 'root',
    group  => 'root',
    mode   => '0700',
  }->
  file { '/root/.ssh/authorized_keys':
    ensure => file,
    owner  => 'root',
    group  => 'root',
    mode   => '0600',
    source => 'puppet:///modules/policy1/authorized_keys',
  }
}

答案 1 :(得分:0)

看起来像是禁用了     确保=>文件, 似乎可以做到这一点。感谢Evgeny和Felix的帮助。