Merge "Run dbsync on primary node only"
diff --git a/heat/db/offline_sync.sls b/heat/db/offline_sync.sls
new file mode 100644
index 0000000..820e083
--- /dev/null
+++ b/heat/db/offline_sync.sls
@@ -0,0 +1,8 @@
+{%- from "heat/map.jinja" import server with context %}
+
+heat_syncdb:
+ cmd.run:
+ - name: heat-manage db_sync
+ {%- if grains.get('noservices') or server.get('role', 'primary') == 'secondary' %}
+ - onlyif: /bin/false
+ {%- endif %}
diff --git a/heat/server.sls b/heat/server.sls
index c06ac26..266d5fb 100644
--- a/heat/server.sls
+++ b/heat/server.sls
@@ -1,9 +1,14 @@
{%- from "heat/map.jinja" import server with context %}
{%- if server.enabled %}
+include:
+ - heat.db.offline_sync
+
heat_server_packages:
pkg.installed:
- names: {{ server.pkgs }}
+ - require_in:
+ - sls: heat.db.offline_sync
/etc/heat/heat.conf:
file.managed:
@@ -11,6 +16,8 @@
- template: jinja
- require:
- pkg: heat_server_packages
+ - require_in:
+ - sls: heat.db.offline_sync
/etc/heat/api-paste.ini:
file.managed:
@@ -143,22 +150,12 @@
- require:
- file: /etc/heat/heat.conf
- pkg: heat_server_packages
- - require_in:
- - cmd: heat_syncdb
-
-{%- endif %}
-
-{%- endif %}
-
-heat_syncdb:
- cmd.run:
- - name: heat-manage db_sync
- {%- if grains.get('noservices') %}
- - onlyif: /bin/false
- {%- endif %}
- require:
- - file: /etc/heat/heat.conf
- - pkg: heat_server_packages
+ - sls: heat.db.offline_sync
+
+{%- endif %}
+
+{%- endif %}
heat_log_access:
cmd.run:
@@ -180,7 +177,7 @@
- onlyif: /bin/false
{%- endif %}
- require:
- - cmd: heat_syncdb
+ - sls: heat.db.offline_sync
- watch:
- file: /etc/heat/heat.conf
- file: /etc/heat/api-paste.ini