Some troubles with Cfengine3 book examples

227 views
Skip to first unread message

ysso...@gmail.com

unread,
Jul 8, 2013, 1:28:45 PM7/8/13
to help-c...@googlegroups.com
I think this is an excellent intro book for Cfengine3, and as a beginner, I started experimenting examples on this book's pages 30 & 31.

I tried the following 2 examples and got errors from both, and I don't know for which part I did wrong.

# cf-agent -V
CFEngine Core 3.5.0

# cat ex1.cf
body common control
{
          bundlesequence => { "blah" };
}

bundle agent blah
{
          services:
                "ssh";
}
# ps -ef|grep ssh
root      6284  2764  0 10:21 pts/0    00:00:00 grep ssh
# cf-agent -KI -f ex1.cf
2013-07-08T10:21:58-0700     info: /blah/services/'ssh': Service 'ssh' could not be invoked successfully
2013-07-08T10:21:58-0700    error: /blah/services/'ssh': A method attempted to use a bundle 'default:standard_services' that was apparently not defined

# ps -ef|grep ssh
root      6292  2764  0 10:21 pts/0    00:00:00 grep ssh



# cat ex2.cf

body common control
{
    bundlesequence => { "blah" };
}

bundle agent blah
{
    files:
        "/etc/resolv.conf"
        comment => "Hello",
        edit_line => replace_or_add(".*search.*", "search example.com");

}

# cf-agent -KI -f ex2.cf
/var/cfengine/inputs/ex2.cf:12:0: error: Undefined bundle replace_or_add with type edit_line
2013-07-08T10:19:13-0700    error: Policy failed validation with command '"/var/cfengine/bin/cf-promises" -c "/var/cfengine/inputs/ex2.cf"'



I guess I'm not using some very basic syntax in my learning experiments but couldn't find where I have such missing basics.

Any help would be appreciated.

Thanks!



- Young

Ted Zlatanov

unread,
Jul 8, 2013, 1:34:13 PM7/8/13
to ysso...@gmail.com, help-c...@googlegroups.com
On Mon, 8 Jul 2013 10:28:45 -0700 (PDT) ysso...@gmail.com wrote:

y> I think this is an excellent intro book for Cfengine3, and as a beginner, I
y> started experimenting examples on this book's *pages 30 & 31*.

y> I tried the following 2 examples and got errors from both, and I don't know
y> for which part I did wrong.

...
y> 2013-07-08T10:21:58-0700 error: /blah/services/'ssh': A method attempted
y> to use a bundle 'default:standard_services' that was apparently not defined*
...
y> */var/cfengine/inputs/ex2.cf:12:0: error: Undefined bundle replace_or_add
y> with type edit_line

You're missing the standard library.

In 3.5.0, add

inputs => { "libraries/cfengine_stdlib.cf" };

to your policy (in "body common control").

Ted

ysso...@gmail.com

unread,
Jul 8, 2013, 1:38:46 PM7/8/13
to help-c...@googlegroups.com, ysso...@gmail.com

Hi Ted,


Excellent! I just added it, and both examples work charm!


  inputs => { "libraries/cfengine_stdlib.cf" };


Thank you for your help.


- Young
 

Diego Zamboni

unread,
Jul 8, 2013, 1:47:28 PM7/8/13
to Ted Zlatanov, Diego Zamboni, ysso...@gmail.com, help-c...@googlegroups.com
Indeed, as Ted points out you need to load the stdlib.

I'll make a note to add a clarification about this in the upcoming new release of the book :)

--Diego
> --
> 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 help-cfengin...@googlegroups.com.
> To post to this group, send email to help-c...@googlegroups.com.
> Visit this group at http://groups.google.com/group/help-cfengine.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

ysso...@gmail.com

unread,
Jul 8, 2013, 2:12:32 PM7/8/13
to help-c...@googlegroups.com, Ted Zlatanov, Diego Zamboni, ysso...@gmail.com


Hi Diego,


Sure, thanks for the comment.

I had a good start with short, easy, yet interesting Chapters 1 and 2, unlike many other books with a whole bunch to grasp in the beginning chapters.

I'm sure you had this factor in mind when you wrote the book. :)

Thank you.


- Young


Diego Zamboni

unread,
Jul 8, 2013, 2:43:24 PM7/8/13
to ysso...@gmail.com, Diego Zamboni, help-c...@googlegroups.com, Ted Zlatanov
Hi Young,

> I had a good start with short, easy, yet interesting Chapters 1 and 2, unlike many other books with a whole bunch to grasp in the beginning chapters.
>
> I'm sure you had this factor in mind when you wrote the book. :)

It was indeed one of the predominant criteria :)

Thanks for the nice comments!

--Diego

Reply all
Reply to author
Forward
0 new messages