neilhwatson / evolve_cfengine_freelib

Evolve Thinking's free Cfengine promise library.
18 stars 5 forks source link

Library seems to fail on CFE 3.5 #4

Closed raags closed 10 years ago

raags commented 10 years ago

The directory structure seems to have changed considerable in CFE 3.5, so some of the README steps differ. I've managed to load the elf library and run the efl_main bundle, but now I"m getting the following error :

# cf-agent -I -K
2014-01-13T15:46:16+0530   notice: R: --> I'm a policy hub.
2014-01-13T15:46:16+0530   notice: R: Hello World!
2014-01-13T15:46:16+0530     info: M '"/var/cfengine/modules/return_index.pl" efl_main 1': 2014-01-13T15:46:16+0530   error: Couldn't run '/var/cfengine/modules/return_index.pl'. (execv: No such file or directory)

Do you know why the return_index.pl module is not being detected? The file is present and set to executable in that directory :

# cd modules/
# pwd
/var/cfengine/modules
# ls -al
total 12
drwx------.  2 root root 4096 Jan 13 15:24 .
drwxr-xr-x. 13 root root 4096 Jan 13 14:55 ..
-rwxr-xr-x.  1 root root  630 Jan 13 15:24 return_index.pl

promises.cf :

body common control
{
 bundlesequence => {
                 # Common bundles first for best practice 
                    def,

                 # Design Center
                    cfsketch_run,

                 # Agent bundles from here
                    main,
                    edit_motd,
                    efl_main("/var/cfengine/inputs/bundle.txt"),
 };

 inputs => {

         # Global common bundles
            "def.cf",

         # Control body for all agents
            "controls/cf_agent.cf",
            "controls/cf_execd.cf",
            "controls/cf_monitord.cf",
            "controls/cf_runagent.cf",
            "controls/cf_serverd.cf",

         # COPBL/Custom libraries.  Eventually this should use wildcards.
             @(cfengine_stdlib.inputs),

         # Design Center
             # MARKER FOR CF-SKETCH INPUT INSERTION
             "cf-sketch-runfile.cf",

         # User services from here
            "services/init_msg.cf",
            "lib/3.5/evolve_freelib.cf",
            "edit_motd.cf",
};

 version => "Community Promises.cf 3.4.0";

}
neilhwatson commented 10 years ago

Is return_index.pl installed on the client? I can't tell if the 'ls -al' and the error from cf-agent are from the same host. Also, the modules dir is 700 so the agent must be run by root.

raags commented 10 years ago

Yes, its on the same host, its a test box which itself is the policy server, and the agent is run as root.

neilhwatson commented 10 years ago

Run this policy with 'cf-agent -vlf /path/to/this_file.cf' and post the results:

body common control
{
    bundlesequence => { "main", };
}

bundle agent main
{
    classes:
        "ok" expression => usemodule( "return_index.pl", "x 3" );

    commands: 
        "/bin/ls -l ${sys.workdir}/modules/return_index.pl";
        "/bin/cat ${sys.workdir}/modules/return_index.pl";

    reports:
        ok::
            "return_index_pl => ${return_index_pl.x}";
}
raags commented 10 years ago

This is what I got :

[root@rhel6 ~]# cf-agent -vlf mod.cf 
cf3> Work directory is /var/cfengine
cf3> Looking for a source of entropy in '/var/cfengine/randseed'
cf3> Making sure that locks are private...
cf3> Checking integrity of the state database
cf3> Checking integrity of the module directory
cf3> Checking integrity of the PKI directory
cf3> Loaded private key at '/var/cfengine/ppkeys/localhost.priv'
cf3> Loaded public key '/var/cfengine/ppkeys/localhost.pub'
cf3> Setting cfengine default port to 5308, '5308'
cf3> Reference time set to 'Tue Jan 14 12:47:27 2014'
cf3> CFEngine Core 3.5.2
cf3> ------------------------------------------------------------------------
cf3> Host name is: rhel6
cf3> Operating System Type is linux
cf3> Operating System Release is 2.6.32-131.0.15.el6.x86_64
cf3> Architecture = x86_64
cf3> Using internal soft-class linux for host rhel6
cf3> The time is now Tue Jan 14 12:47:27 2014
cf3> ------------------------------------------------------------------------
cf3> Extended system discovery is only available in CFEngine Enterprise
cf3> Additional hard class defined as: 64_bit
cf3> Additional hard class defined as: linux_2_6_32_131_0_15_el6_x86_64
cf3> Additional hard class defined as: linux_x86_64
cf3> Additional hard class defined as: linux_x86_64_2_6_32_131_0_15_el6_x86_64
cf3> GNU autoconf class from compile time: compiled_on_linux_gnu
cf3> Address given by nameserver: 192.168.122.110
cf3> No interface exception file /var/cfengine/inputs/ignore_interfaces.rx
cf3> Interface 1: lo
cf3> Interface 2: eth0
cf3> IP address of host set to 192.168.122.110
cf3> Trying to locate my IPv6 address
cf3> Found IPv6 address fe80::5054:ff:fe97:3232
cf3> Looking for environment from cf-monitord...
cf3> Loading environment...
cf3> Environment data loaded
cf3> This appears to be a redhat (or redhat-based) system.
cf3> Looking for redhat linux info in 'Red Hat Enterprise Linux Server release 6.1 (Santiago)'
cf3> Found 1 processor
cf3> ***********************************************************
cf3>  Loading persistent classes 
cf3> ***********************************************************
cf3> ***********************************************************
cf3>  Loaded persistent memory 
cf3> ***********************************************************
cf3> This agent is bootstrapped to '192.168.122.110'
There is no readable input file at '/var/cfengine/inputs/mod.cf'. (stat: No such file or directory)
[root@rhel6 ~]# cp mod.cf /var/cfengine/inputs/
[root@rhel6 ~]# cf-agent -vlf mod.cf 
cf3> Work directory is /var/cfengine
cf3> Looking for a source of entropy in '/var/cfengine/randseed'
cf3> Making sure that locks are private...
cf3> Checking integrity of the state database
cf3> Checking integrity of the module directory
cf3> Checking integrity of the PKI directory
cf3> Loaded private key at '/var/cfengine/ppkeys/localhost.priv'
cf3> Loaded public key '/var/cfengine/ppkeys/localhost.pub'
cf3> Setting cfengine default port to 5308, '5308'
cf3> Reference time set to 'Tue Jan 14 12:48:32 2014'
cf3> CFEngine Core 3.5.2
cf3> ------------------------------------------------------------------------
cf3> Host name is: rhel6
cf3> Operating System Type is linux
cf3> Operating System Release is 2.6.32-131.0.15.el6.x86_64
cf3> Architecture = x86_64
cf3> Using internal soft-class linux for host rhel6
cf3> The time is now Tue Jan 14 12:48:32 2014
cf3> ------------------------------------------------------------------------
cf3> Extended system discovery is only available in CFEngine Enterprise
cf3> Additional hard class defined as: 64_bit
cf3> Additional hard class defined as: linux_2_6_32_131_0_15_el6_x86_64
cf3> Additional hard class defined as: linux_x86_64
cf3> Additional hard class defined as: linux_x86_64_2_6_32_131_0_15_el6_x86_64
cf3> GNU autoconf class from compile time: compiled_on_linux_gnu
cf3> Address given by nameserver: 192.168.122.110
cf3> No interface exception file /var/cfengine/inputs/ignore_interfaces.rx
cf3> Interface 1: lo
cf3> Interface 2: eth0
cf3> IP address of host set to 192.168.122.110
cf3> Trying to locate my IPv6 address
cf3> Found IPv6 address fe80::5054:ff:fe97:3232
cf3> Looking for environment from cf-monitord...
cf3> Loading environment...
cf3> Environment data loaded
cf3> This appears to be a redhat (or redhat-based) system.
cf3> Looking for redhat linux info in 'Red Hat Enterprise Linux Server release 6.1 (Santiago)'
cf3> Found 1 processor
cf3> ***********************************************************
cf3>  Loading persistent classes 
cf3> ***********************************************************
cf3> ***********************************************************
cf3>  Loaded persistent memory 
cf3> ***********************************************************
cf3> This agent is bootstrapped to '192.168.122.110'
cf3> Input file is outside default repository, validating it
cf3> Promises seem to change
cf3> Input file is changed since last validation, validating it
cf3> Verifying the syntax of the inputs...
cf3> Checking policy with command '"/var/cfengine/bin/cf-promises" -c "/var/cfengine/inputs/mod.cf"'
cf3> Parsing file '/var/cfengine/inputs/mod.cf'
cf3> Resolving variables in bundle 'main'
cf3> Running full policy integrity checks
cf3>  -> Hard classes = { 127_0_0_1 192_168_122_110 1_cpu 64_bit Afternoon Day14 GMT_Hr7 Hr12 Hr12_Q4 January Lcycle_1 Min45_50 Min48 PK_MD5_811fd0d062eb81c52cad26cd7718da93 Q4 Tuesday Yr2014 agent any cfengine cfengine_3 cfengine_3_5 cfengine_3_5_2 cfengine_in_high community_edition compiled_on_linux_gnu cpu0_high cpu_high diskfree_high_normal entropy_misc_in_low entropy_misc_out_low entropy_postgresql_in_low entropy_postgresql_out_low fe80__5054_ff_fe97_3232 inform_mode ipv4_127 ipv4_127_0 ipv4_127_0_0 ipv4_127_0_0_1 ipv4_192 ipv4_192_168 ipv4_192_168_122 ipv4_192_168_122_110 linux linux_2_6_32_131_0_15_el6_x86_64 linux_x86_64 linux_x86_64_2_6_32_131_0_15_el6_x86_64 linux_x86_64_2_6_32_131_0_15_el6_x86_64__1_SMP_Tue_May_10_15_42_40_EDT_2011 localhost localhost4 localhost4_localdomain4 localhost_localdomain mac_52_54_00_97_32_32 messages_high_normal net_iface_eth0 net_iface_lo otherprocs_high redhat redhat_6 redhat_6_1 redhat_s redhat_s_6 redhat_s_6_1 rhel6 rootprocs_high_normal smtp_in_high ssh_in_high users_high verbose_mode x86_64}
cf3>  -> Additional classes = {}
cf3>  -> Negated classes = {}
cf3> Executing and using module ["/var/cfengine/modules/return_index.pl" x 3]
cf3> Module context 'return_index_pl'
M '"/var/cfengine/modules/return_index.pl" x 3': Couldn't run '/var/cfengine/modules/return_index.pl'. (execv: No such file or directory)
cf3> Resolving variables in bundle 'main'
cf3> Additional class defined: am_policy_hub
cf3> Setting session ID, becoming process group leader
cf3>  -> Bundlesequence =>  {'main'}
cf3> *****************************************************************
cf3> BUNDLE main
cf3> *****************************************************************
cf3> 

cf3>    =========================================================
cf3>    classes in bundle main (1)
cf3>    =========================================================
cf3> 

cf3> Executing and using module ["/var/cfengine/modules/return_index.pl" x 3]
cf3> Module context 'return_index_pl'
M '"/var/cfengine/modules/return_index.pl" x 3': Couldn't run '/var/cfengine/modules/return_index.pl'. (execv: No such file or directory)
cf3> Adding local bundle class 'ok'
cf3> Resolving variables in bundle 'main'
cf3>      +  Private classes augmented:
cf3>      +       ok
cf3>      -  Private classes diminished:
cf3> 

cf3>    =========================================================
cf3>    commands in bundle main (1)
cf3>    =========================================================
cf3> 

cf3>     .........................................................
cf3>      Promise's handle: ''
cf3>      Promise made by: '/bin/ls -l /var/cfengine/modules/return_index.pl'
cf3>     .........................................................
cf3> 

cf3> Promiser string contains a valid executable '/bin/ls' - ok
Executing 'no timeout' ... '/bin/ls -l /var/cfengine/modules/return_index.pl'
cf3> (Setting umask to 77)
cf3> Additional promise info: source path '/var/cfengine/inputs/mod.cf' at line 12
cf3> Finished command related to promiser '/bin/ls -l /var/cfengine/modules/return_index.pl' -- succeeded
Q: ".../bin/ls -l /var": -rwxr-xr-x. 1 root root 630 Jan 13 15:24 /var/cfengine/modules/return_index.pl

Last 1 quoted lines were generated by promiser '/bin/ls -l /var/cfengine/modules/return_index.pl'
Completed execution of '/bin/ls -l /var/cfengine/modules/return_index.pl'
cf3>     .........................................................
cf3>      Promise's handle: ''
cf3>      Promise made by: '/bin/cat /var/cfengine/modules/return_index.pl'
cf3>     .........................................................
cf3> 

cf3> Promiser string contains a valid executable '/bin/cat' - ok
Executing 'no timeout' ... '/bin/cat /var/cfengine/modules/return_index.pl'
cf3> (Setting umask to 77)
cf3> Additional promise info: source path '/var/cfengine/inputs/mod.cf' at line 13
cf3> Finished command related to promiser '/bin/cat /var/cfengine/modules/return_index.pl' -- succeeded
Q: ".../bin/cat /var/c": #!/usr/bin/perl
Q: ".../bin/cat /var/c": # Prints an ordered number slist useful for ordered indexes.
Q: ".../bin/cat /var/c": sub error{
Q: ".../bin/cat /var/c":    $err = shift;
Q: ".../bin/cat /var/c":    print "Error: $err 
Q: ".../bin/cat /var/c": Usage return_index.pl <list var name> <positive integer>
Q: ".../bin/cat /var/c": Return Cfengine module array from 0 to given argument";
Q: ".../bin/cat /var/c": }
Q: ".../bin/cat /var/c": # validate
Q: ".../bin/cat /var/c": if ( scalar @ARGV != 2 ){
Q: ".../bin/cat /var/c":    error( "Wrong numer of args.");
Q: ".../bin/cat /var/c":    exit 1
Q: ".../bin/cat /var/c": }
Q: ".../bin/cat /var/c": $var_name = $ARGV[0];
Q: ".../bin/cat /var/c": $index_length = $ARGV[1];
Q: ".../bin/cat /var/c": if ( $index_length !~ m/^\d+$/ ){
Q: ".../bin/cat /var/c":    error( "Invalid arguement, integer expected." );
Q: ".../bin/cat /var/c":    exit 2
Q: ".../bin/cat /var/c": }
Q: ".../bin/cat /var/c": # main matter
Q: ".../bin/cat /var/c": print "\@$var_name= { ";
Q: ".../bin/cat /var/c": foreach $i ( 0 .. ($index_length - 1) ){
Q: ".../bin/cat /var/c":    print "'$i'";
Q: ".../bin/cat /var/c":    if ( $i < ($index_length - 1)) {
Q: ".../bin/cat /var/c":        print ', ';
Q: ".../bin/cat /var/c":    }
Q: ".../bin/cat /var/c": }
Q: ".../bin/cat /var/c": print "}\n";

Last 28 quoted lines were generated by promiser '/bin/cat /var/cfengine/modules/return_index.pl'
Completed execution of '/bin/cat /var/cfengine/modules/return_index.pl'
cf3> 

cf3>    =========================================================
cf3>    reports in bundle main (1)
cf3>    =========================================================
cf3> 

cf3>     .........................................................
cf3>      Promise's handle: ''
cf3>      Promise made by: 'return_index_pl => ${return_index_pl.x}'
cf3>     .........................................................
cf3> 

cf3> Additional promise info: source path '/var/cfengine/inputs/mod.cf' at line 17
cf3> Report: return_index_pl => ${return_index_pl.x}
R: return_index_pl => ${return_index_pl.x}
cf3> 

cf3>    =========================================================
cf3>    classes in bundle main (2)
cf3>    =========================================================
cf3> 

cf3> Executing and using module ["/var/cfengine/modules/return_index.pl" x 3]
cf3> Module context 'return_index_pl'
M '"/var/cfengine/modules/return_index.pl" x 3': Couldn't run '/var/cfengine/modules/return_index.pl'. (execv: No such file or directory)
cf3> Resolving variables in bundle 'main'
cf3>      +  Private classes augmented:
cf3>      +       ok
cf3>      -  Private classes diminished:
cf3> 

cf3>    =========================================================
cf3>    commands in bundle main (2)
cf3>    =========================================================
cf3> 

cf3> 

cf3>    =========================================================
cf3>    reports in bundle main (2)
cf3>    =========================================================
cf3> 

cf3> 

cf3>    =========================================================
cf3>    classes in bundle main (3)
cf3>    =========================================================
cf3> 

cf3> Executing and using module ["/var/cfengine/modules/return_index.pl" x 3]
cf3> Module context 'return_index_pl'
M '"/var/cfengine/modules/return_index.pl" x 3': Couldn't run '/var/cfengine/modules/return_index.pl'. (execv: No such file or directory)
cf3> Resolving variables in bundle 'main'
cf3>      +  Private classes augmented:
cf3>      +       ok
cf3>      -  Private classes diminished:
cf3> 

cf3>    =========================================================
cf3>    commands in bundle main (3)
cf3>    =========================================================
cf3> 

cf3> 

cf3>    =========================================================
cf3>    reports in bundle main (3)
cf3>    =========================================================
cf3> 

cf3> Bundle Accounting Summary for 'main'
cf3> Promises kept in 'main' = 0
cf3> Promises not kept in 'main' = 0
cf3> Promises repaired in 'main' = 3
cf3> Aggregate compliance (promises kept/repaired) for bundle 'main' = 100.0%
cf3> No lock purging scheduled
cf3> Logging total compliance, total 'Outcome of version (not specified) (agent-0): Promises observed to be kept 0%, Promises repaired 100%, Promises not repaired 0%'
neilhwatson commented 10 years ago

Do you have selinux enforcement on? What are the results of 'sestatus'? Can you run the module in the shell?

raags commented 10 years ago

It was perl :( there was no perl interpreter installed on the system for some reason. Thanks for your help!