Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
M ubuntu:16.04
MAINTAINER Boris Pavlovic <bpavlovic@mirantis.com>
FROM ubuntu:16.04
MAINTAINER Kirill Zaitsev <k.zaitsev@me.com>

RUN apt-get update && apt-get install --yes wget git-core python-dev build-essential

Expand All @@ -18,5 +18,5 @@ RUN pip install -r requirements.txt
WORKDIR /app/runbook
EXPOSE 5000

ENTRYPOINT ["gunicorn"]
CMD ["-w", "4", "-b", "0.0.0.0:5000", "main:app"]
ENTRYPOINT ["bash"]
CMD ["main.sh"]
32 changes: 32 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,35 @@ Cloud Runbooks


Stores and allows running Cloud automation Runbooks

How To Use & Run
----------------

Build Docker Image
~~~~~~~~~~~~~~~~~~

.. code-block:: sh

docker build -t runbook:latest .


Run Docker Container
~~~~~~~~~~~~~~~~~~~~


.. code-block:: sh

# Update ~/health/etc/config.json file to match your configuration
vi ~/runbook/etc/writer-config.json
vi ~/runbook/etc/reader-config.json
# Run container
docker run -d --name runbook-app -v ~/etc/runbook:/etc/runbook -p 6000:5000 -p 6001:5001 --env=RUN_RUNBOOK_WRITER_API=1 --env=RUN_RUNBOOK_READER_API=1 runbook


Get App Logs
~~~~~~~~~~~~

.. code-block:: sh

docker logs runbook-app

14 changes: 14 additions & 0 deletions runbook/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

RUNBOOK_INIT_INDICES_FOR="${RUNBOOK_INIT_INDICES_FOR:-"writer"}"

if [ ! -z "$RUN_RUNBOOK_WRITER_API" ]; then
runbook-init-storage
gunicorn -w 4 -b 0.0.0.0:5001 runbook.main_writer:app &
fi

if [ ! -z "$RUN_RUNBOOK_READER_API" ]; then
gunicorn -w 4 -b 0.0.0.0:5000 runbook.main_reader:app &
fi

wait -n
6 changes: 5 additions & 1 deletion runbook/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import json
import logging
import os

import elasticsearch

Expand Down Expand Up @@ -79,6 +80,8 @@ def ensure_index(index, api_type):
mapping = json.dumps(ES_MAPPINGS)
LOG.info("Creating Elasticsearch index: {}".format(index))
es.indices.create(index, body=mapping)
else:
LOG.info("Elasticsearch index: '{}' already exists".format(index))
except elasticsearch.exceptions.ElasticsearchException:
LOG.exception("Was unable to get or create index: {}".format(index))
raise
Expand All @@ -92,4 +95,5 @@ def configure_regions(api_type="writer"):


if __name__ == "__main__":
configure_regions()
api_type = os.environ.get("RUNBOOK_INIT_INDICES_FOR", "writer")
configure_regions(api_type)
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ packages =

[entry_points]
console_scripts =
runbook = runbook.main:main
runbook-reader-api = runbook.main_reader:main
runbook-writer-api = runbook.main_writer:main
runbook-init-storage = runbook.storage:configure_regions

[global]
setup-hooks =
Expand Down