Re: classfiltercsv question

Xander Cage <[email protected]>
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
seems classfiltercsv can not handle csv entries with duplicate strings in 
the class column. but if this is true, whats the exact use case of all this?
in my scenario i need (want) to handle many users which can of course can 
be members of the same group (class), and i absolutlely want to avoid a 
different csv for every user group. pathetic...


On Thursday, October 7, 2021 at 4:17:12 PM UTC+2 Xander Cage wrote:

> the example presented in the docs  is not correct hence the empty output . 
> i found a working example in nicj anderson presentation -> 
> https://github.com/nickanderson/cfengine-training/blob/master/slide-deck.org
>
> bundle agent example_classfiltercsv
> {
>   classes:
>
>     "department_of_wierdos";
>     "department_of_twats";
>     "wasted_persons";
>
>
>   vars:
>       "data_file" string => "users.csv";
>       "d" data => classfiltercsv($(data_file), "true", 0);
>
>   reports:
>
>     department_of_wierdos::
>
>       "Wierdos: data: $(with)" with => string_mustache("{{%-top-}}", d);
>
>     department_of_twats::
>
>       "Twats: data: $(with)" with => string_mustache("{{%-top-}}", d);
>
>     wasted_persons::
>
>       "Fired Jerks: data: $(with)" with => string_mustache("{{%-top-}}", 
> d);
>
>
> }
> bundle agent __main__
> {
>   methods:
>       "example_classfiltercsv";
> }
>
>
> output:
>
> R: Wierdos: data: [
>   {
>     "group": "tedious",
>     "name": "Toby Flenderson",
>     "ssh_key": "ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg",
>     "uid": "tflen"
>   },
>   {
>     "group": "buzzoff",
>     "name": "Get OUT!",
>     "ssh_key": "ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg",
>     "uid": "fired"
>   }
> ]
> R: Twats: data: [
>   {
>     "group": "tedious",
>     "name": "Toby Flenderson",
>     "ssh_key": "ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg",
>     "uid": "tflen"
>   },
>   {
>     "group": "buzzoff",
>     "name": "Get OUT!",
>     "ssh_key": "ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg",
>     "uid": "fired"
>   }
> ]
> R: Fired Jerks: data: [
>   {
>     "group": "tedious",
>     "name": "Toby Flenderson",
>     "ssh_key": "ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg",
>     "uid": "tflen"
>   },
>   {
>     "group": "buzzoff",
>     "name": "Get OUT!",
>     "ssh_key": "ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg",
>     "uid": "fired"
>   }
> ]
>
> at least something, but still not what i am expecting....not sure why it 
> repeates the same items 3 times...
>
> On Thursday, October 7, 2021 at 2:50:49 PM UTC+2 Xander Cage wrote:
>
>> ok, forgot some garbage chars...now
>>
>> ClassExpression,uid,name,group,ssh_key^M
>> deparment_of_wierdos,mscott,Michael 
>> Scott,pathetic,ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg^M
>> deparment_of_wierdos,jkras,John 
>> Krasinski,pathetic,ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg^M
>> department_of_twats,tflen,Toby 
>> Flenderson,tedious,ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg^M
>> wasted_persons,fired,Get 
>> OUT!,buzzoff,ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg^M
>>
>> but now output is empty, while i expecting output of the data container 
>> split in the various groups.  Am i even on the right track with this 
>> function?
>>
>> R: Wierdos: data:
>> R: Twats: data:
>> R: Fired Jerks: data:
>>
>>
>>
>>
>> On Thursday, October 7, 2021 at 2:45:28 PM UTC+2 Xander Cage wrote:
>>
>>> nope, same error...
>>>
>>> ClassExpression,uid,name,group,ssh_key^M
>>> deparment_of_wierdos,mscott,Michael 
>>> Scott,pathetic,ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg^M
>>> deparment_of_wierdos,jkras,John 
>>> Krasinski,pathetic,"ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg^M
>>> department_of_twats,tflen,Toby 
>>> Flenderson,tedious,"ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg^M
>>> wasted_persons,fired,Get 
>>> OUT!,buzzoff,"ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg^M
>>>
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>> R: Wierdos: data:
>>> R: Twats: data:
>>> R: Fired Jerks: data:
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 3, line ignored.
>>>  warning: classfiltercsv: Failed to parse line 4, line ignored.
>>>
>>>
>>> On Thursday, October 7, 2021 at 2:28:43 PM UTC+2 Bas van der Vlies wrote:
>>>
>>>> Remove the ' and " for the file the example is: 
>>>> [bas@localhost ~]$ echo 'any,A,net.ipv4.ip_forward,ANYVALUE' 
>>>> any,A,net.ipv4.ip_forward,ANYVALUE 
>>>>
>>>> result in an entry with out ' 
>>>>
>>>> On 07/10/2021 14:14, Xander Cage wrote: 
>>>> > 
>>>> > Hi, 
>>>> > 
>>>> > I thought about using classfiltercsv for managing user/identities, 
>>>> but 
>>>> > it seem i dont fully understand whats the deal with this function or 
>>>> > missinterpreting something. 
>>>> > 
>>>> > I used the example form the docs, made this sample user csv with the 
>>>> for 
>>>> > some reason required DOS linefeeds. 
>>>> > 
>>>> > 
>>>> > 'ClassExpression,uid,name,group,ssh_key' 
>>>> > 'deparment_of_wierdos,mscott,Michael 
>>>> > Scott,pathetic,"ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg"' 
>>>> > 'deparment_of_wierdos,jkras,John 
>>>> > 
>>>> Krasinski,pathetic,"ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg"' 
>>>> > 'department_of_twats,tflen,Toby 
>>>> > 
>>>> Flenderson,tedious,"ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg' 
>>>> > 'wasted_persons,fired,Get 
>>>> > OUT!,buzzoff,"ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg"' 
>>>> > 
>>>> > policy: 
>>>> > 
>>>> > bundle agent example_classfiltercsv 
>>>> > { 
>>>> >   classes: 
>>>> > 
>>>> >     "department_of_wierdos"; 
>>>> >     "department_of_twats"; 
>>>> >     "wasted_persons"; 
>>>> > 
>>>> > 
>>>> >   vars: 
>>>> >       "data_file" string => "users.csv"; 
>>>> >       "d" data => classfiltercsv($(data_file), "true", 0); 
>>>> > 
>>>> >   reports: 
>>>> > 
>>>> >     department_of_wierdos:: 
>>>> > 
>>>> >       "Wierdos: data: $(with)" with => string_mustache("", d); 
>>>> > 
>>>> >     department_of_twats:: 
>>>> > 
>>>> >       "Twats: data: $(with)" with => string_mustache("", d); 
>>>> > 
>>>> >     wasted_persons:: 
>>>> > 
>>>> >       "Fired Jerks: data: $(with)" with => string_mustache("", d); 
>>>> > 
>>>> > } 
>>>> > bundle agent __main__ 
>>>> > { 
>>>> >   methods: 
>>>> >       "example_classfiltercsv"; 
>>>> > } 
>>>> > 
>>>> > output: 
>>>> > 
>>>> > root@aixtest01: /root/cfe_testbed # /var/cfengine/bin/cf-agent -KI -f 
>>>> > ./classfiltercsv_test.cf 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> > R: Wierdos: data: 
>>>> > R: Twats: data: 
>>>> > R: Fired Jerks: data: 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 2, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 3, line ignored. 
>>>> >  warning: classfiltercsv: Failed to parse line 4, line ignored. 
>>>> > 
>>>> > what i am doing wrong? 
>>>> > 
>>>> > chris 
>>>> > 
>>>> > 
>>>> > 
>>>> > -- 
>>>> > You received this message because you are subscribed to the Google 
>>>> > Groups "help-cfengine" group. 
>>>> > To unsubscribe from this group and stop receiving emails from it, 
>>>> send 
>>>> > an email to [email protected] 
>>>> > <mailto:[email protected]>. 
>>>> > To view this discussion on the web visit 
>>>> > 
>>>> https://groups.google.com/d/msgid/help-cfengine/9dc2e3ba-2fea-4f1c-8af9-32efd7c40d57n%40googlegroups.com 
>>>> > <
>>>> https://groups.google.com/d/msgid/help-cfengine/9dc2e3ba-2fea-4f1c-8af9-32efd7c40d57n%40googlegroups.com?utm_medium=email&utm_source=footer>. 
>>>>
>>>>
>>>> -- 
>>>> Bas van der Vlies 
>>>> | HPCV Supercomputing | Internal Services | SURF | 
>>>> https://userinfo.surfsara.nl | 
>>>> | Science Park 140 | 1098 XG Amsterdam | Phone: +31208001300 
>>>> <+31%2020%20800%201300> | 
>>>> | [email protected] 
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/29b9b262-0bb2-4cac-b3b1-3299e2294c4fn%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.