Skip to main content

Continuous Deployment toolkit.

Project description

Status Health Coverage Downloads Version License

Prudentia is a Continuous Deployment toolkit written in Python.

Mission

Prudentia’s mission is to help you to get production (or any other environment) ready in minutes instead of days, by streamlining all the actions needed to provision your architectural components.

Features

Prudentia uses Ansible as its main automation system, so it easily understands Ansible playbooks. A playbook is one of the components needed to define a Prudentia Box.

Prudentia currently offers:

  • a CLI (supporting auto-completion) used to interactively define Boxes and run operations on them

  • Here-Document format to script Prudentia environments

  • provisioning of an existing server that can be accessed trough SSH

  • management of the lifecycle of a Box that has been created through Prudentia

  • creating Boxes using one of these providers:

    • Vagrant

    • DigitalOcean

    • local

    • ssh

Currently, all features work with Python 2.6 and 2.7. Work is under way to support Python 3.3+ in the same codebase.

Installation

To install prudentia:

$ pip install prudentia

It may be necessary to have root privileges, in which case:

$ sudo pip install prudentia

To uninstall:

$ pip uninstall prudentia

Box operations

Simple providers (e.g. Local provider or SSH provider) have the following operations available:

  • register: adds a new box definition to the registry

  • unregister: removes a box from the registry

  • reconfigure: changes the definition of an existing box

  • list: lists all boxes in the registry

  • set: defines or override a playbook variable

  • unset: removes variable

  • provision: runs tasks defined in the playbook associated with a box

Factory providers (e.g. Vagrant provider or DigitalOcean provider) extend simple providers and add allow you to change the box life cycle:

  • create: instantiate a new instance based of the box definition

  • restart: reloads the instance

  • stop: shuts down the instance

  • destroy: kill the instance

  • phoenix: shortcut for stop -> destroy -> create -> start -> provision (citing phoenix server Martin Fowler’s article)

  • status: returns the status of the instance

Usage

We’ll show a usage example of the SSH provider bundled with Prudentia.

Make sure you have a server that you can ssh into.

$ prudentia ssh

Check what the Ssh provider can do using tab completion:

(Prudentia > Ssh)
EOF          help         list         provision    reconfigure  register     set          unregister   unset

Let’s start registering a new box:

(Prudentia > Ssh) register
Specify the playbook path:

Now Prudentia is asking for a playbook path, and this is actually an Ansible playbook.

You can use one of the samples that you can find in the examples/boxes directory. For instance, the tasks.yml that will run some Ansible tasks that we’ve defined (those tasks are not that meaningful, but they are used as a sanity check in our tests).

So let’s continue using the tasks.yml:

(Prudentia > Ssh) register
Specify the playbook path: /path/to/prudentia/examples/boxes/tasks.yml
Specify the box name [default: tasks-host]:
Specify the address of the instance: ip.of.your.server
Specify the remote user [default: _your_user_]:
Specify the password for the remote user [default: ssh key]:

Box example -> (/path/to/prudentia/examples/boxes/tasks.yml, tasks-host, ip.of.your.server, _your_user_) added.

You will notice that, for some questions, Prudentia gives us a suggested answer within [ ]. For instance, the suggested Box name is tasks-host. If you like the suggestion, just press enter to choose it.

So far we’ve registered a Prudentia Box that can be used to play around. If you want to check the definition again:

(Prudentia > Ssh) list
example -> (/path/to/prudentia/examples/boxes/tasks.yml, tasks-host, ip.of.your.server, _your_user_)

Now that we have double-checked that our Box has been registered, we can provision it:

(Prudentia > Ssh) provision example

PLAY [tasks-host] ***************************************************************

GATHERING FACTS ***************************************************************
ok: [tasks-host]

TASK: [Uname] *****************************************************************
changed: [tasks-host] => {"changed": true, "cmd": ["uname", "-a"], "delta": "0:00:00.005527", "end": "2015-01-01 19:13:58.633534", "rc": 0, "start": "2015-01-01 19:13:58.628007", "stderr": "", "stdout": "Darwin tiziano-air 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64", "warnings": []}

TASK: [Shuffle] ***************************************************************
ok: [tasks-host] => (item=2) => {
    "item": 2,
    "msg": "2"
}
ok: [tasks-host] => (item=4) => {
    "item": 4,
    "msg": "4"
}
ok: [tasks-host] => (item=1) => {
    "item": 1,
    "msg": "1"
}
ok: [tasks-host] => (item=5) => {
    "item": 5,
    "msg": "5"
}
ok: [tasks-host] => (item=3) => {
    "item": 3,
    "msg": "3"
}

TASK: [No operation] **********************************************************
ok: [tasks-host] => {
    "msg": "Task noop executed."
}

PLAY RECAP ********************************************************************
tasks-host                  : ok=4    changed=1    unreachable=0    failed=0

Play run took 0 minutes

Now Prudentia has done the reasonable uninteresting uname, shuffling a list of ints and noop tasks for me on the remote machine.

The same sequence of operations can be executed using the Here-Document input:

$ prudentia ssh <<EOF
register
/path/to/prudentia/examples/boxes/tasks.yml
tasks-host
ip.of.your.server
_your_user_

provision tasks-host

unregister tasks-host
EOF

This shows how to use the SSH provider. If you got curious enough I invite you to check out the other providers as well.

More Info

Here you can find a guide on how to use Prudentia to provision a Digital Ocean droplet with the StarterSquad website on it.

Another important source of information is Iwein’s post that gives you an idea of what Continuous Delivery is, and where Prudentia fits into the flow.

Questions & Contributions

Questions, Contributions and Feedback are more than welcome.

You can checkout planned new features on the Trello Board. Feel free to create feature requests on github issues.

You can e-mail me at:

tiziano@startersquad.com

Release History

0.11 (2015-06-19)

Improvements

  • Suggests automatically latest Ubuntu 14.04 LTS 64bit image when creating DigitalOcean droplet.

  • Validates setting extra variables and show existing ones when running unset without arguments.

  • Updates examples.

  • Adds bundled tasks: osquery, ufw, add sudo user, zeromq, elastic search, collectd, mongodb 2.6.

  • Generalize bundled java task.

  • Upgrades to a newer version of nginx using proper apt repository.

  • Upgrades to SBT 0.13.8.

Bugfixes

  • Sets correctly the user that will run the webdriver manager.

0.10 (2015-05-12)

Improvements

  • Updates examples.

  • Upgrade to Ansible 1.9.1.

Bugfixes

  • Fixes buffering issue.

0.9.1 (2015-03-18)

Bugfixes

  • Fixes issue if cli history file doesn’t exist.

0.9 (2015-03-18)

Improvements

  • Enables cli history cross sessions.

  • Adds bundled task for adding ssh known host.

  • Adds status action for factory providers.

  • Upgrade to Ansible 1.8.4.

  • Improves examples.

  • Increases code quality.

0.8.1 (2015-02-15)

Bugfixes

  • Fixes tor bundled task.

Improvements

  • Makes postgresql and sbt parametrized tasks.

  • Improves ssh key bundled task using file module.

0.8 (2015-02-05)

Bugfixes

  • Fixes shared folder definition for Vagrant box.

  • Includes HISTORY in python setup manifest.

0.7 (2015-02-04)

Bugfixes

  • Fixes stop recreation DigitalOcean droplet when user reconfigures box without destroying it.

Improvements

  • Makes provision accept multiple tags.

  • Suggests tags during auto-completion filtering out the ones that have already been selected.

  • Enables symlinks feature in VirtualBox.

  • Registers an existing DigitalOcean droplet using the id.

Misc

  • Adds History and Authors.

0.6 (2015-01-07)

Bugfixes

  • Fix creation user dir.

Documentation

  • Described properly box operations.

0.5 (2015-01-07)

Bugfixes

  • Fixes error when running an action against a non existing box.

Improvements

  • Drops execution of the script to install Vagrant.

  • Publishes Prudentia on PyPI.

  • Adds Python 2.6 to Travis build options.

  • Refactor nodejs bundled task to use nvm (#11).

  • Hides password when user enters it during box definition (#10).

  • Executes extra checks when user inputs file paths (#8).

  • Updates Readme doc.

  • Updates and cleans up examples.

  • Creates Local Provider.

  • Adds bundled tasks: fontforge, opencv, noop, postgres, sbt, ssl-self-certificate, timezone.

Behavioral Changes

  • Restructures python packages.

  • Moves Prudentia environments directory under user home.

  • Avoids check and install Vagrant package when using Vagrant Provider.

Misc

  • Adds license.

0.4 (2014-02-09)

Bugfixes

  • Fixes several issue with Vagrantfile.

  • Fixes provisioning non existing box.

Improvements

  • Adds set/unset action used to set an environment variable.

  • Sets default for yes/no question if no answer was given.

  • Integrates Travis CI.

  • Suggest box name based on playbook hosts name.

  • Exit with error code 1 if one off cmd provisioning fails.

  • Add example box.

0.3 (2014-01-16)

Improvements

  • Creates DigitalOcean Provider and Ssh Provider.

  • Introduces Environment and Box entities.

  • Adds bundled tasks: chrome, protractor, mongodb, python.

  • Introduces bash utility.

0.2 (2013-10-15)

Bugfixes

  • Fixes provision without tags.

Improvements

  • Loads box playbook tags and use in action argument suggestion.

0.1 (2013-09-17)

Beginning

  • Adds script to install Vagrant and Ansible.

  • Creates Vagrant Provider with basic commands: add, remove, provision, phoenix, restart, destroy.

  • Adds bundled tasks: common-setup, git, github, java7, jenkins, mercurial, mysql, nginx, nodejs, redis, ruby, sbt, ssh-key, tor.

  • Provides tags support for provision action.

  • Adds shared folder to Vagrant box definition.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prudentia-0.11.tar.gz (57.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page