How can I make CFEngine report PermitRootLogin from sshd_config as part of Inventory? #4474
-
I'd like to parse system sshd config, store the The CFEngine docs show me how to tag a variable for inventory, so I guess something like this:
What would I use to get the data that I want? Does the standard library or the built in functions include functionality to make it easy to parse sshd config? Could someone give me an example? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @olehermanse There are a few functions that come to mind with respect to parsing text. \
Of these, the first two are the ones I most commonly use. For cases where you have a unique key you can use
In the example above:
|
Beta Was this translation helpful? Give feedback.
-
You may also be interested in
It won't show every Match case, you have to use
|
Beta Was this translation helpful? Give feedback.
Hi @olehermanse
There are a few functions that come to mind with respect to parsing text. \
data_readstringarray
data_readstringarrayidx
readstringarray
readstringarrayidx
data_regextract
parsestringarray
parsestringarrayidx
regextract
Of these, the first two are the ones I most commonly use. For cases where you have a unique key you can use
data_readstringarray()
, for cases where you might have the same key multiple times you will probably want to usedata_readstringarrayidx()
. I am going to ignore the match feature for sshd and assume unique keys for this file, that is to say if you have PermitRootLogin multiple times, the last one will win.