Initial commit

This is initial commit of manila formula.

Change-Id: I3db2409bab10e8005a8c99c3899d19ced495469e
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..aa8e42a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+.kitchen
+tests/build/
+*.swp
+*.pyc
+.ropeproject
diff --git a/.gitreview b/.gitreview
index 09ca5a2..e736ca6 100644
--- a/.gitreview
+++ b/.gitreview
@@ -1,4 +1,4 @@
 [gerrit]
-host=172.16.48.254
+host=gerrit.mcp.mirantis.net
 port=29418
 project=salt-formulas/manila.git
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..7923057
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,74 @@
+---
+driver:
+  name: docker
+  hostname: manila.ci.local
+  use_sudo: false
+
+provisioner:
+  name: salt_solo
+  salt_install: bootstrap
+  salt_bootstrap_url: https://bootstrap.saltstack.com
+  salt_version: latest
+  require_chef: false
+  log_level: error
+  formula: manila
+  grains:
+    noservices: True
+  dependencies:
+    - name: linux
+      repo: git
+      source: https://github.com/salt-formulas/salt-formula-linux
+    - name: apache
+      repo: git
+      source: https://github.com/salt-formulas/salt-formula-apache
+  state_top:
+    base:
+      "*":
+        - linux.system
+        - apache
+        - manila
+  pillars:
+    top.sls:
+      base:
+        "*":
+          - linux_repo_openstack
+          - manila
+          - release
+  pillars-from-files:
+    linux_repo_openstack.sls: tests/pillar/repo_mcp_openstack_<%= ENV['OS_VERSION'] || 'pike' %>.sls
+
+verifier:
+  name: inspec
+  sudo: true
+
+platforms:
+  - name: <%= ENV['PLATFORM'] || 'ubuntu-xenial' %>
+    driver_config:
+      image: <%= ENV['PLATFORM'] || 'epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2016.3' %>
+      platform: ubuntu
+
+suites:
+
+  - name: server_cluster
+    provisioner:
+      pillars-from-files:
+        manila.sls: tests/pillar/server_cluster.sls
+      pillars:
+        release.sls:
+        share.sls:
+          manila:
+            share:
+              version: <%= ENV['OS_VERSION'] || 'pike' %>
+
+  - name: server_single
+    provisioner:
+      pillars-from-files:
+        manila.sls: tests/pillar/server_single.sls
+      pillars:
+        release.sls:
+          manila:
+            common:
+              version: <%= ENV['OS_VERSION'] || 'pike' %>
+
+# vim: ft=yaml sw=2 ts=2 sts=2 tw=125
+
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..0308d00
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,42 @@
+sudo: required
+services:
+  - docker
+
+install:
+  - pip install PyYAML
+  - pip install virtualenv
+  - |
+    test -e Gemfile || cat <<EOF > Gemfile
+    source 'https://rubygems.org'
+    gem 'rake'
+    gem 'test-kitchen'
+    gem 'kitchen-docker'
+    gem 'kitchen-inspec'
+    gem 'inspec'
+    gem 'kitchen-salt', :git => 'https://github.com/salt-formulas/kitchen-salt.git'
+  - bundle install
+
+env:
+  - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2016.3 OS_VERSION=pike SUITE=server_cluster
+  - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2016.3 OS_VERSION=pike SUITE=server_single
+  - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2017.7 OS_VERSION=pike SUITE=server_cluster
+  - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2017.7 OS_VERSION=pike SUITE=server_single
+
+before_script:
+  - set -o pipefail
+  - make test | tail
+
+script:
+  - test ! -e .kitchen.yml || bundle exec kitchen converge ${SUITE} || true
+  - test ! -e .kitchen.yml || bundle exec kitchen verify ${SUITE} -t tests/integration
+
+notifications:
+  webhooks:
+    urls:
+      - https://webhooks.gitter.im/e/6123573504759330786b
+    on_success: change  # options: [always|never|change] default: always
+    on_failure: never  # options: [always|never|change] default: always
+    on_start: never     # options: [always|never|change] default: always
+    on_cancel: never    # options: [always|never|change] default: always
+    on_error: never    # options: [always|never|change] default: always
+  email: false
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
new file mode 100644
index 0000000..1670a14
--- /dev/null
+++ b/CHANGELOG.rst
@@ -0,0 +1,6 @@
+manila formula
+==============
+
+2017.12 (2017-12-07)
+
+- Initial formula setup
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..7862bbb
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2017 Mirantis Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1043fbe
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,118 @@
+DESTDIR=/
+SALTENVDIR=/usr/share/salt-formulas/env
+RECLASSDIR=/usr/share/salt-formulas/reclass
+FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-\_]*')
+VERSION=$(shell grep version: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\.\-\_]*')
+VERSION_MAJOR := $(shell echo $(VERSION)|cut -d . -f 1-2)
+VERSION_MINOR := $(shell echo $(VERSION)|cut -d . -f 3)
+
+NEW_MAJOR_VERSION ?= $(shell date +%Y.%m|sed 's,\.0,\.,g')
+NEW_MINOR_VERSION ?= $(shell /bin/bash -c 'echo $$[ $(VERSION_MINOR) + 1 ]')
+
+MAKE_PID := $(shell echo $$PPID)
+JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)")))
+
+ifneq ($(subst -j,,$(JOB_FLAG)),)
+JOBS := $(subst -j,,$(JOB_FLAG))
+else
+JOBS := 1
+endif
+
+KITCHEN_LOCAL_YAML?=.kitchen.yml
+KITCHEN_OPTS?="--concurrency=$(JOBS)"
+KITCHEN_OPTS_CREATE?=""
+KITCHEN_OPTS_CONVERGE?=""
+KITCHEN_OPTS_VERIFY?=""
+KITCHEN_OPTS_TEST?=""
+
+all:
+	@echo "make install - Install into DESTDIR"
+	@echo "make test    - Run tests"
+	@echo "make kitchen - Run Kitchen CI tests (create, converge, verify)"
+	@echo "make clean   - Cleanup after tests run"
+	@echo "make release-major  - Generate new major release"
+	@echo "make release-minor  - Generate new minor release"
+	@echo "make changelog      - Show changes since last release"
+
+install:
+	# Formula
+	[ -d $(DESTDIR)/$(SALTENVDIR) ] || mkdir -p $(DESTDIR)/$(SALTENVDIR)
+	cp -a $(FORMULANAME) $(DESTDIR)/$(SALTENVDIR)/
+	[ ! -d _modules ] || cp -a _modules $(DESTDIR)/$(SALTENVDIR)/
+	[ ! -d _states ] || cp -a _states $(DESTDIR)/$(SALTENVDIR)/ || true
+	[ ! -d _grains ] || cp -a _grains $(DESTDIR)/$(SALTENVDIR)/ || true
+	# Metadata
+	[ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
+	cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
+
+test:
+	[ ! -d tests ] || (cd tests; ./run_tests.sh)
+
+release-major: check-changes
+	@echo "Current version is $(VERSION), new version is $(NEW_MAJOR_VERSION)"
+	@[ $(VERSION_MAJOR) != $(NEW_MAJOR_VERSION) ] || (echo "Major version $(NEW_MAJOR_VERSION) already released, nothing to do. Do you want release-minor?" && exit 1)
+	echo "$(NEW_MAJOR_VERSION)" > VERSION
+	sed -i 's,version: .*,version: "$(NEW_MAJOR_VERSION)",g' metadata.yml
+	[ ! -f debian/changelog ] || dch -v $(NEW_MAJOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version"
+	make genchangelog-$(NEW_MAJOR_VERSION)
+	(git add -u; git commit -m "Version $(NEW_MAJOR_VERSION)")
+	git tag -s -m $(NEW_MAJOR_VERSION) $(NEW_MAJOR_VERSION)
+
+release-minor: check-changes
+	@echo "Current version is $(VERSION), new version is $(VERSION_MAJOR).$(NEW_MINOR_VERSION)"
+	echo "$(VERSION_MAJOR).$(NEW_MINOR_VERSION)" > VERSION
+	sed -i 's,version: .*,version: "$(VERSION_MAJOR).$(NEW_MINOR_VERSION)",g' metadata.yml
+	[ ! -f debian/changelog ] || dch -v $(VERSION_MAJOR).$(NEW_MINOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version"
+	make genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION)
+	(git add -u; git commit -m "Version $(VERSION_MAJOR).$(NEW_MINOR_VERSION)")
+	git tag -s -m $(NEW_MAJOR_VERSION) $(VERSION_MAJOR).$(NEW_MINOR_VERSION)
+
+check-changes:
+	@git log --pretty=oneline --decorate $(VERSION)..HEAD | grep -Eqc '.*' || (echo "No new changes since version $(VERSION)"; exit 1)
+
+changelog:
+	git log --pretty=short --invert-grep --grep="Merge pull request" --decorate $(VERSION)..HEAD
+
+genchangelog: genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION)
+
+genchangelog-%:
+	$(eval NEW_VERSION := $(patsubst genchangelog-%,%,$@))
+	(echo "=========\nChangelog\n=========\n"; \
+	(echo $(NEW_VERSION);git tag) | sort -r | grep -E '^[0-9\.]+' | while read i; do \
+	    cur=$$i; \
+	    test $$i = $(NEW_VERSION) && i=HEAD; \
+	    prev=`(echo $(NEW_VERSION);git tag)|sort|grep -E '^[0-9\.]+'|grep -B1 "$$cur\$$"|head -1`; \
+	    echo "Version $$cur\n=============================\n"; \
+	    git log --pretty=short --invert-grep --grep="Merge pull request" --decorate $$prev..$$i; \
+	    echo; \
+	done) > CHANGELOG.rst
+
+kitchen-check:
+	@[ -e $(KITCHEN_LOCAL_YAML) ] || (echo "Kitchen tests not available, there's no $(KITCHEN_LOCAL_YAML)." && exit 1)
+
+kitchen: kitchen-check kitchen-create kitchen-converge kitchen-verify kitchen-list
+
+kitchen-create: kitchen-check
+	kitchen create ${KITCHEN_OPTS} ${KITCHEN_OPTS_CREATE}
+	[ "$(shell echo $(KITCHEN_LOCAL_YAML)|grep -Eo docker)" = "docker" ] || sleep 120
+
+kitchen-converge: kitchen-check
+	kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE} &&\
+	kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE}
+
+kitchen-verify: kitchen-check
+	[ ! -d tests/integration ] || kitchen verify -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
+	[ -d tests/integration ]   || kitchen verify ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
+
+kitchen-test: kitchen-check
+	[ ! -d tests/integration ] || kitchen test -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
+	[ -d tests/integration ]   || kitchen test ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
+
+kitchen-list: kitchen-check
+	kitchen list
+
+clean:
+	[ ! -x "$(shell which kitchen)" ] || kitchen destroy
+	[ ! -d .kitchen ] || rm -rf .kitchen
+	[ ! -d tests/build ] || rm -rf tests/build
+	[ ! -d build ] || rm -rf build
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..9b9dcbd
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,84 @@
+==============
+Manila Formula
+==============
+
+Manila is an OpenStack project to provide “Shared Filesystems as a service”.
+
+Sample pillars
+==============
+
+Single manila service
+
+.. code-block:: yaml
+
+    manila:
+      common:
+        database:
+          engine: mysql
+          host: 10.20.0.101
+          port: 3306
+          name: manila
+          user: manila
+          password: segreto
+        identity:
+          engine: keystone
+          host: 10.20.0.101
+          port: 35357
+          user: manila
+          password: segreto
+          region: RegionOne
+          tenant: service
+          endpoint_type: internalURL
+        cache:
+          engine: memcached
+          members:
+          - host: 10.20.0.102
+            port: 11211
+          - host: 10.20.0.103
+            port: 11211
+          - host: 10.20.0.104
+            port: 11211
+      api:
+        bind:
+          host: 10.20.0.102
+
+
+More information
+================
+
+* https://wiki.openstack.org/wiki/Telemetry
+* https://docs.openstack.org/developer/manila/
+* https://github.com/openstack/manila
+* https://bugs.launchpad.net/manila
+
+
+Documentation and Bugs
+======================
+
+To learn how to install and update salt-formulas, consult the documentation
+available online at:
+
+    http://salt-formulas.readthedocs.io/
+
+In the unfortunate event that bugs are discovered, they should be reported to
+the appropriate issue tracker. Use GitHub issue tracker for specific salt
+formula:
+
+    https://github.com/salt-formulas/salt-formula-manila/issues
+
+For feature requests, bug reports or blueprints affecting entire ecosystem,
+use Launchpad salt-formulas project:
+
+    https://launchpad.net/salt-formulas
+
+Developers wishing to work on the salt-formulas projects should always base
+their work on master branch and submit pull request against specific formula.
+
+You should also subscribe to mailing list (salt-formulas@freelists.org):
+
+    https://www.freelists.org/list/salt-formulas
+
+Any questions or feedback is always welcome so feel free to join our IRC
+channel:
+
+    #salt-formulas @ irc.freenode.net
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..565d2be
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+2017.6
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..c854387
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+salt-formula-manila (2017.6) xenial; urgency=medium
+
+  * Initial release
+
+ -- Vasyl Saienko vsaienko@mirantis.com  Tue, 29 Jun 2017 13:01:02 EET
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..99670d4
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,15 @@
+Source: salt-formula-manila
+Maintainer: Vasyl Saienko vsaienko@mirantis.com
+Section: admin
+Priority: optional
+Build-Depends: debhelper (>= 9), salt-master, python, python-yaml
+Standards-Version: 3.9.6
+Homepage: https://github.com/salt-formulas
+Vcs-Browser: https://github.com/salt-formulas/salt-formula-manila
+Vcs-Git: https://github.com/salt-formulas/salt-formula-manila.git
+
+Package: salt-formula-manila
+Architecture: all
+Depends: ${misc:Depends}
+Description: manila salt formula
+ Install and configure manila system.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..7c1d0ca
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,15 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: salt-formula-manila
+Upstream-Contact: salt-formulas@freelists.org
+Source: https://github.com/salt-formulas/salt-formula-manila
+
+Files: *
+Copyright: 2017 Mirantis Inc.
+License: Apache-2.0
+  Copyright (C) 2017 Mirantis Inc.
+  .
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  .
+  On a Debian system you can find a copy of this license in
+  /usr/share/common-licenses/Apache-2.0.
diff --git a/debian/docs b/debian/docs
new file mode 100644
index 0000000..d585829
--- /dev/null
+++ b/debian/docs
@@ -0,0 +1,3 @@
+README.rst
+CHANGELOG.rst
+VERSION
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..abde6ef
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,5 @@
+#!/usr/bin/make -f
+
+%:
+	dh $@
+
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..89ae9db
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/doc/source/conf.py b/doc/source/conf.py
new file mode 100644
index 0000000..44d3ca0
--- /dev/null
+++ b/doc/source/conf.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import sys
+
+sys.path.insert(0, os.path.abspath('../..'))
+# -- General configuration ----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = [
+    'sphinx.ext.autodoc',
+]
+
+# autodoc generation is a bit aggressive and a nuisance when doing heavy
+# text edit cycles.
+# execute "export SPHINX_DEBUG=1" in your terminal to disable
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'salt-formula-manila'
+copyright = u'2018, Mirantis Inc.'
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+add_module_names = True
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# -- Options for HTML output --------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+# html_theme_path = ["."]
+# html_theme = '_theme'
+# html_static_path = ['static']
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = '%sdoc' % project
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass
+# [howto/manual]).
+latex_documents = [
+    ('index',
+     '%s.tex' % project,
+     u'%s Documentation' % project,
+     u'OpenStack Foundation', 'manual'),
+]
+
+# Example configuration for intersphinx: refer to the Python standard library.
+# intersphinx_mapping = {'http://docs.python.org/': None}
diff --git a/doc/source/index.rst b/doc/source/index.rst
new file mode 100644
index 0000000..a6210d3
--- /dev/null
+++ b/doc/source/index.rst
@@ -0,0 +1 @@
+.. include:: ../../README.rst
diff --git a/manila/_common.sls b/manila/_common.sls
new file mode 100644
index 0000000..5af5791
--- /dev/null
+++ b/manila/_common.sls
@@ -0,0 +1,41 @@
+{%- from "manila/map.jinja" import cfg with context %}
+
+manila_common.pkgs:
+  pkg.installed:
+    - name: 'manila-common'
+    - install_recommends: False
+
+/etc/manila/manila.conf:
+  file.managed:
+  - source: salt://manila/files/{{ cfg.version }}/manila.conf
+  - template: jinja
+  - require:
+    - pkg: manila_common.pkgs
+
+{%- if cfg.message_queue.get('ssl',{}).get('enabled', False) %}
+rabbitmq_ca_manila_file:
+{%- if cfg.message_queue.ssl.cacert is defined %}
+  file.managed:
+    - name: {{ cfg.message_queue.ssl.cacert_file }}
+    - contents_pillar: cfg.message_queue:ssl:cacert
+    - mode: 0444
+    - makedirs: true
+{%- else %}
+  file.exists:
+   - name: {{ cfg.message_queue.ssl.get('cacert_file', cfg.cacert_file) }}
+{%- endif %}
+{%- endif %}
+
+{%- if cfg.database.get('ssl',{}).get('enabled', False) %}
+mysql_ca_manila_file:
+{%- if cfg.database.ssl.cacert is defined %}
+  file.managed:
+    - name: {{ cfg.databse.ssl.cacert_file }}
+    - contents_pillar: cfg.database:ssl:cacert
+    - mode: 0444
+    - makedirs: true
+{%- else %}
+  file.exists:
+   - name: {{ cfg.database.ssl.get('cacert_file', cfg.cacert_file) }}
+{%- endif %}
+{%- endif %}
diff --git a/manila/api.sls b/manila/api.sls
new file mode 100644
index 0000000..2ab8acf
--- /dev/null
+++ b/manila/api.sls
@@ -0,0 +1,47 @@
+{%- from "manila/map.jinja" import api with context %}
+{%- if api.enabled %}
+include:
+  - apache
+  - manila._common
+
+manila_api_packages:
+  pkg.installed:
+  - names: {{ api.pkgs }}
+
+manila_install_database:
+  cmd.run:
+  - names:
+    - manila-manage --config-file /etc/manila/manila.conf db sync
+  - require:
+    - file: /etc/manila/manila.conf
+  {%- if grains.get('noservices') %}
+  - onlyif: /bin/false
+  {%- endif %}
+
+manila_api_service_dead:
+  service.dead:
+  - name: manila-api
+  - enable: False
+
+{{ api.service }}:
+  service.running:
+    - enable: true
+    - watch:
+      - file: /etc/manila/manila.conf
+      - file: /etc/manila/policy.json
+    {%- if grains.get('noservices') %}
+    - onlyif: /bin/false
+    {%- endif %}
+
+/etc/manila/policy.json:
+  file.managed:
+  - source: salt://manila/files/{{ api.version }}/policy.json
+  - template: jinja
+  - require:
+    - pkg: manila_api_packages
+
+manila_site_enabled:
+  apache_site.enabled:
+    - name: wsgi_manila
+
+{%- endif %}
diff --git a/manila/data.sls b/manila/data.sls
new file mode 100644
index 0000000..b4864dc
--- /dev/null
+++ b/manila/data.sls
@@ -0,0 +1,19 @@
+{%- from "manila/map.jinja" import data with context %}
+{%- if data.enabled %}
+include:
+  - manila._common
+
+manila_data_packages:
+  pkg.installed:
+  - names: {{ data.pkgs }}
+
+{{ data.service }}:
+  service.running:
+    - enable: true
+    - watch:
+      - file: /etc/manila/manila.conf
+    {%- if grains.get('noservices') %}
+    - onlyif: /bin/false
+    {%- endif %}
+
+{%- endif %}
diff --git a/manila/files/pike/_auth_type_password.conf b/manila/files/pike/_auth_type_password.conf
new file mode 100644
index 0000000..83834b0
--- /dev/null
+++ b/manila/files/pike/_auth_type_password.conf
@@ -0,0 +1,76 @@
+{%- if _service_catalog.get('engine') == 'keystone' %}
+auth_url = {{ _service_catalog.protocol }}://{{ _service_catalog.host }}:{{ _service_catalog.port }}/identity
+
+{%- if _service_catalog.protocol == 'https' %}
+cafile={{ _service_catalog.get('cacert_file', common.cacert_file) }}
+{%- endif %}
+
+{%- if _service_catalog.get('default_domain_id') %}
+default_domain_id = {{ _service_catalog.default_domain_id }}
+{%- endif %}
+
+{%- if _service_catalog.get('default_domain_name') %}
+default_domain_name = {{ _service_catalog.default_domain_name }}
+{%- endif %}
+
+{%- if _service_catalog.get('domain_id') %}
+domain_id = {{ _service_catalog.domain_id }}
+{%- endif %}
+
+{%- if _service_catalog.get('domain_name') %}
+domain_name = {{ _service_catalog.domain_name }}
+{%- endif %}
+
+{%- if _service_catalog.get('password') %}
+password = {{ _service_catalog.password }}
+{%- endif %}
+
+{%- if _service_catalog.get('project_domain_id') %}
+project_domain_id = {{ _service_catalog.project_domain_id }}
+{%- endif %}
+
+{%- if _service_catalog.get('project_domain_name') %}
+project_domain_name = {{ _service_catalog.project_domain_name }}
+{%- endif %}
+
+{%- if _service_catalog.get('project_id') %}
+project_id = {{ _service_catalog.project_id }}
+{%- endif %}
+
+{%- if _service_catalog.get('project_name') %}
+project_name = {{ _service_catalog.project_name }}
+{%- endif %}
+
+{%- if _service_catalog.get('tenant_id') %}
+tenant_id = {{ _service_catalog.tenant_id }}
+{%- endif %}
+
+{%- if _service_catalog.get('tenant_name') %}
+tenant_name = {{ _service_catalog.tenant_name }}
+{%- endif %}
+
+{%- if _service_catalog.get('user_domain_id') %}
+user_domain_id = {{ _service_catalog.user_domain_id }}
+{%- endif %}
+
+{%- if _service_catalog.get('user_domain_name') %}
+user_domain_name = {{ _service_catalog.user_domain_name }}
+{%- endif %}
+
+{%- if _service_catalog.get('user_id')  %}
+user_id = {{ _service_catalog.user_id }}
+{%- endif %}
+
+{%- if _service_catalog.get('user') %}
+username = {{ _service_catalog.user }}
+{%- endif %}
+
+{%- if _service_catalog.get('version') %}
+auth_version = {{ _service_catalog.version }}
+{%- endif %}
+
+{%- if _service_catalog.get('memcached_servers') %}
+memcached_servers = {{ _service_catalog.memcached_servers }}
+{%- endif %}
+
+{%- endif %}
diff --git a/manila/files/pike/_backend_general.conf b/manila/files/pike/_backend_general.conf
new file mode 100644
index 0000000..9554749
--- /dev/null
+++ b/manila/files/pike/_backend_general.conf
@@ -0,0 +1,23 @@
+{%- if backend.dhss is defined %}
+driver_handles_share_servers = {{ backend.dhss }}
+{%- endif %}
+
+{%- if backend.share_backend_name is defined %}
+share_backend_name = {{ backend.share_backend_name }}
+{%- endif %}
+
+{%- if backend.share_driver is defined %}
+share_driver = {{ backend.share_driver }}
+{%- endif %}
+
+{%- if backend.service_instance_password is defined %}
+service_instance_password = {{ backend.service_instance_password }}
+{%- endif %}
+
+{%- if backend.service_instance_user is defined %}
+service_instance_user = {{ backend.service_instance_user }}
+{%- endif %}
+
+{%- if backend.service_image_name is defined %}
+service_image_name = {{ backend.service_image_name }}
+{%- endif %}
diff --git a/manila/files/pike/_backend_lvm.conf b/manila/files/pike/_backend_lvm.conf
new file mode 100644
index 0000000..ab31b62
--- /dev/null
+++ b/manila/files/pike/_backend_lvm.conf
@@ -0,0 +1,15 @@
+{%- if backend.lvm_share_export_root is defined %}
+lvm_share_export_root = {{ backend.lvm_share_export_root }}
+{%- endif %}
+{%- if backend.lvm_share_export_ips is defined %}
+lvm_share_export_ips = {{ ','.join(backend.lvm_share_export_ips) }}
+{%- endif %}
+{%- if backend.lvm_share_mirrors is defined %}
+lvm_share_mirrors = {{ backend.lvm_share_mirrors }}
+{%- endif %}
+{%- if backend.lvm_share_volume_group is defined %}
+lvm_share_volume_group = {{ backend.lvm_share_volume_group }}
+{%- endif %}
+{%- if backend.lvm_share_helpers is defined %}
+lvm_share_helpers = {{ backend.lvm_share_helpers }}
+{%- endif %}
diff --git a/manila/files/pike/_database.conf b/manila/files/pike/_database.conf
new file mode 100644
index 0000000..1533395
--- /dev/null
+++ b/manila/files/pike/_database.conf
@@ -0,0 +1 @@
+connection = {{ _database.engine }}+pymysql://{{ _database.user }}:{{ _database.password }}@{{ _database.host }}/{{ _database.name }}?charset=utf8{%- if _database.get('ssl',{}).get('enabled',False) %}&ssl_ca={{ _database.ssl.get('cacert_file', _database.cacert_file) }}{% endif %}
diff --git a/manila/files/pike/api-paste.ini b/manila/files/pike/api-paste.ini
new file mode 100644
index 0000000..42395c1
--- /dev/null
+++ b/manila/files/pike/api-paste.ini
@@ -0,0 +1,59 @@
+#############
+# OpenStack #
+#############
+
+[composite:osapi_share]
+use = call:manila.api:root_app_factory
+/: apiversions
+/v1: openstack_share_api
+/v2: openstack_share_api_v2
+
+[composite:openstack_share_api]
+use = call:manila.api.middleware.auth:pipeline_factory
+noauth = cors faultwrap http_proxy_to_wsgi sizelimit noauth api
+keystone = cors faultwrap http_proxy_to_wsgi sizelimit authtoken keystonecontext api
+keystone_nolimit = cors faultwrap http_proxy_to_wsgi sizelimit authtoken keystonecontext api
+
+[composite:openstack_share_api_v2]
+use = call:manila.api.middleware.auth:pipeline_factory
+noauth = cors faultwrap http_proxy_to_wsgi sizelimit noauth apiv2
+keystone = cors faultwrap http_proxy_to_wsgi sizelimit authtoken keystonecontext apiv2
+keystone_nolimit = cors faultwrap http_proxy_to_wsgi sizelimit authtoken keystonecontext apiv2
+
+[filter:faultwrap]
+paste.filter_factory = manila.api.middleware.fault:FaultWrapper.factory
+
+[filter:noauth]
+paste.filter_factory = manila.api.middleware.auth:NoAuthMiddleware.factory
+
+[filter:sizelimit]
+paste.filter_factory = oslo_middleware.sizelimit:RequestBodySizeLimiter.factory
+
+[filter:http_proxy_to_wsgi]
+paste.filter_factory = oslo_middleware.http_proxy_to_wsgi:HTTPProxyToWSGI.factory
+
+[app:api]
+paste.app_factory = manila.api.v1.router:APIRouter.factory
+
+[app:apiv2]
+paste.app_factory = manila.api.v2.router:APIRouter.factory
+
+[pipeline:apiversions]
+pipeline = cors faultwrap http_proxy_to_wsgi osshareversionapp
+
+[app:osshareversionapp]
+paste.app_factory = manila.api.versions:VersionsRouter.factory
+
+##########
+# Shared #
+##########
+
+[filter:keystonecontext]
+paste.filter_factory = manila.api.middleware.auth:ManilaKeystoneContext.factory
+
+[filter:authtoken]
+paste.filter_factory = keystonemiddleware.auth_token:filter_factory
+
+[filter:cors]
+paste.filter_factory = oslo_middleware.cors:filter_factory
+oslo_config_project = manila
diff --git a/manila/files/pike/manila.conf b/manila/files/pike/manila.conf
new file mode 100644
index 0000000..5e9138e
--- /dev/null
+++ b/manila/files/pike/manila.conf
@@ -0,0 +1,118 @@
+{%- from "manila/map.jinja" import cfg,scheduler,share,data with context -%}
+
+[DEFAULT]
+
+{%- if cfg.osapi_max_limit is defined %}
+osapi_max_limit = {{ cfg.osapi_max_limit }}
+{%- endif %}
+
+{%- if cfg.osapi_share_base_url is defined %}
+osapi_share_base_URL = {{ cfg.osapi_share_base_url }}
+{%- endif %}
+
+{%- if cfg.use_forwarded_for is defined %}
+use_forwarded_for = {{ cfg.use_forwarded_for }}
+{%- endif %}
+
+{%- if cfg.get('identity', {}).get('engine') == 'keystone' and cfg.identity.region is defined %}
+os_region_name = {{ cfg.identity.region }}
+{%- endif %}
+
+{%- if scheduler.manager is defined %}
+scheduler_manager = {{ scheduler.manager }}
+{%- endif %}
+
+{%- if share.manager is defined %}
+share_manager = {{ share.manager }}
+{%- endif %}
+
+{%- if data.manager is defined %}
+data_manager = {{ data.manager }}
+{%- endif %}
+
+{%- if cfg.storage_availability_zone is defined %}
+storage_availability_zone = {{ cfg.storage_availability_zone }}
+{%- endif %}
+
+{%- if cfg.default_share_type is defined %}
+default_share_type = {{ cfg.default_share_type }}
+{%- endif %}
+
+{%- if cfg.default_share_group_type is defined %}
+default_share_group_type = {{ cfg.default_share_group_type }}
+{%- endif %}
+
+{%- if cfg.memcached_servers is defined %}
+memcached_servers = {{ cfg.memcached_servers }}
+{%- endif %}
+
+rootwrap_config = {{ cfg.get('rootwrap_config', '/etc/manila/rootwrap.conf') }}
+
+{%- if cfg.get('identity', {}).get('engine') is defined %}
+auth_strategy = {{ cfg.identity.engine }}
+{%- endif %}
+
+{%- if cfg.debug is defined %}
+debug = {{ cfg.debug }}
+{%- endif %}
+
+{%- if cfg.enabled_share_backends is defined %}
+{%- set enabled_share_backends = [] %}
+{%- for name, backend in cfg.enabled_share_backends.iteritems() %}
+{%- if backend.get('enabled', False ) %}
+{%- do enabled_share_backends.append(backend.name) %}
+{%- endif %}
+{%- endfor %}
+enabled_share_backends = {{ ','.join(enabled_share_backends) }}
+{%- endif %}
+
+{%- if cfg.enabled_share_protocols is defined %}
+enabled_share_protocols = {{ cfg.enabled_share_protocols }}
+{%- endif %}
+
+{%- if cfg.dhss is defined %}
+driver_handles_share_servers = {{ cfg.dhss }}
+{%- endif %}
+
+[database]
+{% set _database = cfg.database %}
+{%- if _database.ssl is defined and cacert_file not in _database.get('ssl', {}).keys() %}{% do _database['ssl'].update({'cacert_file': cfg.cacert_file}) %}{% endif %}
+{%- include "manila/files/"+ cfg.version +"/_database.conf" %}
+
+
+[keystone_authtoken]
+{%- set _service_catalog = cfg.get('identity', {}) %}
+{%- if _service_catalog.get('auth_type') %}
+auth_type = {{ _service_catalog.auth_type }}
+{%- include "manila/files/"+ cfg.version +"/_auth_type_"+ _service_catalog.auth_type +".conf" %}
+{%- endif %}
+
+[cinder]
+{%- set _service_catalog = cfg.get('cinder', cfg.get('identity', {})) %}
+{%- if _service_catalog.get('auth_type') %}
+auth_type = {{ _service_catalog.auth_type }}
+{%- include "manila/files/"+ cfg.version +"/_auth_type_"+ _service_catalog.auth_type +".conf" %}
+{%- endif %}
+
+[neutron]
+{%- set _service_catalog = cfg.get('neutron', cfg.get('identity', {})) %}
+{%- if _service_catalog.get('auth_type') %}
+auth_type = {{ _service_catalog.auth_type }}
+{%- include "manila/files/"+ cfg.version +"/_auth_type_"+ _service_catalog.auth_type +".conf" %}
+{%- endif %}
+
+[nova]
+{%- set _service_catalog = cfg.get('nova', cfg.get('identity', {})) %}
+{%- if _service_catalog.get('auth_type') %}
+auth_type = {{ _service_catalog.auth_type }}
+{%- include "manila/files/"+ cfg.version +"/_auth_type_"+ _service_catalog.auth_type +".conf" %}
+{%- endif %}
+
+{%- if cfg.enabled_share_backends is defined %}
+{%- for name, backend in cfg.enabled_share_backends.iteritems() %}
+[{{ backend.name }}]
+{%- include "manila/files/"+ cfg.version +"/_backend_general.conf" %}
+{%- include "manila/files/"+ cfg.version +"/_backend_"+ backend.type +".conf" %}
+{%- endfor %}
+{%- endif %}
+
diff --git a/manila/files/pike/policy.json b/manila/files/pike/policy.json
new file mode 100644
index 0000000..dc91ebf
--- /dev/null
+++ b/manila/files/pike/policy.json
@@ -0,0 +1,163 @@
+{
+    "context_is_admin": "role:admin",
+    "admin_or_owner": "is_admin:True or project_id:%(project_id)s",
+    "default": "rule:admin_or_owner",
+
+    "admin_api": "is_admin:True",
+
+    "availability_zone:index": "rule:default",
+
+    "quota_set:update": "rule:admin_api",
+    "quota_set:show": "rule:default",
+    "quota_set:delete": "rule:admin_api",
+
+    "quota_class_set:show": "rule:default",
+    "quota_class_set:update": "rule:admin_api",
+
+    "service:index": "rule:admin_api",
+    "service:update": "rule:admin_api",
+
+    "share:create": "",
+    "share:delete": "rule:default",
+    "share:get": "rule:default",
+    "share:get_all": "rule:default",
+    "share:list_by_share_server_id": "rule:admin_api",
+    "share:list_by_host": "rule:admin_api",
+    "share:update": "rule:default",
+    "share:access_get": "rule:default",
+    "share:access_get_all": "rule:default",
+    "share:allow_access": "rule:default",
+    "share:deny_access": "rule:default",
+    "share:extend": "rule:default",
+    "share:shrink": "rule:default",
+    "share:get_share_metadata": "rule:default",
+    "share:delete_share_metadata": "rule:default",
+    "share:update_share_metadata": "rule:default",
+    "share:migration_start": "rule:admin_api",
+    "share:migration_complete": "rule:admin_api",
+    "share:migration_cancel": "rule:admin_api",
+    "share:migration_get_progress": "rule:admin_api",
+    "share:reset_task_state": "rule:admin_api",
+    "share:manage": "rule:admin_api",
+    "share:unmanage": "rule:admin_api",
+    "share:force_delete": "rule:admin_api",
+    "share:reset_status": "rule:admin_api",
+    "share:revert_to_snapshot": "rule:default",
+    "share_export_location:index": "rule:default",
+    "share_export_location:show": "rule:default",
+
+    "share_instance:index": "rule:admin_api",
+    "share_instance:show": "rule:admin_api",
+    "share_instance:force_delete": "rule:admin_api",
+    "share_instance:reset_status": "rule:admin_api",
+    "share_instance_export_location:index": "rule:admin_api",
+    "share_instance_export_location:show": "rule:admin_api",
+
+    "share:create_snapshot": "rule:default",
+    "share:delete_snapshot": "rule:default",
+    "share:snapshot_update": "rule:default",
+    "share_snapshot:get_snapshot": "rule:default",
+    "share_snapshot:get_all_snapshots": "rule:default",
+    "share_snapshot:manage_snapshot": "rule:admin_api",
+    "share_snapshot:unmanage_snapshot": "rule:admin_api",
+    "share_snapshot:force_delete": "rule:admin_api",
+    "share_snapshot:reset_status": "rule:admin_api",
+    "share_snapshot:access_list": "rule:default",
+    "share_snapshot:allow_access": "rule:default",
+    "share_snapshot:deny_access": "rule:default",
+    "share_snapshot_export_location:index": "rule:default",
+    "share_snapshot_export_location:show": "rule:default",
+
+    "share_snapshot_instance:detail": "rule:admin_api",
+    "share_snapshot_instance:index": "rule:admin_api",
+    "share_snapshot_instance:show": "rule:admin_api",
+    "share_snapshot_instance:reset_status": "rule:admin_api",
+    "share_snapshot_instance_export_location:index": "rule:admin_api",
+    "share_snapshot_instance_export_location:show": "rule:admin_api",
+
+    "share_type:index": "rule:default",
+    "share_type:show": "rule:default",
+    "share_type:default": "rule:default",
+    "share_type:create": "rule:admin_api",
+    "share_type:delete": "rule:admin_api",
+    "share_type:add_project_access": "rule:admin_api",
+    "share_type:list_project_access": "rule:admin_api",
+    "share_type:remove_project_access": "rule:admin_api",
+
+    "share_types_extra_spec:create": "rule:admin_api",
+    "share_types_extra_spec:update": "rule:admin_api",
+    "share_types_extra_spec:show": "rule:admin_api",
+    "share_types_extra_spec:index": "rule:admin_api",
+    "share_types_extra_spec:delete": "rule:admin_api",
+
+    "security_service:create": "rule:default",
+    "security_service:delete": "rule:default",
+    "security_service:update": "rule:default",
+    "security_service:show": "rule:default",
+    "security_service:index": "rule:default",
+    "security_service:detail": "rule:default",
+    "security_service:get_all_security_services": "rule:admin_api",
+
+    "share_server:index": "rule:admin_api",
+    "share_server:show": "rule:admin_api",
+    "share_server:details": "rule:admin_api",
+    "share_server:delete": "rule:admin_api",
+
+    "share_network:create": "rule:default",
+    "share_network:delete": "rule:default",
+    "share_network:update": "rule:default",
+    "share_network:index": "rule:default",
+    "share_network:detail": "rule:default",
+    "share_network:show": "rule:default",
+    "share_network:add_security_service": "rule:default",
+    "share_network:remove_security_service": "rule:default",
+    "share_network:get_all_share_networks": "rule:admin_api",
+
+    "scheduler_stats:pools:index": "rule:admin_api",
+    "scheduler_stats:pools:detail": "rule:admin_api",
+
+    "share_group:create" : "rule:default",
+    "share_group:delete": "rule:default",
+    "share_group:update": "rule:default",
+    "share_group:get": "rule:default",
+    "share_group:get_all": "rule:default",
+    "share_group:force_delete": "rule:admin_api",
+    "share_group:reset_status": "rule:admin_api",
+
+    "share_group_snapshot:create" : "rule:default",
+    "share_group_snapshot:delete": "rule:default",
+    "share_group_snapshot:update" : "rule:default",
+    "share_group_snapshot:get": "rule:default",
+    "share_group_snapshot:get_all": "rule:default",
+    "share_group_snapshot:force_delete": "rule:admin_api",
+    "share_group_snapshot:reset_status": "rule:admin_api",
+
+    "share_replica:get_all": "rule:default",
+    "share_replica:show": "rule:default",
+    "share_replica:create" : "rule:default",
+    "share_replica:delete": "rule:default",
+    "share_replica:promote": "rule:default",
+    "share_replica:resync": "rule:admin_api",
+    "share_replica:reset_status": "rule:admin_api",
+    "share_replica:force_delete": "rule:admin_api",
+    "share_replica:reset_replica_state": "rule:admin_api",
+
+    "share_group_type:index": "rule:default",
+    "share_group_type:show": "rule:default",
+    "share_group_type:default": "rule:default",
+    "share_group_type:create": "rule:admin_api",
+    "share_group_type:delete": "rule:admin_api",
+    "share_group_type:add_project_access": "rule:admin_api",
+    "share_group_type:list_project_access": "rule:admin_api",
+    "share_group_type:remove_project_access": "rule:admin_api",
+
+    "share_group_types_spec:create": "rule:admin_api",
+    "share_group_types_spec:update": "rule:admin_api",
+    "share_group_types_spec:show": "rule:admin_api",
+    "share_group_types_spec:index": "rule:admin_api",
+    "share_group_types_spec:delete": "rule:admin_api",
+
+    "message:delete": "rule:default",
+    "message:get": "rule:default",
+    "message:get_all": "rule:default"
+}
diff --git a/manila/init.sls b/manila/init.sls
new file mode 100644
index 0000000..6f09096
--- /dev/null
+++ b/manila/init.sls
@@ -0,0 +1,15 @@
+{%- if pillar.manila is defined %}
+include:
+{%- if pillar.manila.api is defined %}
+- manila.api
+{%- endif %}
+{%- if pillar.manila.data is defined %}
+- manila.data
+{%- endif %}
+{%- if pillar.manila.scheduler is defined %}
+- manila.scheduler
+{%- endif %}
+{%- if pillar.manila.share is defined %}
+- manila.share
+{%- endif %}
+{%- endif %}
diff --git a/manila/map.jinja b/manila/map.jinja
new file mode 100644
index 0000000..80350ad
--- /dev/null
+++ b/manila/map.jinja
@@ -0,0 +1,82 @@
+{%- set cacert_file = salt['grains.filter_by']({
+        'Debian': '/etc/ssl/certs/ca-certificates.crt',
+        'RedHat': '/etc/pki/tls/certs/ca-bundle.crt'
+    })
+%}
+
+{% set cfg = pillar.manila.get('common', {}) %}
+
+{% set api = salt['grains.filter_by']({
+    'Debian': {
+        'pkgs': ['manila-api'],
+        'engine': {
+          'name': 'eventlet'
+        },
+        'service': 'apache2',
+        'cacert_file': cacert_file,
+    }
+}, merge=pillar.manila.get('api', {})) %}
+
+{%- if api.get('enabled', False) %}
+
+{% set cfg = salt['grains.filter_by']({
+    'default': cfg,
+}, default='default', merge=api) %}
+
+{%- endif %}
+
+{% set scheduler = salt['grains.filter_by']({
+    'Debian': {
+      'pkgs': ['manila-scheduler'],
+      'service': 'manila-scheduler',
+      'cacert_file': cacert_file,
+    }
+
+}, merge=pillar.manila.get('scheduler', {})) %}
+
+{%- if scheduler.get('enabled', False) %}
+
+{% set cfg = salt['grains.filter_by']({
+    'default': cfg,
+}, default='default', merge=scheduler) %}
+
+{%- endif %}
+
+{% set data = salt['grains.filter_by']({
+    'Debian': {
+        'pkgs': ['manila-data'],
+        'service': 'manila-data',
+        'cacert_file': cacert_file,
+    },
+}, merge=pillar.manila.get('data', {})) %}
+
+{%- if data.get('enabled', False) %}
+
+{% set cfg = salt['grains.filter_by']({
+    'default': cfg,
+}, default='default', merge=data) %}
+
+{%- endif %}
+
+{% set share = salt['grains.filter_by']({
+    'Debian': {
+        'pkgs': ['manila-share'],
+        'service': 'manila-share',
+        'cacert_file': cacert_file,
+    },
+}, merge=pillar.manila.get('share', {})) %}
+
+{%- if share.get('enabled', False) %}
+
+{% set cfg = salt['grains.filter_by']({
+    'default': cfg,
+}, default='default', merge=share) %}
+
+{%- endif %}
+
+{% set client = salt['grains.filter_by']({
+    'Debian': {
+      'pkgs': ['python-manilaclient'],
+      'cacert_file': cacert_file,
+    },
+}, merge=pillar.manila.get('client', {})) %}
diff --git a/manila/meta/sensu.yml b/manila/meta/sensu.yml
new file mode 100644
index 0000000..93c1989
--- /dev/null
+++ b/manila/meta/sensu.yml
@@ -0,0 +1,8 @@
+# Sample check
+check:
+  local_manila_proc:
+    command: "PATH=$PATH:/usr/lib64/nagios/plugins:/usr/lib/nagios/plugins check_procs -C manila-api -u manila -c 1:1024"
+    interval: 60
+    occurrences: 1
+    subscribers:
+    - local-manila-server
diff --git a/manila/meta/sphinx.yml b/manila/meta/sphinx.yml
new file mode 100644
index 0000000..ac554b4
--- /dev/null
+++ b/manila/meta/sphinx.yml
@@ -0,0 +1,12 @@
+{%- from "manila/map.jinja" import server with context %}
+# Fill in documentation details
+doc:
+  name: manila
+  description: Some service info
+  role:
+    server:
+      name: server
+      param:
+        some_param:
+          name: "Some name"
+          value: "some value"
diff --git a/manila/scheduler.sls b/manila/scheduler.sls
new file mode 100644
index 0000000..9089c90
--- /dev/null
+++ b/manila/scheduler.sls
@@ -0,0 +1,19 @@
+{%- from "manila/map.jinja" import scheduler with context %}
+{%- if scheduler.enabled %}
+include:
+  - manila._common
+
+manila_scheduler_packages:
+  pkg.installed:
+  - names: {{ scheduler.pkgs }}
+
+{{ scheduler.service }}:
+  service.running:
+    - enable: true
+    - watch:
+      - file: /etc/manila/manila.conf
+    {%- if grains.get('noservices') %}
+    - onlyif: /bin/false
+    {%- endif %}
+
+{%- endif %}
diff --git a/manila/share.sls b/manila/share.sls
new file mode 100644
index 0000000..76228b0
--- /dev/null
+++ b/manila/share.sls
@@ -0,0 +1,19 @@
+{%- from "manila/map.jinja" import share with context %}
+{%- if share.enabled %}
+include:
+  - manila._common
+
+manila_share_packages:
+  pkg.installed:
+  - names: {{ share.pkgs }}
+
+{{ share.service }}:
+  service.running:
+    - enable: true
+    - watch:
+      - file: /etc/manila/manila.conf
+    {%- if grains.get('noservices') %}
+    - onlyif: /bin/false
+    {%- endif %}
+
+{%- endif %}
diff --git a/metadata.yml b/metadata.yml
new file mode 100644
index 0000000..5214008
--- /dev/null
+++ b/metadata.yml
@@ -0,0 +1,6 @@
+name: "manila"
+version: "2017.6"
+source: "https://github.com/salt-formulas/salt-formula-manila"
+dependencies:
+  - name: apache
+    source: "https://github.com/salt-formulas/salt-formula-apache"
diff --git a/metadata/service/common/cluster.yml b/metadata/service/common/cluster.yml
new file mode 100644
index 0000000..e9e9b15
--- /dev/null
+++ b/metadata/service/common/cluster.yml
@@ -0,0 +1,32 @@
+applications:
+  - manila
+parameters:
+  manila:
+    common:
+      version: ${_param:openstack_version}
+      message_queue:
+        engine: rabbitmq
+        port: 5672
+        user: openstack
+        password: ${_param:rabbitmq_openstack_password}
+        virtual_host: '/openstack'
+        host: ${_param:openstack_message_queue_address}
+      database:
+        engine: mysql
+        host: ${_param:openstack_database_address}
+        port: 3306
+        name: manila
+        user: manila
+        password: ${_param:mysql_manila_password}
+      identity:
+        engine: keystone
+        region: RegionOne
+        host: ${_param:cluster_vip_address}
+        port: 35357
+        user: manila
+        password: ${_param:keystone_manila_password}
+        tenant: service
+        auth_type: password
+        user_domain_id: default
+        project_domain_id: default
+        protocol: 'http'
diff --git a/metadata/service/common/single.yml b/metadata/service/common/single.yml
new file mode 100644
index 0000000..b61b269
--- /dev/null
+++ b/metadata/service/common/single.yml
@@ -0,0 +1,32 @@
+applications:
+  - manila
+parameters:
+  manila:
+    common:
+      version: ${_param:openstack_version}
+      message_queue:
+        engine: rabbitmq
+        port: 5672
+        user: openstack
+        password: ${_param:rabbitmq_openstack_password}
+        virtual_host: '/openstack'
+        host: ${_param:single_address}
+      database:
+        engine: mysql
+        host: ${_param:single_address}
+        port: 3306
+        name: manila
+        user: manila
+        password: ${_param:mysql_manila_password}
+      identity:
+        engine: keystone
+        region: RegionOne
+        host: ${_param:single_address}
+        port: 35357
+        user: manila
+        password: ${_param:keystone_manila_password}
+        tenant: service
+        auth_type: password
+        user_domain_id: default
+        project_domain_id: default
+        protocol: 'http'
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
new file mode 100644
index 0000000..559dee2
--- /dev/null
+++ b/metadata/service/support.yml
@@ -0,0 +1,11 @@
+parameters:
+  manila:
+    _support:
+      collectd:
+        enabled: false
+      heka:
+        enabled: false
+      sensu:
+        enabled: false
+      sphinx:
+        enabled: true
diff --git a/tests/pillar/repo_mcp_openstack_pike.sls b/tests/pillar/repo_mcp_openstack_pike.sls
new file mode 100644
index 0000000..b0a3b17
--- /dev/null
+++ b/tests/pillar/repo_mcp_openstack_pike.sls
@@ -0,0 +1,12 @@
+linux:
+  system:
+    enabled: true
+    repo:
+      mirantis_openstack_repo:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/pike/{{ grains.get('oscodename') }} pike main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/pike/{{ grains.get('oscodename') }}/archive-mcppike.key"
+        pin:
+        - pin: 'release a=pike'
+          priority: 1050
+          package: '*'
diff --git a/tests/pillar/server_cluster.sls b/tests/pillar/server_cluster.sls
new file mode 100644
index 0000000..368c199
--- /dev/null
+++ b/tests/pillar/server_cluster.sls
@@ -0,0 +1,75 @@
+manila:
+  api:
+    region: RegionOne
+    enabled: true
+    version: pike
+    bind:
+      host: 127.0.0.1
+      port: 8977
+    identity:
+      engine: keystone
+      host: 127.0.0.1
+      port: 35357
+      tenant: service
+      user: manila
+      password: misterio
+      endpoint_type: internalURL
+    database:
+      engine: mysql
+      host: 127.0.0.1
+      port: 3306
+      name: manila
+      user: manila
+      password: misterio
+    cache:
+      engine: memcached
+      members:
+        - host: 127.0.0.1
+        - host: 127.0.0.1
+        - host: 127.0.0.1
+    message_queue:
+      engine: rabbitmq
+      host: '127.0.0.1'
+      port: 5672
+      user: openstack
+      password: workshop
+      virtual_host: '/openstack'
+apache:
+  server:
+    enabled: true
+    default_mpm: event
+    mpm:
+      prefork:
+        enabled: true
+        servers:
+          start: 5
+          spare:
+            min: 2
+            max: 10
+        max_requests: 0
+        max_clients: 20
+        limit: 20
+    site:
+      manila:
+        enabled: false
+        available: true
+        type: wsgi
+        name: manila
+        host:
+          name: manila.ci.local
+          address: 127.0.0.1
+          port: 8041
+        log:
+          custom:
+            format: >-
+              %v:%p %{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %D %O \"%{Referer}i\" \"%{User-Agent}i\"
+        wsgi:
+          daemon_process: manila-api
+          processes: 2
+          threads: 10
+          user: manila
+          group: manila
+          display_name: '%{GROUP}'
+          script_alias: '/ /usr/bin/manila-api'
+          application_group: '%{GLOBAL}'
+          authorization: 'On'
diff --git a/tests/pillar/server_single.sls b/tests/pillar/server_single.sls
new file mode 100644
index 0000000..7a82b43
--- /dev/null
+++ b/tests/pillar/server_single.sls
@@ -0,0 +1,69 @@
+manila:
+  api:
+    region: RegionOne
+    enabled: true
+    version: pike
+    bind:
+      host: 127.0.0.1
+      port: 8977
+    identity:
+      engine: keystone
+      host: 127.0.0.1
+      port: 35357
+      tenant: service
+      user: manila
+      password: misterio
+      endpoint_type: internalURL
+    database:
+      engine: mysql
+      host: 127.0.0.1
+      port: 3306
+      name: manila
+      user: manila
+      password: misterio
+    message_queue:
+      engine: rabbitmq
+      host: '127.0.0.1'
+      port: 5672
+      user: openstack
+      password: workshop
+      virtual_host: '/openstack'
+apache:
+  server:
+    enabled: true
+    default_mpm: event
+    mpm:
+      prefork:
+        enabled: true
+        servers:
+          start: 5
+          spare:
+            min: 2
+            max: 10
+        max_requests: 0
+        max_clients: 20
+        limit: 20
+    site:
+      manila:
+        enabled: false
+        available: true
+        type: wsgi
+        name: manila
+        host:
+          name: manila.ci.local
+          address: 127.0.0.1
+          port: 8041
+        log:
+          custom:
+            format: >-
+              %v:%p %{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %D %O \"%{Referer}i\" \"%{User-Agent}i\"
+        wsgi:
+          daemon_process: manila-api
+          processes: 2
+          threads: 10
+          user: manila
+          group: manila
+          display_name: '%{GROUP}'
+          script_alias: '/ /usr/bin/manila-api'
+          application_group: '%{GLOBAL}'
+          authorization: 'On'
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
new file mode 100755
index 0000000..312b7e4
--- /dev/null
+++ b/tests/run_tests.sh
@@ -0,0 +1,167 @@
+#!/usr/bin/env bash
+
+set -e
+[ -n "$DEBUG" ] && set -x
+
+CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+METADATA=${CURDIR}/../metadata.yml
+FORMULA_NAME=$(cat $METADATA | python -c "import sys,yaml; print yaml.load(sys.stdin)['name']")
+
+## Overrideable parameters
+PILLARDIR=${PILLARDIR:-${CURDIR}/pillar}
+BUILDDIR=${BUILDDIR:-${CURDIR}/build}
+VENV_DIR=${VENV_DIR:-${BUILDDIR}/virtualenv}
+DEPSDIR=${BUILDDIR}/deps
+
+SALT_FILE_DIR=${SALT_FILE_DIR:-${BUILDDIR}/file_root}
+SALT_PILLAR_DIR=${SALT_PILLAR_DIR:-${BUILDDIR}/pillar_root}
+SALT_CONFIG_DIR=${SALT_CONFIG_DIR:-${BUILDDIR}/salt}
+SALT_CACHE_DIR=${SALT_CACHE_DIR:-${SALT_CONFIG_DIR}/cache}
+
+SALT_OPTS="${SALT_OPTS} --retcode-passthrough --local -c ${SALT_CONFIG_DIR}"
+
+if [ "x${SALT_VERSION}" != "x" ]; then
+    PIP_SALT_VERSION="==${SALT_VERSION}"
+fi
+
+## Functions
+log_info() {
+    echo "[INFO] $*"
+}
+
+log_err() {
+    echo "[ERROR] $*" >&2
+}
+
+setup_virtualenv() {
+    log_info "Setting up Python virtualenv"
+    virtualenv $VENV_DIR
+    source ${VENV_DIR}/bin/activate
+    pip install salt${PIP_SALT_VERSION}
+}
+
+setup_pillar() {
+    [ ! -d ${SALT_PILLAR_DIR} ] && mkdir -p ${SALT_PILLAR_DIR}
+    echo "base:" > ${SALT_PILLAR_DIR}/top.sls
+    for pillar in ${PILLARDIR}/*; do
+        grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
+        state_name=$(basename ${pillar%.sls})
+        echo -e "  ${state_name}:\n    - ${state_name}" >> ${SALT_PILLAR_DIR}/top.sls
+    done
+}
+
+setup_salt() {
+    [ ! -d ${SALT_FILE_DIR} ] && mkdir -p ${SALT_FILE_DIR}
+    [ ! -d ${SALT_CONFIG_DIR} ] && mkdir -p ${SALT_CONFIG_DIR}
+    [ ! -d ${SALT_CACHE_DIR} ] && mkdir -p ${SALT_CACHE_DIR}
+
+    echo "base:" > ${SALT_FILE_DIR}/top.sls
+    for pillar in ${PILLARDIR}/*.sls; do
+        grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
+        state_name=$(basename ${pillar%.sls})
+        echo -e "  ${state_name}:\n    - ${FORMULA_NAME}" >> ${SALT_FILE_DIR}/top.sls
+    done
+
+    cat << EOF > ${SALT_CONFIG_DIR}/minion
+file_client: local
+cachedir: ${SALT_CACHE_DIR}
+verify_env: False
+minion_id_caching: False
+
+file_roots:
+  base:
+  - ${SALT_FILE_DIR}
+  - ${CURDIR}/..
+  - /usr/share/salt-formulas/env
+
+pillar_roots:
+  base:
+  - ${SALT_PILLAR_DIR}
+  - ${PILLARDIR}
+EOF
+}
+
+fetch_dependency() {
+    dep_name="$(echo $1|cut -d : -f 1)"
+    dep_source="$(echo $1|cut -d : -f 2-)"
+    dep_root="${DEPSDIR}/$(basename $dep_source .git)"
+    dep_metadata="${dep_root}/metadata.yml"
+
+    [ -d /usr/share/salt-formulas/env/${dep_name} ] && log_info "Dependency $dep_name already present in system-wide salt env" && return 0
+    [ -d $dep_root ] && log_info "Dependency $dep_name already fetched" && return 0
+
+    log_info "Fetching dependency $dep_name"
+    [ ! -d ${DEPSDIR} ] && mkdir -p ${DEPSDIR}
+    git clone $dep_source ${DEPSDIR}/$(basename $dep_source .git)
+    ln -s ${dep_root}/${dep_name} ${SALT_FILE_DIR}/${dep_name}
+
+    METADATA="${dep_metadata}" install_dependencies
+}
+
+install_dependencies() {
+    grep -E "^dependencies:" ${METADATA} >/dev/null || return 0
+    (python - | while read dep; do fetch_dependency "$dep"; done) << EOF
+import sys,yaml
+for dep in yaml.load(open('${METADATA}', 'ro'))['dependencies']:
+    print '%s:%s' % (dep["name"], dep["source"])
+EOF
+}
+
+clean() {
+    log_info "Cleaning up ${BUILDDIR}"
+    [ -d ${BUILDDIR} ] && rm -rf ${BUILDDIR} || exit 0
+}
+
+salt_run() {
+    [ -e ${VEN_DIR}/bin/activate ] && source ${VENV_DIR}/bin/activate
+    salt-call ${SALT_OPTS} $*
+}
+
+prepare() {
+    [ -d ${BUILDDIR} ] && mkdir -p ${BUILDDIR}
+
+    which salt-call || setup_virtualenv
+    setup_pillar
+    setup_salt
+    install_dependencies
+}
+
+run() {
+    for pillar in ${PILLARDIR}/*.sls; do
+        grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
+        state_name=$(basename ${pillar%.sls})
+        salt_run grains.set 'noservices' False force=True
+        salt_run --id=${state_name} state.show_sls ${FORMULA_NAME} || (log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1)
+    done
+}
+
+_atexit() {
+    RETVAL=$?
+    trap true INT TERM EXIT
+
+    if [ $RETVAL -ne 0 ]; then
+        log_err "Execution failed"
+    else
+        log_info "Execution successful"
+    fi
+    return $RETVAL
+}
+
+## Main
+trap _atexit INT TERM EXIT
+
+case $1 in
+    clean)
+        clean
+        ;;
+    prepare)
+        prepare
+        ;;
+    run)
+        run
+        ;;
+    *)
+        prepare
+        run
+        ;;
+esac