Puppet: How to fix "Invalid resource type file_line"?
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
.
Related videos on Youtube
![Itai Ganot](https://i.stack.imgur.com/ICkw8.jpg?s=256&g=1)
Itai Ganot
Architect and Lecturer in the field of DevOps Engineering. LinkedIn: https://www.linkedin.com/in/itaiganot Personal Website: http://geek-kb.com
Updated on September 18, 2022Comments
-
Itai Ganot almost 2 years
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 runpuppet 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?
-
Itai Ganot over 9 yearsI'm sorry I forgot to add that I added it to the
init.pp
manifest of the module... is that the right place to add it? -
FooBee over 9 yearsYes, that should be the place.
-
Itai Ganot over 9 yearsCan I add it in
/etc/puppet/environments/production/manifests/site.pp
instead? -
Itai Ganot over 9 yearsOk found it! also had to copy the stdlib folder to the modules directory of production. Thanks!
-
Felix Frank over 9 yearsContrary to popular belief,
include stdlib
is mostly superfluous. You only need it to get at the default run stages defined in this module. But don't do that.