Useful scripts for initting a system.
Ir para arquivo
Zane C. B-H ac4d954360 cleanup of sagan_rules 2024-04-25 11:27:34 -05:00
lib cleanup of sagan_rules 2024-04-25 11:27:34 -05:00
share/templates a few more changes for lilith and ready for release 2024-04-16 00:37:03 -05:00
src_bin derp... actually commit missed commit 2024-04-19 09:48:02 -05:00
t sagan_rules does the in palce bit 2024-04-25 10:35:24 -05:00
.gitignore a few more changes for lilith and ready for release 2024-04-16 00:37:03 -05:00
.perlcriticrc use Fcntl also ProhibitBitwiseOperators is just dumb so disable it 2023-10-31 00:15:38 -05:00
.perltidyrc add perlcritic and perl tidy configs 2023-07-12 08:46:39 -05:00
Changes derp... actually commit missed commit 2024-04-19 09:48:02 -05:00
LICENSE Initial commit 2023-02-07 11:19:52 -06:00
MANIFEST sagan_rules does the in palce bit 2024-04-25 10:35:24 -05:00
Makefile.PL remove TOML::Tiny as a hard requirement... is only needed for one action now... all uses are via eval with use in the eval 2024-04-07 21:51:22 -05:00
README.md misc 2024-04-16 00:15:55 -05:00

README.md

Ixchel

!!!WARNING!!! Very much a work in progress and testing at this stage. !!!WARNING!!!

Configuration and templating system meant to be used Ansible or Rex. Config generated centeral and pushed out and templating/actions done based on that on the remote systems for purpose of continual integration pipe line for server configuration as well as setup.

Setup

CMDB Setup

First you will want to get a CMDB setup using like Shell:Var::Reader (CPAN).

This will make it easy to create easy to create the config used by Ixchel as well as config files that can easily be shared with other things.

Once you have everything setup and cmdb_shell_var_reader working, you are ready to move on to the next step.

Integration With Tooling

Rex

use Rex -feature => ['1.4'];
use File::Slurp;

group all => 'a.foo.bar', 'b.foo.bar;

set cmdb => {
              type           => 'TOML',
              path           => ./cmdb/,
              merge_behavior => 'LEFT_PRECEDENT',
              use_roles      => 1,
            };

desc 'Upload Server Confs';
task 'upload_server_confs',
        group => all',
        sub {
                my $remote_hostname = connection->server;

                mkdir('/usr/local/etc/ixchel');

                my @types = ( 'toml', 'yaml', 'json', 'shell' );
                foreach my $type (@types) {
                        my $type_dir = $type;
                        if ( $type eq 'shell' ) {
                                $type = 'sh';
                        }
                        my $upload_from = $type_dir . '_confs/' . $remote_hostname . '.' . $type;
                        if ( -f $upload_from ) {
                                my $content=read_file($upload_from);
                                file '/usr/local/etc/ixchel/server.' . $type, content => $content;
                        }
                } ## end foreach my $type (@types)
        };

Ansible

- hosts: "{{ host }}"
  order: sorted
  gather_facts: false
  ignore_errors: true
  ignore_unreachable: true
  become: true
  become_method: sudo
  serial: 1

  tasks:
  - name: Copy System JSON Conf Into Place
    ansible.builtin.copy:
      src: ./json_confs/{{ inventory_hostname }}.json
      dest: /usr/local/etc/ixchel/server.json

  - name: Copy System Shell Conf Into Place
    ansible.builtin.copy:
      src: ./shell_confs/{{ inventory_hostname }}.conf
      dest: /usr/local/etc/ixchel/server.conf

  - name: Copy System YAML Conf Into Place
    ansible.builtin.copy:
      src: ./yaml_confs/{{ inventory_hostname }}.yaml
      dest: /usr/local/etc/ixchel/server.yaml

  - name: Copy System TOML Conf Into Place
    ansible.builtin.copy:
      src: ./toml_confs/{{ inventory_hostname }}.toml
      dest: /usr/local/etc/ixchel/server.toml

And if you wish to use the generated JSON config file with a system in a Ansible task, it can be done like below.

- hosts: "{{ host }}"
  var_files:
    - ./json_confs/{{ inventory_hostname }}.json

Shell Scripts

If generating the configs via Shell::Var::Reader, the generated shell conf file can easily be included in sh, zsh, and bash scripts like below.

. /usr/local/etc/ixchel/server.sh

That said it is worth nothing these do not include any of the default variables for Ixchel. Only those that have been explicitely set via the CMDB.

Install

Perl modules needed.

  • Config::Tiny
  • Data::Dumper
  • File::Find::Rule
  • File::ShareDir
  • File::Slurp
  • Hash::Merge
  • JSON
  • JSON::Path
  • LWP::Simple
  • Module::List
  • Rex
  • String::ShellQuote
  • TOML::Tiny
  • Template
  • YAML::XS

Other Libraries.

  • libyaml

Debian

  1. apt-get install libconfig-tiny-perl libfile-find-rule-perl libfile-sharedir-perl libfile-slurp-perl libhash-merge-perl libjson-perl libjson-path-perl libwww-perl rex libstring-shellquote-perl libtemplate-perl libyaml-libyaml-perl cpanminus
  2. cpanm Ixchel

FreeBSD

  1. pkg intall p5-Config-Tiny p5-Data-Dumper p5-File-Find-Rule p5-File-ShareDir p5-File-Slurp p5-Hash-Merge p5-JSON p5-JSON-Path p5-libwww p5-Module-List p5-Rex p5-String-ShellQuote p5-Template-Toolkit p5-YAML-LibYAML p5-App-cpanminus
  2. cpanm Ixchel

TODO

  • sub path selection for xeno when passing hashes
  • Sagan config comparison
  • add in file_cleaner_by_du support
  • Apache config management(genearlized manner)
  • actions for...
    • Lilith
      • db server setup
    • CAPEv2
  • better documentation for Suricata outputs
  • lots more documentation