大网数据广告活动
服务器运维问答

Puppet: How to fix "Invalid resource type file_line"?

· 52CE 我爱测

I have a freshly installed Puppet server with only one module configured and one managed client. This is a MOTD module and looks like so: class motd { file { "/etc/custom_motd.sh": path => '/etc/custom_motd.sh', ensure => present…

问题原文

原帖链接 · Itai Ganot · CC BY-SA 3.0

I have a freshly installed Puppet server with only one module configured and one managed client.

This is a MOTD module and looks like so:

class motd {
    file { "/etc/custom_motd.sh":
    path    => '/etc/custom_motd.sh',
    ensure  => present,
    owner   => "root",
    group   => "root",
    mode    => "775",
    content => template('motd/custom_motd.sh.erb'),
    #require => Class['nagios_client'],
    }

#    file_line { 'enable motd':
#    ensure  => present,
#    line    => '/etc/custom_motd.sh',
#    path    => '/etc/profile',
#    require  => File['/etc/custom_motd.sh']
#    }
}

When I run puppet agent -t on the client I get the proper result:

[root@pnd01 ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for pnd01.company.com
Info: Applying configuration version '1426413575'
Notice: /Stage[main]/Motd/File[/etc/custom_motd.sh]/ensure: created
Notice: Finished catalog run in 0.24 seconds
[root@pnd01 ~]#

But if I uncomment the "file line" section in the init.pp file of the module and then run puppet agent -t on the client, I get the following response:

[root@pnd01 ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type file_line at /etc/puppet/environments/production/modules/motd/manifests/init.pp:17 on node pnd01.company.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
[root@pnd01 ~]#

Line 17 points to the "file_line" declaration. I have the exact same module on another Puppet environment and it works there like a charm. I've looked it up on Google and found a post which recommends to add:

pluginsync = true

to the [main] section of /etc/puppet/puppet.conf on the client machine and I've done so but I still get the same error.

Any idea how to fix this issue or why does it even happen?

已采纳解答

原帖链接 · Sven · CC BY-SA 3.0

You likely need to install the standard library. On your other installation, this might have got pulled in by some other module you installed.

After that, use it with include stdlib.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-03-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。