Several fixes for backupninja

	- Make 'fs_excludes' parameter optional in client state
	- Make 'fs_includes' parameter optional in server state
	- Clean /etc/backup.d/ dir during every BN client run
	  This is required to make sure there no duplicated custom
	  steps (this can be disabled)

Related: PROD-32863
Related: PROD-32739

Change-Id: I045ef21eee04a2517efb74bcd0600af639907541
diff --git a/backupninja/client.sls b/backupninja/client.sls
index 99ed1fb..79b7380 100644
--- a/backupninja/client.sls
+++ b/backupninja/client.sls
@@ -50,6 +50,13 @@
 
 {%- endif %}
 
+{%- if client.cleanup_backup_directory %}
+cleanup_backup_directory:
+  file.directory:
+  - name: /etc/backup.d/
+  - clean: true
+{%- endif %}
+
 {%- if pillar.postgresql is defined or pillar.maas is defined %}
 backupninja_postgresql_handler:
   file.managed:
diff --git a/backupninja/files/rsync.conf b/backupninja/files/rsync.conf
index 22757fd..5bafc15 100644
--- a/backupninja/files/rsync.conf
+++ b/backupninja/files/rsync.conf
@@ -117,7 +117,7 @@
 include = {{ fs_include }}
 {%- endfor %}
 
-{%- for fs_exclude in backup.fs_excludes %}
+{%- for fs_exclude in backup.get('fs_excludes', []) %}
 exclude = {{ fs_exclude }}
 {%- endfor %}
 
diff --git a/backupninja/map.jinja b/backupninja/map.jinja
index 7c6c1ba..c13f07e 100644
--- a/backupninja/map.jinja
+++ b/backupninja/map.jinja
@@ -5,6 +5,7 @@
     'report': {'email': 'root'},

     'config': '/etc/default/backupninja',

     'cacert_file': '/etc/ssl/certs/ca-certificates.crt',

+    'cleanup_backup_directory': True,

   },

   'RedHat': {

     'pkgs': ['backupninja', 'mailx'],

diff --git a/backupninja/server.sls b/backupninja/server.sls
index aad237a..abcd680 100644
--- a/backupninja/server.sls
+++ b/backupninja/server.sls
@@ -51,7 +51,7 @@
 {%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
 
 {%- for backup_name, backup in node_grains.get('backupninja', {}).get('backup', {}).iteritems() %}
-{%- for fs_include in backup.fs_includes %}
+{%- for fs_include in backup.get('fs_includes', []) %}
 
 {{ server.home_dir }}/{{ node_name }}{{ fs_include }}:
   file.directory: