Skip to content

zimski/shaker

Repository files navigation

alt tag Automation CMS to create and manage automated task whithin your browser

how ?

Shaker is built on top of Bash with python/mako layer. Shaker let you edit your shell scripts and your environment variables file. You can also perform a syntax check and run the scripts.

In addition, Shaker allows you to manage your IT infrastructure, configure and create Virtual Machines from any HyperVisor, and push the configurations on your Network devices.

Finally, Shaker strength is its extendability. You can write you own modules whithin the web interface.

Install Shaker

git clone https://github.com/zimski/shaker.git
cd shaker && sudo bash setup.bash

please check if the version of node installed >= v0.10.XX if not, install NVM and get v0.10

https://github.com/creationix/nvm

curl https://raw.github.com/creationix/nvm/v0.3.0/install.sh | sh
(( reopen the terminal ))
nvm install 0.10
node app

Configuration

Go to shaker/py-sc/shaker.conf and edit with a valid account, this account will be used to ssh your localhost (if it's needed) You can create a dedicated user for shaker, in this case you will be able to control shaker permissions

change also the "pwd" with the curent shaker folder in your machine

localhost:
    user : shaker
    password: shakerpass@
pwd : /home/shaker

Start Shaker

node app.js

You can access to Shaker at this address : http://localhost:3002/

user :      admin
password :  admin

Example of Shaker Script

We have two files, the env file, where we fetch our variables, we can use Python code to fetch and Mako to template the file the second file is the bash script,

Full Proxmox create vm example:

In this case, we have a Proxmox cluster and a Shaker machine, we will run this script in the shaker machine, Shaker will perform an ssh to the Proxmox cluster and run our commands

env file

<%
  import redis
  r = redis.StrictRedis()
  data = r.hgetall(argv[0]) ## we get data from REDIS  DB, argv[] it's shaker parameters
  ## data its a dictionnary
  ## data = {ip : IP,mac : MAC , vmid: ID,..}
%>
script:
  host  : 192.168.0.8 # proxmox machine
  user  : root
  password  : cspolperdio

vm:
  mac       : ${data['mac'].upper()}
  # we can have vm paramters like cpu ram image ...ect

GET_VAR:
    - NEXT_VMID

UPDATE_VM_ID:
    code: |
        import redis
        r = redis.StrictRedis()
        r.hset('${argv[0]}','vmid',NEXT_VMID)
        print "update vm !"

shell file

NEXT_VMID=$(pvesh get cluster/nextid | sed 's/"//g')
mkdir /var/lib/vz/images/$NEXT_VMID
cp /var/lib/vz/images/111/base-111-disk-1.qcow2 /var/lib/vz/images/$NEXT_VMID/base-$NEXT_VMID-disk-1.qcow2
pvesh create /nodes/proxmox/qemu -vmid $NEXT_VMID -memory 2048 -sockets 1 -cores 2 -net0 e1000=${env['vm']['mac']},bridge=vmbr0 -ide0=local:$NEXT_VMID/base-$NEXT_VMID-disk-1.qcow2
echo "vm created"
$$ sk_console.get GET_VAR ## get variable from Proxmox machine
$$ rbox.py_run UPDATE_VM_ID ## update in our DB the curent VM_ID of the virtual machine
sleep 5 ; pvesh create /nodes/proxmox/qemu/$NEXT_VMID/status/start

we can call to internal shaker module with "$$", it's very easy to add new modules to shaker, you just have to add a python code in py-sc/modules/yourfile and add the name of your file in "__init__.py"

run it !

  • from terminal
python shaker.py -x -e <path to env file> -s <path to shell file>
  • from web interface alt tag

to be continued ...

About

Remote execution [ Bash with Python/Mako layer]

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published