Merge branch 'feature/pull-formula-review' into 'master'

Formula reset to specific refs (example: Gerrit review)

See merge request !9
diff --git a/README.rst b/README.rst
index dd87f53..488dac8 100644
--- a/README.rst
+++ b/README.rst
@@ -153,6 +153,15 @@
               host: 127.0.0.1
               port: 9999
 
+Salt master peer for remote certificate sign.
+
+.. code-block:: yaml
+
+    salt:
+      master:
+        peer:
+          ".*":
+          - x509.sign_remote_certificate
 
 Salt minion
 -----------
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 7399f96..9beb7a7 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -6,7 +6,7 @@
       collectd:
         enabled: false
       heka:
-        enabled: false
+        enabled: true
       sensu:
         enabled: true
       sphinx:
diff --git a/salt/files/heka.toml b/salt/files/heka.toml
new file mode 100644
index 0000000..529778a
--- /dev/null
+++ b/salt/files/heka.toml
@@ -0,0 +1,51 @@
+{%- if pillar.salt.minion is defined %}
+[logstreamer_salt_minion]
+type = "LogstreamerInput"
+log_directory = "/var/log/salt"
+file_match = 'minion-?(?P<Index>\d+)?(\.gz)?'
+priority = ["^Index"]
+decoder = "Sandbox_salt_minion"
+
+[Sandbox_salt_minion]
+type = "PayloadRegexDecoder"
+match_regex = '^(?P<Timestamp>[0-9\-]+ [0-9:]+),\d+ \[(?P<Module>[\w\d\.]+)[\ \t]*\]\[(?P<Severity>\w+)[\ \t]*\]\[(?P<JID>\d+)\] (?P<Payload>.*)'
+timestamp_layout = "2006-01-02 15:04:05"
+
+[Sandbox_salt_minion.severity_map]
+DEBUG = 7
+INFO = 6
+NOTICE = 5
+WARNING = 4
+ERROR = 3
+CRITICAL = 2
+ALERT = 1
+EMERGENCY = 0
+
+[Sandbox_salt_minion.message_fields]
+Module = "%Module%"
+JID = "%JID%"
+{%- endif %}
+
+{% if pillar.salt.master is defined %}
+[logstreamer_salt_master]
+type = "LogstreamerInput"
+log_directory = "/var/log/salt"
+file_match = 'master-?(?P<Index>\d+)?(\.gz)?'
+priority = ["^Index"]
+decoder = "Sandbox_salt_master"
+
+[Sandbox_salt_master]
+type = "PayloadRegexDecoder"
+match_regex = '^(?P<Timestamp>[0-9\-]+ [0-9:]+),\d+ \[(?P<Module>[\w\d\.]+)[\ \t]*\]\[(?P<Severity>\w+)[\ \t]*\]\[(?P<JID>\d+)\] (?P<Payload>.*)'
+timestamp_layout = "2006-01-02 15:04:05"
+
+[Sandbox_salt_master.severity_map]
+DEBUG = 7
+INFO = 6
+WARNING = 4
+ERROR = 3
+
+[Sandbox_salt_master.message_fields]
+Module = "%Module%"
+JID = "%JID%"
+{%- endif %}
diff --git a/salt/files/minion.conf b/salt/files/minion.conf
index 22893af..1323b2f 100644
--- a/salt/files/minion.conf
+++ b/salt/files/minion.conf
@@ -8,7 +8,7 @@
 - {{ master.host }}
 {%- endfor %}
 
-{%- if minion.master_type == "failover" %}
+{%- if minion.get('master_type', 'default') == "failover" %}
 master_type: failover
 master_shuffle: True
 master_alive_interval: 60
diff --git a/salt/map.jinja b/salt/map.jinja
index e0bfc10..b66180e 100644
--- a/salt/map.jinja
+++ b/salt/map.jinja
@@ -2,16 +2,17 @@
 {%- load_yaml as master_common %}
 default:
   service: salt-master
-  {%- if pillar.salt.master is defined %}
-  {%- if pillar.salt.master.source.engine == 'pkg' %}
+  {%- if pillar.salt.get('master', {}).get('source', {}).get('engine', 'pkg') == 'pkg' %}
   install_state: "pkg: salt_master_packages"
+  source:
+    engine: pkg
   {%- elif pillar.salt.master.source.engine == 'pip' %}
   install_state: "pip: salt_master_packages"
   {%- endif %}
-  {%- if pillar.salt.master.source.version is defined %}
+
+  {%- if pillar.salt.get('master', {}).get('source', {}).version is defined %}
   version: {{ pillar.salt.master.source.version }}
   {%- endif %}
-  {%- endif %}
   accept_policy: preseed
   bind: {}
   formula: {}
@@ -40,40 +41,43 @@
   - salt-master
 {%- endload %}
 
+{%- if pillar.salt.master is defined %}
 {%- set raw_master = salt['grains.filter_by'](master_specific, merge=salt['pillar.get']('salt:master')) %}
 {%- set master = salt['grains.filter_by'](master_common, merge=raw_master) %}
+{%- endif %}
 
 
 {%- load_yaml as minion_common %}
 default:
-  graph_pkgs: 
+  graph_pkgs:
   - graphviz
-  graph_states_pkgs: 
+  graph_states_pkgs:
   - python-pydot
   - python-yaml
   graph_states: False
   service: salt-minion
-  {%- if pillar.salt.minion is defined %}
-  {%- if pillar.salt.minion.source.engine == 'pkg' %}
+  {%- if pillar.salt.get('minion', {}).get('source', {}).get('engine', 'pkg') == 'pkg' %}
   install_state: "pkg: salt_minion_packages"
+  source:
+    engine: pkg
   {%- elif pillar.salt.minion.source.engine == 'pip' %}
   install_state: "pip: salt_minion_packages"
   {%- endif %}
-  {%- if pillar.salt.minion.source.version is defined %}
+
+  {%- if pillar.salt.get('minion', {}).get('source', {}).version is defined %}
   version: {{ pillar.salt.minion.source.version }}
   {%- endif %}
-  {%- endif %}
 {%- endload %}
 
 {%- load_yaml as minion_specific %}
 Arch:
-  pkgs: 
+  pkgs:
   - salt-zmq
 Debian:
   pkgs:
   - salt-minion
 Gentoo:
-  pkgs: 
+  pkgs:
   - app-admin/salt
 MacOS:
   pkgs:
@@ -83,8 +87,10 @@
   - salt-minion
 {%- endload %}
 
+{%- if pillar.salt.minion is defined %}
 {%- set raw_minion = salt['grains.filter_by'](minion_specific, merge=salt['pillar.get']('salt:minion')) %}
 {%- set minion = salt['grains.filter_by'](minion_common, merge=raw_minion) %}
+{%- endif %}
 
 
 {%- load_yaml as api_common %}
@@ -98,31 +104,32 @@
 
 {%- load_yaml as control_common %}
 default:
-  cloud_pips: 
+  cloud_pips:
   - apache-libcloud
   - netaddr
-  cloud_pkgs: 
+  cloud_pkgs:
   - python-netaddr
   - python-libcloud
-  virt_pips: 
+  virt_pips:
   - libvirt-python
-  maas_pkgs: 
+  maas_pkgs:
   - python-maas-client
   cluster: {}
 {%- endload %}
 
 {%- load_yaml as control_specific %}
 Debian:
-  virt_pkgs: 
+  virt_pkgs:
   - libvirt-dev
   - pkg-config
   - libguestfs-tools
 RedHat:
-  virt_pkgs: 
+  virt_pkgs:
   - libvirt-dev
   - pkg-config
 {%- endload %}
 
+{%- if pillar.salt.control is defined %}
 {%- set raw_control = salt['grains.filter_by'](control_specific, merge=salt['pillar.get']('salt:control')) %}
 {%- set control = salt['grains.filter_by'](control_common, merge=raw_control) %}
-
+{%- endif %}
diff --git a/salt/minion/grains.sls b/salt/minion/grains.sls
index af57b34..ca83a4f 100644
--- a/salt/minion/grains.sls
+++ b/salt/minion/grains.sls
@@ -23,8 +23,8 @@
   cmd.run:
   - name: cat /etc/salt/grains.d/* > /etc/salt/grains
   - require:
-    - file: salt_minion_grains_dir
+    - file: salt_minion_grains_placeholder
   - watch_in:
     - service: salt_minion_service
 
-{%- endif %}
\ No newline at end of file
+{%- endif %}