Skip to content

Commit

Permalink
Merge branch 'release/0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
TizianoPerrucci committed Feb 4, 2015
2 parents f83ef3c + 57a6f51 commit 25e0675
Show file tree
Hide file tree
Showing 19 changed files with 344 additions and 99 deletions.
17 changes: 17 additions & 0 deletions AUTHORS.rst
@@ -0,0 +1,17 @@
Prudentia is written and maintained by Tiziano Perrucci and various contributors:

Development Lead
````````````````

- Tiziano Perrucci <tiziano@startersquad.com> `@TizianoPerrucci <https://github.com/TizianoPerrucci>`_


Patches, Suggestions and Contributions
``````````````````````````````````````

- Iwein Fuld `@iwein <https://github.com/iwein>`_
- Dmitry Evseev `@dmitryevseev <https://github.com/dmitryevseev>`_
- Albert Sikkema `@asikkema <https://github.com/asikkema>`_
- Anna Nachesa `@ashalynd <https://github.com/ashalynd>`_
- Sebastian Sastre `@sebastianconcept <https://github.com/sebastianconcept>`_
- Craig Latta `@ccrraaiigg <https://github.com/ccrraaiigg>`_
110 changes: 110 additions & 0 deletions HISTORY.rst
@@ -0,0 +1,110 @@
Release History
---------------

0.7 (2015-02-03)
++++++++++++++++

**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.
60 changes: 32 additions & 28 deletions README.rst
@@ -1,29 +1,29 @@
Prudentia |build-status| |pypi-downloads|
=========================================
Prudentia |build-status| |pypi-downloads| |pypi-version|
========================================================
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, through
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 main automation system, so it easily understand playbooks.
A playbook is one of the information needed to define a Prudentia Box.
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 operation on them
* a CLI_ (supporting auto-completion) used to interactively define Boxes and run operations on them
* Here-Document_ format to script Prudentia environments
* Provision existing server that can be accessed trough SSH
* Manage the lifecycle of a Box that has been created through Prudentia
* Create Boxes using one of the available providers
* 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
* 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.

Expand Down Expand Up @@ -51,36 +51,36 @@ To uninstall:
Box operations
--------------
Simple providers (e.g. Local provider or SSH provider) supports the following 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 box in the registry
* *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 allow you to change the
life cycle of 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 (refers to the `phoenix server`_)
* *phoenix*: shortcut for stop -> destroy -> create -> start -> provision (citing `phoenix server`_ Martin Fowler's article)

Usage
-----
We'll show a usage example of the SSH provider bundled with Prudentia.

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

.. code-block:: bash
$ prudentia ssh
Check what the SSH provider can do using tab completion::
Check what the Ssh provider can do using tab completion::

(Prudentia > Ssh)
EOF help list provision reconfigure register set unregister unset
Expand All @@ -93,8 +93,8 @@ Let's start registering a new box::
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 sanity check in our tests).
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`::

Expand All @@ -107,15 +107,15 @@ So let's continue using the `tasks.yml`::
Box example -> (/path/to/prudentia/examples/boxes/tasks.yml, tasks-host, ip.of.your.server, _your_user_) added.

You will notice for some questions Prudentia gives us a suggested answer within `[ ]`. For instance the Box name is been
suggested as `tasks-host`, if you like the suggestion just press enter to choose it.
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 again the definition of 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::
Now that we have double-checked that our Box has been registered, we can provision it::

(Prudentia > Ssh) provision example
Expand Down Expand Up @@ -173,17 +173,18 @@ The same sequence of operations can be executed using the `Here-Document`_ input
_your_user_
provision tasks-host
unregister tasks-host
EOF
This is the easiest example I could come up with to show you the use of the SSH provider bundled in Prudentia.
This shows how to use the SSH provider. If you got curious enough I invite you to check out the other providers as well.
I invite you to checkout the other providers.
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
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.
Expand Down Expand Up @@ -215,3 +216,6 @@ You can e-mail me at:
.. |pypi-downloads| image:: https://pypip.in/d/prudentia/badge.png
:target: https://pypi.python.org/pypi/prudentia
:alt: PyPI: Package status
.. |pypi-version| image:: https://badge.fury.io/py/prudentia.png
:target: http://badge.fury.io/py/prudentia
:alt: PyPI: Package version
9 changes: 3 additions & 6 deletions bin/prudentia
Expand Up @@ -9,6 +9,7 @@ from prudentia.cli import CLI


if __name__ == "__main__":
os.environ['PYTHONUNBUFFERED'] = '1'
PRUDENTIA_USER_DIR = path.join(path.expanduser('~'), 'prudentia')

if not os.path.exists(PRUDENTIA_USER_DIR):
Expand All @@ -25,12 +26,8 @@ if __name__ == "__main__":

exit_error = 0
if len(sys.argv) > 1:
env = sys.argv[1]
one_cmd_executed = cli.do_use(env)
if not one_cmd_executed:
cli.cmdloop()
else:
exit_error = 0 if cli.env_cli.provider.provisioned else 1
one_cmd_provisioned = cli.do_use(sys.argv[1], *sys.argv[2:])
exit_error = 0 if one_cmd_provisioned else 1
else:
cli.cmdloop()

Expand Down
2 changes: 2 additions & 0 deletions examples/boxes/tasks.yml
Expand Up @@ -7,9 +7,11 @@
tasks:
- name: Uname
command: uname -a
tags: uname

- name: Shuffle
debug: msg={{ item }}
with_items: "{{ mylist | shuffle }}"
tags: shuffle

- include: "{{ prudentia_dir }}/tasks/noop.yml"
16 changes: 15 additions & 1 deletion prudentia.sh
@@ -1,5 +1,19 @@
#!/bin/bash

#http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
SOURCE="${BASH_SOURCE[0]}"
# resolve $SOURCE until the file is no longer a symlink
while [ -h "${SOURCE}" ]; do
DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
SOURCE="$(readlink "${SOURCE}")"
# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
[[ ${SOURCE} != /* ]] && SOURCE="${DIR}/${SOURCE}"
done
DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"

# Change cwd in Prudentia dir
cd ${DIR}

if [ -z "$( which python )" ]; then
echo "Please, install Python (>=2.6)."
exit 1
Expand All @@ -23,4 +37,4 @@ then
pip install -r ./requirements.txt
fi

PYTHONPATH=. PYTHONUNBUFFERED=1 bin/prudentia "$@" 2>&1
PYTHONPATH=. bin/prudentia "$@" 2>&1
5 changes: 4 additions & 1 deletion prudentia/Vagrantfile.j2
Expand Up @@ -11,6 +11,9 @@ Vagrant.configure("2") do |config|
vb.customize ["modifyvm", :id, "--memory", "{{ b.extra.mem }}"]
vb.customize ["modifyvm", :id, "--vtxvpid", "off"]
vb.customize ["modifyvm", :id, "--cpus", "1"]

# Enables symlinks feature in VirtualBox (https://github.com/mitchellh/vagrant/issues/713#issuecomment-4416384)
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end

{% for s in b.extra.shares %}
Expand All @@ -19,4 +22,4 @@ Vagrant.configure("2") do |config|
end
{% endfor %}

end
end
2 changes: 1 addition & 1 deletion prudentia/__init__.py
@@ -1,4 +1,4 @@
__version__ = '0.6'
__version__ = '0.7'
__author__ = 'Tiziano Perrucci'


Expand Down
1 change: 1 addition & 0 deletions prudentia/ansible.cfg
@@ -1,6 +1,7 @@
[defaults]
host_key_checking=False
nocows=1
log_path=/tmp/prudentia-ansible.log

[paramiko_connection]
record_host_keys=False

0 comments on commit 25e0675

Please sign in to comment.