Ask Your Question

how can i turn a fact output from a one line string to multiple lines?

asked 2014-05-12 15:33:37 -0600

Discreet gravatar image

I have a custom fact that outputs a list of AD security groups that have access to my servers. Unfortunately these groups are seen as a single string so I cannot parse through and see all servers that have group E granted access for example. Is there a way to turn this string into an array or something that will make it easily searchable? Let me know if you need me to pastebin my fact.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-05-12 15:46:46 -0600

updated 2014-05-13 14:09:44 -0600

you can try use split function.


answering your question on the comments. yes, you can slpit based on whitespace.

here is an example:

$string = 'test1 test2 test3'
$array = split($string, ' ')
notify{$array: }

and when I run , look at the output.

Notice: Compiled catalog for localhost.localdomain in environment production in 0.03 seconds
Notice: test3
Notice: /Stage[main]/Main/Notify[test3]/message: defined 'message' as 'test3'
Notice: test2
Notice: /Stage[main]/Main/Notify[test2]/message: defined 'message' as 'test2'
Notice: test1
Notice: /Stage[main]/Main/Notify[test1]/message: defined 'message' as 'test1'
edit flag offensive delete link more


does the split function have the ability to split based on whitespace? for example: $string = test1 test2 test3 $array1 = split($string, ' ')

Discreet gravatar imageDiscreet ( 2014-05-13 09:20:50 -0600 )edit

Cool, thanks. Do I need to enable structured facts for this to work properly?

Discreet gravatar imageDiscreet ( 2014-05-14 06:41:45 -0600 )edit

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-05-12 15:33:37 -0600

Seen: 860 times

Last updated: May 13 '14