Initial commit
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
new file mode 100644
index 0000000..0511ef9
--- /dev/null
+++ b/CHANGELOG.rst
@@ -0,0 +1,6 @@
+keepalived formula
+==================
+
+0.0.1 (2015-08-03)
+
+- Initial formula setup
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..8e80b12
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2014-2015 tcp cloud a. s.
+
+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/README.rst b/README.rst
new file mode 100644
index 0000000..81b77ba
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,34 @@
+==========
+Keepalived
+==========
+
+Keepalived is a routing software written in C. The main goal of this project is to provide simple and robust facilities for loadbalancing and high-availability to Linux system and Linux based infrastructures. Loadbalancing framework relies on well-known and widely used Linux Virtual Server (IPVS) kernel module providing Layer4 loadbalancing. Keepalived implements a set of checkers to dynamically and adaptively maintain and manage loadbalanced server pool according their health. On the other hand high-availability is achieved by VRRP protocol. VRRP is a fundamental brick for router failover. In addition, Keepalived implements a set of hooks to the VRRP finite state machine providing low-level and high-speed protocol interactions. Keepalived frameworks can be used independently or all together to provide resilient infrastructures.
+
+
+Sample pillar
+=============
+
+.. code-block:: yaml
+
+ keepalived:
+ cluster:
+ enabled: True
+ instance:
+ VI_1:
+ priority: 100 (highest priority must be on primary server, different for cluster members)
+ virtual_router_id: 51
+ password: pass
+ address: 192.168.10.1
+ interface: eth0
+ VI_2:
+ priority: 150 (highest priority must be on primary server, different for cluster members)
+ virtual_router_id: 52
+ password: pass
+ address: 10.0.0.5
+ interface: eth1
+
+
+Read more
+=========
+
+* https://raymii.org/s/tutorials/Keepalived-Simple-IP-failover-on-Ubuntu.html
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..3b04cfb
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.2
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..7af9c80
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,11 @@
+salt-formula-keepalived (0.2) trusty; urgency=medium
+
+ * First public release
+
+ -- Filip Pytloun <filip.pytloun@tcpcloud.eu> Tue, 06 Oct 2015 16:38:44 +0200
+
+salt-formula-keepalived (0.1) trusty; urgency=medium
+
+ * Initial release
+
+ -- Jakub Pavlik <jakub.pavlik@tcpcloud.eu> Thu, 13 Aug 2015 23:23:41 +0200
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..f523724
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,15 @@
+Source: salt-formula-keepalived
+Maintainer: Jakub Pavlik <jakub.pavlik@tcpcloud.eu>
+Section: admin
+Priority: optional
+Build-Depends: debhelper (>= 9)
+Standards-Version: 3.9.6
+Homepage: http://www.tcpcloud.eu
+Vcs-Browser: https://github.com/tcpcloud/salt-formula-keepalived
+Vcs-Git: https://github.com/tcpcloud/salt-formula-keepalived.git
+
+Package: salt-formula-keepalived
+Architecture: all
+Depends: ${misc:Depends}, salt-master, reclass
+Description: Keepalived Salt formula
+ Install and configure Keepalived server and client.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..6d4b795
--- /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-keepalived
+Upstream-Contact: Jakub Pavlik <jakub.pavlik@tcpcloud.eu>
+Source: https://github.com/tcpcloud/salt-formula-keepalived
+
+Files: *
+Copyright: 2014-2015 tcp cloud
+License: Apache-2.0
+ Copyright (C) 2014-2015 tcp cloud
+ .
+ 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/install b/debian/install
new file mode 100644
index 0000000..1193bab
--- /dev/null
+++ b/debian/install
@@ -0,0 +1,2 @@
+keepalived/* /usr/share/salt-formulas/env/keepalived/
+metadata/service/* /usr/share/salt-formulas/reclass/service/keepalived/
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/keepalived/cluster.sls b/keepalived/cluster.sls
new file mode 100644
index 0000000..85b107f
--- /dev/null
+++ b/keepalived/cluster.sls
@@ -0,0 +1,25 @@
+{% from "keepalived/map.jinja" import cluster with context %}
+
+{%- if cluster.enabled %}
+
+keepalived_packages:
+ pkg.installed:
+ - names: {{ cluster.pkgs }}
+
+keepalived_config:
+ file.managed:
+ - name: {{ cluster.config }}
+ - source: salt://keepalived/files/keepalived.conf
+ - template: jinja
+ - require:
+ - pkg: keepalived_packages
+
+keepalived_service:
+ service.running:
+ - name: {{ cluster.service }}
+ - enable: true
+ - reload: true
+ - watch:
+ - file: keepalived_config
+
+{%- endif %}
\ No newline at end of file
diff --git a/keepalived/files/keepalived.conf b/keepalived/files/keepalived.conf
new file mode 100644
index 0000000..63d46bf
--- /dev/null
+++ b/keepalived/files/keepalived.conf
@@ -0,0 +1,24 @@
+{% from "keepalived/map.jinja" import cluster with context %}
+
+! Configuration File for keepalived
+
+{% for instance_name, instance in cluster.instance.iteritems() %}
+vrrp_instance {{ instance_name }} {
+ state MASTER
+ preempt_delay 7
+ garp_master_delay 5
+ garp_master_repeat 3
+ garp_master_refresh 1
+ interface {{ instance.interface }}
+ virtual_router_id {{ instance.virtual_router_id }}
+ priority {{ instance.priority }}
+ advert_int 1
+ authentication {
+ auth_type PASS
+ auth_pass {{ instance.password }}
+ }
+ virtual_ipaddress {
+ {{ instance.address }}
+ }
+}
+{% endfor %}
\ No newline at end of file
diff --git a/keepalived/init.sls b/keepalived/init.sls
new file mode 100644
index 0000000..b06c1e1
--- /dev/null
+++ b/keepalived/init.sls
@@ -0,0 +1,5 @@
+
+include:
+{% if pillar.keepalived.cluster is defined %}
+- keepalived.cluster
+{% endif %}
diff --git a/keepalived/map.jinja b/keepalived/map.jinja
new file mode 100644
index 0000000..940546b
--- /dev/null
+++ b/keepalived/map.jinja
@@ -0,0 +1,14 @@
+{% set cluster = salt['grains.filter_by']({
+ 'Debian': {
+ 'pkgs': ['keepalived'],
+ 'service': 'keepalived',
+ 'config': '/etc/keepalived/keepalived.conf',
+ 'instance': {}
+ },
+ 'RedHat': {
+ 'pkgs': ['keepalived'],
+ 'service': 'keepalived',
+ 'config': '/etc/keepalived/keepalived.conf',
+ 'instance': {}
+ },
+}, merge=salt['pillar.get']('keepalived:cluster')) %}
diff --git a/metadata/service/cluster/single.yml b/metadata/service/cluster/single.yml
new file mode 100644
index 0000000..16a02e5
--- /dev/null
+++ b/metadata/service/cluster/single.yml
@@ -0,0 +1,18 @@
+applications:
+- keepalived
+parameters:
+ _param:
+ keepalived_vip_priority: 100
+ keepalived_vip_virtual_router_id: 100
+ keepalived_vip_password: password
+ keepalived_vip_interface: eth0
+ keepalived:
+ cluster:
+ enabled: True
+ instance:
+ VIP:
+ priority: ${_param:keepalived_vip_priority}
+ virtual_router_id: ${_param:keepalived_vip_virtual_router_id}
+ password: ${_param:keepalived_vip_password}
+ address: ${_param:cluster_vip_address}
+ interface: ${_param:keepalived_vip_interface}