Code Monkey home page Code Monkey logo

evolve_cfengine_freelib's Introduction

Copyright Neil H. Watson ( http://watson-wilson.ca ). For fresh updates visit: https://github.com/neilhwatson/evolve_cfengine_freelib

Version notice

A Branch for each version. Master is the latest bleeding edge.

License

Evolve_freelib.cf is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Introduction

The bundles contained in this CFEngine library primarily focus on data driven policy. Each such bundle takes a csv or JSON type delimited parameter file as shown in the common bundle efl_c.

Contents of the main library

Bundle Purpose
efl_skeleton A template for creating new bundles.
efl_c A collection of common tunable variables.
efl_main A bundle for calling other bundles, in order, using methods.
efl_chkconfig_disable_service Disable a service from starting at boot.
efl_chkconfig_enable_service Enable a service to start at boot.
efl_class_classmatch Creates namespace classes by matching existing class names.
efl_class_cmd_regcmp Creates namespace classes on the output of a shell command.
efl_class_expression Creates namespace classes from a class expression.
efl_class_hostname Creates namespace classs based on the hostname of the host.
efl_class_iprange Creates namespace classes based on the IP address of the host.
efl_class_returnszero Creates namespace classes using the return status of a shell command.
efl_command Configurable commands promises.
efl_copy_files Configurable file copy promises.
efl_delete_files Promises to delete files.
efl_edit_template Promise a file's contents using a template.
efl_file_perms Configurable file permissions promises.
efl_global_slists Set namespace scoped slists variables.
efl_global_strings Set namespace scoped strings variables.
efl_lastseen Report hosts seen in the last 24 hours.
efl_link Promise links.
efl_mon_cfengine Report CFEngine internal statistics.
efl_notseen Report hosts not seen in the last 24 hours.
efl_packages Promises to add, remove, or update packages.
efl_rcs_pull Promises to keep a checked out copy of version control current.
efl_server Promise server access rules.
efl_service Promises to configure and start a service.
efl_start_service Promises to start a service that is not running.
efl_sysctl_conf_file Promises sysctl.conf kernel settings.
efl_sysctl_live Promises live sysctl Linux kernel settings.

An alternate inputs update file

The file efl_update.cf is an alternate high performance, yet simplified, collection of bundles to keep CFEngine's inputs directory up to date. See the in docs for more information.

Requirements

  1. Cfengine Core 3.10.0 or higher. There are older 3.10, 3.6, 3.5, and 3.4 branches too.
  2. The Cfengine standard library.
  3. Perl of any version and no special modules (only when using with Delta Reporting).

Futher reading

  1. INSTALL.md
  2. HOWTO.md
  3. EFL related articles: http://watson-wilson.ca/blog/tag/EFL

Reporting

If you are interested in reporting on the outcome of EFL promises please look at Delta Reporting: https://github.com/neilhwatson/delta_reporting

evolve_cfengine_freelib's People

Contributors

jremond avatar neilhwatson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

evolve_cfengine_freelib's Issues

Add docker management bundle

Requirements:

  1. Promise Dockerfile and supporting files from cf-serverd.
  2. If above promise is repaired then 'force' both image build and container restart. Use --restart=unless-stopped for run and --rm=true for images.
  3. If promise 1 is kept then ensure defined image is present and container is running.

How to do the last promise the least invasive way given CFEngine has not docker aware parts? Commands must be used.

Data required:

  1. File src on cf-serverd.
  2. File destination on agent host.
  3. Image and container name.
  4. Image tag (maybe)
  5. Docker capabilities.
  6. Volumes (nice to have)

Possible checks:

  1. docker images -q pcf_dns:latest
  2. docker ps -q --filter=name=pcf_dns

Bundle to manage docker images

Keep docker images current by checking existing images and build new ones from Dockerfiles if current ones are old or missing.

Getting info from Docker API

  1. Get creation time of image with given RepoTag:
    curl -s --unix-socket /run/docker.sock http://docker/images/json|jq '.[] | select( .RepoTags[] == "my_tag:latest" )|.Created''

Compare time against Dockerfile and support files' ctime. Invoke new build if Created is older.

new bundle for killing processes

A bundle to kill process that are long running, consuming too much memory, or not permitted by security. Consider not using CSV for this an all new bundles.

Parameters:

  1. Class
  2. Process command regex
  3. Process_owner regex list
  4. Minimum rsize in kilobytes
  5. Minimum elapsed process time in minutes
  6. Minimum number of processes

Because number of processes is not in a process select body, it will be tricky to combine. Will probably need three process promises.

Bundles system auditing

A set of bundles for passive host auditing by setting classes. Combine them with the test bundle for TAP output.

  1. Is process running?
  2. Is rpm installed?
  3. Is sysctl value set?
  4. Is systctl value in conf file?
  5. Does file have correct hash sum?
  6. Is service enabled for boot start?
  7. Is service disabled for boot start?
  8. Are file permissions correct?

Expected input:
class, class to set, test

Or class to set should be base class and prefix it with ok or not_ok based on pass or fail.

obsolete promise type meta in efl_server_csv, efl_server_json

Not sure if I'm doing something wrong, but with cfengine-community 3.7.2, I see this in the logs:

'''
2016-03-31T05:43:28.256199-04:00 myserver [20596]: CFEngine(server) Trying to evaluate unsupported/obsolete promise type meta in server bundle efl_server_csv
2016-03-31T05:43:28.256764-04:00 myserver [20596]: CFEngine(server) Trying to evaluate unsupported/obsolete promise type meta in server bundle efl_server_json
'''

Is meta really deprecated, or should I file a bug with cfengine to have this message removed?

promise summary not logging cfengine-3.10-1 and RHEL7

promise outcome not logged , only below line in /var/cfengine/delta_reporting/log/promises
BEGIN 2017-06-12T05:37:32-0500
copied evolve_freelib.cf and efl_common.cf to masterfiles/lib/EFL
and efl.cf to masterfiles/services/autorun
followed install document and created efl_data and other required files.

also how we can debug logging promise outcome.

the freelib produces the following errors

cfengine 3.7.0

error: A variable seems to have been used for the name of the method. In this case, the promiser also needs to contain the unique name of the method
error: A method attempted to use a bundle '${d[0][bundle]}' that was apparently not defined
error: Method 'efl_bug2638' failed in some repairs
error: A variable seems to have been used for the name of the method. In this case, the promiser also needs to contain the unique name of the method
error: A method attempted to use a bundle '${d[1][bundle]}' that was apparently not defined
error: Method 'efl_bug2638' failed in some repairs
error: A variable seems to have been used for the name of the method. In this case, the promiser also needs to contain the unique name of the method
error: A method attempted to use a bundle '${d[2][bundle]}' that was apparently not defined
error: Method 'efl_bug2638' failed in some repairs
error: Method 'efl_main' failed in some repairs
error: Method 'efl_run' failed in some repairs

Library seems to fail on CFE 3.5

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";

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.