Skip to content

wekan/sps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple Provisioning System


Tired of maintaining installation scripts and separately a Markdown documentation (to be processed by MkDocs or Sphinx? You only have a few servers and not want to bring out the big guns?

So maybe Simple Provisioning System (SPS) is made for you : just write your markdown documentation and execute a part of it.

SPS is simple because :

  • It's less than 200 lines of code.
  • No dependencies' hell.
  • No need to install a specific agent, just the ssh server.
  • There is only one instruction and four keywords to remember.
  • Everything else, you already know how to do it.

Requirements

Must be installed : make and g++ which can compile in c++11, and ssh

Installation

Just compile to produce the sps binary:

make

Prepare the host

The host you want to provision must accept an ssh connexion with your gpg key :

ssh-keygen -t rsa -b 4096
ssh-copy-id -i ~/.ssh/id_rsa.pub root@server_to_provision

Few rules

Write your documentation in Markdown

  • The title level 1 mark # Target (at the beginning of the line) is used as a target like a target in a Makefile.
  • Only the (one or more) target enumerated on the parameters will be executed.
  • Default setting: shell commands are executed at the remote server side through the ssh command.
  • Shell commands have to be enclosed by triple backquote ``` at the beginning of the line.
  • Put the mark * REMOTE_EXECUTION (only that keyword) at the beginning of the line and at the previous line the shell command you want to be executed remotely (default setting)
  • Put the mark * LOCAL_EXECUTION (only that keyword) at the beginning of the line and at the previous line the shell command you want to be executed locally.
  • Put the following mark * PUT to send a local file source to the remote server to target (don't forget the back quotes) through scp.
* PUT `source` `target`
  • Put the following mark * GETto retrieve a remote file source to the local machine to target (don't forget the back quotes) through scp.
* GET `source` `target`
  • That's all ! Everything else will be ignored (in the same way the target you did not mention on the paramaters) : so you can add many comments without problem.

Execute

cat file.md | ./sps host target [target]

With:
  file.md    Markdown file
  host       Hostname or ip address where to deploy
  target     Section name in the markdown file.md 

Example of sps cards

Theses examples need a Debian Wheezy 64 bit for the host to provision (192.168.0.121 in our example).

Prepare the host

The host you want to provision must accept an ssh connexion with your gpg key :

ssh-keygen -t rsa -b 4096
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.121

MkDocs

Description

  • Generic installation of MkDocs for Debian Wheezy 64 bit.
  • This card respects the sps formalism (sps card)

Install

apt-get install python-pip python-dev
pip install mkdocs

Wekan Only-For-Testing (full stack)

Description

  • Wekan "The open-source web kanban." : https://wekan.io/
  • This documentation respects the sps formalism (sps card)
  • The purpose of this sps card is only for testing wekan and is obviously not suitable for production.
  • This sps card install a full stack mongodb nodejs wekan.
  • This installation was tested on a Debian Wheezy 64 bit and Devuan Jessie 64 bit inside VirtualBox (yes, the same script with the same packages for both)
  • Reference : Wekan Install

Requirements

  • The host to provision is a minimal installation of a Debian Wheezy 64 bit or a Devuan Jessie 64 bit
  • Be sure your compiled binary sps is in the $PATH
  • You already deployed your ssh key with
ssh-keygen -t rsa -b 4096
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.56.101
  • Then you can install and start the full stack with :
cat README.md | sps 192.168.56.101 "Install Wekan"

Install Wekan

apt-get install apt-transport-https

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb https://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.2 main" > /etc/apt/sources.list.d/mongodb-org-3.2.list

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv FDEB78E7
echo "deb https://soohwa.github.io/apt/debian wheezy main" > /etc/apt/sources.list.d/wekan-oft.list

apt-get update
apt-get install -y wekan-oft-0

Configuration

Change the default values in the file

/etc/default/wefork-oft-0

And restart the service

/etc/init.d/wekan-oft-0 restart

Now you can access to wekan http://192.168.56.101:3000/ if you changed ROOT_URL='http://192.168.56.101:3000' in the /etc/default/wefork-oft file.

Behind a reverse proxy

Your reverse proxy must be able to manage websocket : apache 2.2 in wheezy can not so you must install nginx from wheezy-backports (only apache >= 2.4 can).

If the external exposed port is 4444 and the internal port of wekan is 3000 you must set :

export ROOT_URL='http://yourserver:4444'
export PORT=3000

If your reverse proxy manage the SSL certificat for HTTPS, just replace http by https.

export ROOT_URL='https://yourserver:4444'
export PORT=3000

And set at least but (obviously) not sufficient :

server {
	listen       4444;
	server_name  yourserver;
	
	location {
		proxy_pass http://127.0.0.1:3000/;
	}
}

Other example

Other example

Create a file apache.md :

# Install

* PUT `custom.list` `/etc/apt/sources.list.d/`

```
apt-get update && apt-get -q -y install apache2
```

# Backup Conf

```
cd /etc/
tar cpzf /root/apache2.tar.gz apache2
```

* GET `/root/apache2.tar.gz` `.`

```
rm -f /root/apache2.tar.gz
```

* LOCAL_EXECUTION

```
date > last_conf_backup
```

# Remove All

```
apt-get -q -y --purge autoremove apache2
```

Execute

cat apache.md | ./sps 192.168.0.50 "Install" "Backup Conf"

Result

Only the section # Install and # Backup Conf will be executed, not the # Remove All section.

Future

I think this program is simple enough to be quickly understood and modified. This program is intentionally small and will remain because it does the job for me and I will not have the time to manage any contributions.

So I encourage you to fork it and/or transpose it in other languages.

About

Simple Provisioning System

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •