Quick question, Im writing a module that makes sure file_line exists but cant figure out how to only apply this if the target file exists, heres the module so far
$file = '/etc/modprobe.d/CIS.conf' file { $file : ensure => file, mode => '0600', owner => 'root', group => 'root', } file_line { "(1.1.18) ${file} - cramfs": ensure => present, path => $file, line => 'install cramfs /bin/true', require => File[$file], } file_line { "(1.1.19) ${file} - freevxfs": ensure => present, path => $file, line => 'install freevxfs /bin/true', require => File[$file], } I added the Require for each file_line but when I test on a node I get this, *Notice: /Stage[main]/Cis_rhel7::Rule::Rule_1_1_18/File[/etc/modprobe.d/CIS.conf]/ensure: current_value absent, should be file (noop)* *Error: /Stage[main]/Cis_rhel7::Rule::Rule_1_1_18/File_line[(1.1.18) /etc/modprobe.d/CIS.conf - cramfs]: Could not evaluate: No such file or directory @ rb_sysopen - /etc/modprobe.d/CIS.confError: /Stage[main]/Cis_rhel7::Rule::Rule_1_1_18/File_line[(1.1.19) /etc/modprobe.d/CIS.conf - freevxfs]: Could not evaluate: No such file or directory @ rb_sysopen - /etc/modprobe.d/CIS.confError: /Stage[main]/Cis_rhel7::Rule::Rule_1_1_18/File_line[(1.1.20) /etc/modprobe.d/CIS.conf - jffs2]: Could not evaluate: No such file or directory @ rb_sysopen - /etc/modprobe.d/CIS.conf* Error: /Stage[main]/Cis_rhel7::Rule::Rule_1_1_18/File_line[(1.1.21) /etc/modprobe.d/CIS.conf - hfs]: Could not evaluate: No such file or directory @ rb_sysopen - /etc/modprobe.d/CIS.conf Error: /Stage[main]/Cis_rhel7::Rule::Rule_1_1_18/File_line[(1.1.22) /etc/modprobe.d/CIS.conf - hfsplus]: Could not evaluate: No such file or directory @ rb_sysopen - /etc/modprobe.d/CIS.conf Error: /Stage[main]/Cis_rhel7::Rule::Rule_1_1_18/File_line[(1.1.23) /etc/modprobe.d/CIS.conf - squashfs]: Could not evaluate: No such file or directory @ rb_sysopen - /etc/modprobe.d/CIS.conf Error: /Stage[main]/Cis_rhel7::Rule::Rule_1_1_18/File_line[(1.1.24) /etc/modprobe.d/CIS.conf - udf]: Could not evaluate: No such file or directory @ rb_sysopen - /etc/modprobe.d/CIS.conf Info: Class[Cis_rhel7::Rule::Rule_1_1_18]: Unscheduling all events on Class[Cis_rhel7::Rule::Rule_1_1_18] All my resources are have a resource default of NOOP, since Im doing a compliance check. Cant figure out how to make File_line only get applied if the file exists. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/dbcdf341-8f37-4a5a-a67e-a8150f34d949%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.