【问题标题】:Puppet root authorized_key filePuppet root 授权密钥文件
【发布时间】:2014-09-27 16:44:26
【问题描述】:

我一直在玩 puppet,但遇到了一个困扰我的问题。 也许有人可以提供一些启示。这个想法是我有一个 rsync 脚本来更新我的 authorized_keys 我的木偶大师的文件。 puppet agent 每 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

【问题讨论】:

  • 你能确定在master上,modules/policy1/files/authorized_keys不是目录吗?
  • 是的,它不是目录。

标签: ssh puppet authorized-keys


【解决方案1】:

在您的清单中,特别是您需要的第二个资源定义。也就是说,您想要执行以下操作:

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',
  }
}

【讨论】:

  • 所以我禁用了清单的下半部分,我可以确认上半部分工作 class policy1::sshkeys { file { '/root/.ssh': ensure => directory, path => ' /root/.ssh', 所有者 => 'root', 组 => 'root', 模式 => '0700',
  • 所以我禁用了上半部分并可以验证它是否有效。所以我认为问题可能是第二部分,如果我禁用确保 => 文件它可以工作。我可以看到来自主人的预先播种的授权密钥。
【解决方案2】:

好像禁用了 确保 => 文件, 似乎可以解决问题。感谢 Evgeny 和 Felix 的帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    • 2018-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多