Add possibility to manage file permissions of config files.
Fixes-bug: PROD-36551
Change-Id: I96049fe250307ffc8d1e194b4b24374c0a4c5c26
diff --git a/README.rst b/README.rst
index daae157..f1f5d5a 100644
--- a/README.rst
+++ b/README.rst
@@ -338,6 +338,38 @@
enable_stack_abandon: true
enable_stack_adopt: true
+
+Change files/directories permissions for heat service:
+=======================================
+In order to change file permissions the following should be set:
+
+'files' - block to set permissions for files.
+- full path to file
+- user ( default value is 'root' ) this parameter is optional.
+- group ( default value is 'heat' ) this parameter is optional
+- mode ( default value is '0640' ) this parameter is optional
+
+'directories' - block to set permissions for directories.
+- full path to directory
+- user ( default value is 'root' ) this parameter is optional
+- group ( default value is 'heat' ) this parameter is optional
+- mode ( default value is '0750' ) this parameter is optional
+
+.. code-block:: yaml
+
+ heat:
+ files:
+ /etc/heat/heat.conf:
+ user: 'root'
+ group: 'heat'
+ mode: '0750'
+ directories:
+ /etc/heat:
+ user: 'root'
+ group: 'heat'
+ mode: '0750'
+
+
Upgrades
========
diff --git a/heat/file_permissions.sls b/heat/file_permissions.sls
new file mode 100644
index 0000000..7dd579d
--- /dev/null
+++ b/heat/file_permissions.sls
@@ -0,0 +1,22 @@
+{% if pillar.heat.files is defined %}
+{%- for file_full_path, file_mode in pillar.heat.files.iteritems() %}
+{{ file_full_path }}_permissions:
+ file.managed:
+ - name: {{ file_full_path }}
+ - mode: {{ file_mode.get('mode', '0640') }}
+ - user: {{ file_mode.get('user', 'root') }}
+ - group: {{ file_mode.get('group', 'heat') }}
+ - replace: false
+{%- endfor %}
+{% endif %}
+
+{% if pillar.heat.directories is defined %}
+{%- for directory_path, directory_mode in pillar.heat.directories.iteritems() %}
+{{ directory_path }}_permissions:
+ file.directory:
+ - name: {{ directory_path }}
+ - mode: {{ directory_mode.get('mode', '0750') }}
+ - user: {{ directory_mode.get('user', 'root') }}
+ - group: {{ directory_mode.get('group', 'heat') }}
+{%- endfor %}
+{% endif %}
\ No newline at end of file
diff --git a/heat/init.sls b/heat/init.sls
index 3ed5ba1..6a1a135 100644
--- a/heat/init.sls
+++ b/heat/init.sls
@@ -6,4 +6,5 @@
{%- if pillar.heat.client is defined %}
- heat.client
{%- endif %}
+- heat.file_permissions
{%- endif %}
\ No newline at end of file
diff --git a/metadata/service/file_permissions.yml b/metadata/service/file_permissions.yml
new file mode 100644
index 0000000..52be71c
--- /dev/null
+++ b/metadata/service/file_permissions.yml
@@ -0,0 +1,5 @@
+parameters:
+ heat:
+ directories:
+ /etc/heat:
+ mode: '0750'
\ No newline at end of file
diff --git a/metadata/service/server/cluster.yml b/metadata/service/server/cluster.yml
index 7ebc388..8221271 100644
--- a/metadata/service/server/cluster.yml
+++ b/metadata/service/server/cluster.yml
@@ -2,6 +2,7 @@
- heat
classes:
- service.heat.support
+- service.heat.file_permissions
parameters:
_param:
heat_client_default_endpoint_type: internalURL
diff --git a/metadata/service/server/single.yml b/metadata/service/server/single.yml
index b3c733e..612dff9 100644
--- a/metadata/service/server/single.yml
+++ b/metadata/service/server/single.yml
@@ -2,6 +2,7 @@
- heat
classes:
- service.heat.support
+- service.heat.file_permissions
parameters:
_param:
heat_client_default_endpoint_type: internalURL