Add possibility to manage file permissions of config files
Fixes-bug: PROD-36556
Change-Id: I223410209d15e5232bdf85c5b1634a5e00401c71
diff --git a/README.rst b/README.rst
index 04e79ed..d2fef75 100644
--- a/README.rst
+++ b/README.rst
@@ -178,6 +178,40 @@
project_alarm_quota: 10
alarm_max_actions: -1
+
+Change files/directories permissions for aodh 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 'aodh' ) 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 'aodh' ) this parameter is optional
+- mode ( default value is '0750' ) this parameter is optional
+
+.. code-block:: yaml
+
+ aodh:
+ files:
+ /etc/aodh/aodh.conf:
+ user: 'root'
+ group: 'aodh'
+ mode: '0750'
+ directories:
+ /etc/aodh:
+ user: 'root'
+ group: 'aodh'
+ mode: '0750'
+
+
+
+
Development and testing
=======================
diff --git a/aodh/file_permissions.sls b/aodh/file_permissions.sls
new file mode 100644
index 0000000..5b463e8
--- /dev/null
+++ b/aodh/file_permissions.sls
@@ -0,0 +1,22 @@
+{% if pillar.aodh.files is defined %}
+{%- for file_full_path, file_mode in pillar.aodh.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', 'aodh') }}
+ - replace: false
+{%- endfor %}
+{% endif %}
+
+{% if pillar.aodh.directories is defined %}
+{%- for directory_path, directory_mode in pillar.aodh.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', 'aodh') }}
+{%- endfor %}
+{% endif %}
diff --git a/aodh/init.sls b/aodh/init.sls
index 9877617..c1dfa69 100644
--- a/aodh/init.sls
+++ b/aodh/init.sls
@@ -6,4 +6,5 @@
{%- if pillar.aodh.client is defined %}
- aodh.client
{%- endif %}
+- aodh.file_permissions
{%- endif %}
diff --git a/metadata/service/file_permissions.yml b/metadata/service/file_permissions.yml
new file mode 100644
index 0000000..9bee5d1
--- /dev/null
+++ b/metadata/service/file_permissions.yml
@@ -0,0 +1,5 @@
+parameters:
+ aodh:
+ directories:
+ /etc/aodh:
+ mode: '0750'
\ No newline at end of file
diff --git a/metadata/service/server/cluster.yml b/metadata/service/server/cluster.yml
index 7724e24..bd30bc1 100644
--- a/metadata/service/server/cluster.yml
+++ b/metadata/service/server/cluster.yml
@@ -2,6 +2,7 @@
- aodh
classes:
- service.aodh.support
+- service.aodh.file_permissions
parameters:
_param:
keystone_aodh_endpoint_type: internalURL
diff --git a/metadata/service/server/single.yml b/metadata/service/server/single.yml
index 5615125..26cbfb0 100644
--- a/metadata/service/server/single.yml
+++ b/metadata/service/server/single.yml
@@ -2,6 +2,7 @@
- aodh
classes:
- service.aodh.support
+- service.aodh.file_permissions
parameters:
_param:
keystone_aodh_endpoint_type: internalURL