Ask Your Question

How to make sure, that a specific line exists?

asked 2014-02-13 02:30:18 -0500

Adam Ryczkowski gravatar image

updated 2014-02-13 02:54:29 -0500

I need to make sure, that there is a specific line in /etc/crypttab.

Is there any ready puppet module, that can be used?

I don't want to manage whole /etc/crypttab. I only want to be sure, that specific line exists, and - as a bonus - that other lines, given by regex, don't exist.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-02-14 15:35:34 -0500

fnaard gravatar image

The puppetlibs/stdlib module includes a file_line resource which does exactly what you want. You can install the module (or confirm it is already) from the command line with puppet module and then puppet describe will show you how to use it.

[root@training ~]# puppet module install puppetlabs/stdlib
[root@training ~]# puppet describe file_line

Ensures that a given line is contained within a file.  The implementation
matches the full line, including whitespace at the beginning and end.  If
the line is not contained in the given file, Puppet will add the line to
ensure the desired state.  Multiple resources ...
edit flag offensive delete link more


Thank you! I thought I've remembered all the standard resources. Must have my memory played a trick on me.

Adam Ryczkowski gravatar imageAdam Ryczkowski ( 2014-02-14 16:08:17 -0500 )edit

answered 2014-02-13 10:21:45 -0500

doc75 gravatar image

updated 2014-02-13 10:22:06 -0500

I would use augeas to check this as it appears that a lens exist for crypttab (cf.: ) As I do not have a crypttab file accessible at the moment I cannot give you the code to do so. If you need more information let me know and I'll try to provide more info.

Hope this helps.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-02-13 02:30:18 -0500

Seen: 985 times

Last updated: Feb 14 '14