No Description

David Yurkiewicz 6eeef13ee5 config for part two 1 year ago
roles 6eeef13ee5 config for part two 1 year ago
.travis.yaml 1e74b02c4a updating readme + pylint recomendations 1 year ago
README.md bf8fe8c402 More updates to Readme 1 year ago
miniConfigApply.py bf8fe8c402 More updates to Readme 1 year ago
requirements.txt 1e74b02c4a updating readme + pylint recomendations 1 year ago

README.md

miniConfig

miniConfig is a python3 based minimal config management that focuses mainly on add/removing files and packages. miniConfig runs ssh in parallel to allow the management of multiple nodes.

Installation

miniConfig requires parallel-ssh and gevent. Install requirements by running:

pip install -r requirements.txt

Usage

miniConfig uses configurations files (config.json) under a "role" directory to apply config changes to remote host. The following directory structure should be followed:

── roles
    ├── role-config-1
    │   ├── config.json
    │   └── files
    │       └── info.php
    └── role-config-2
        ├── config.json
        └── files
            ├── foo.php
            └── index.php

Auth

The user and password for ssh can be configure by setting the following environment variables:

  • miniConfigUser

    export miniConfigUser='r00t'
    
  • miniConfigPass

    export miniConfigPass='p@ssw0rd'
    

config.json

Config files tell miniConfig what to do. Each role directory should have a config.json file.

Example config.json:

{
  "hosts": [
    "88.28.97.11",
    "88.18.18.13"
  ],
  "packages": [ {
    "add": ["apache2","php7.4","libapache2-mod-php7.4"],
    "remove": ["nginx"]
  }],
  "commands": [
    "cat /etc/issue"
  ],
  "files": [{
    "name": "index.php",
    "path": "/var/www/html",
    "owner": "www-data",
    "group": "www-data",
    "mode": "0775",
    "action": "add",
    "service_notify": "apache2"
  }]
}

There are four main sections in a config file:

hosts

List here the hosts you want to apply the configuration to:

  "hosts": [
    "88.28.97.11",
    "88.18.18.13"
  ],

packages

List here the packages you want to add and remove:

  "packages": [ {
    "add": ["apache2","php7.4","libapache2-mod-php7.4"],
    "remove": ["nginx"]
  }],

Note: Each time you apply a configuration, miniConfig will only do the add/remove action if necessary. It runs a verify step before running the action.

commands

List here the commands you want to run on the remote hosts:

  "commands": [
    "cat /etc/issue"
  ],

files

List here the files you want to copy to the remote hosts. The action key is mandatory, select either add or remmove depending on the desired outcome. service_notify is an optional key that can restart a specified service after the file has been add or remove:

  "files": [{
    "name": "index.php",
    "path": "/var/www/html",
    "owner": "www-data",
    "group": "www-data",
    "mode": "0775",
    "action": "add",
    "service_notify": "apache2"
  }]

Note: The files listed here must be included under roles/role-name/files directory. File ownership/group and mode are optional.

When using the service_notify key make sure to include the actual service name.

Applying configurations

Run miniConfigApply.py $rolename

miniConfig writes its log to stdout.

$ ./miniConfigApply.py webserver
[88.28.97.11] apache2 already installed. Nothing to do!
[88.18.18.13] apache2 already installed. Nothing to do!
[88.28.97.11] php7.4 already installed. Nothing to do!
[88.18.18.13] php7.4 already installed. Nothing to do!
[88.28.97.11] libapache2-mod-php7.4 already installed. Nothing to do!
[88.18.18.13] libapache2-mod-php7.4 already installed. Nothing to do!
[88.28.97.11]	f1281dc0e84f751e7d72728c476a4615  /var/www/html/index.php
[88.18.18.13] /var/www/html/index.php already on system/checksum match local file

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT