Add os-client-config support

This patch allows to manage os-client-config configurations by
keystone.client state.

Related-Prod: PROD-18221
"

Change-Id: I45c6eacacacfceb4218f3159a95ac1620f48649b
diff --git a/README.rst b/README.rst
index aad2c64..c5a2ad0 100644
--- a/README.rst
+++ b/README.rst
@@ -706,6 +706,29 @@
         policy:
           admin_or_token_subject: 'rule:admin_required or rule:token_subject'
 
+Manage os-cloud-config yml with keystone.client
+
+.. code-block:: yaml
+
+    keystone:
+      client:
+        os_client_config:
+          enabled: true
+          cfgs:
+            root:
+              file: /root/.config/openstack/clouds.yml
+              content:
+                clouds:
+                  admin_identity:
+                    region_name: RegioneOne
+                    auth:
+                      username: admin
+                      password: secretpassword
+                      user_domain_name: Default
+                      project_name: admin
+                      project_domain_name: Default
+                      auth_url: "http://1.2.3.4:5000"
+
 Setting up default admin project name and domain
 
 .. code-block:: yaml
diff --git a/keystone/client/init.sls b/keystone/client/init.sls
index 4a3f11d..c4fc48c 100644
--- a/keystone/client/init.sls
+++ b/keystone/client/init.sls
@@ -3,3 +3,4 @@
 - keystone.client.service
 - keystone.client.project
 - keystone.client.server
+- keystone.client.os_client_config
diff --git a/keystone/client/os_client_config.sls b/keystone/client/os_client_config.sls
new file mode 100644
index 0000000..bffed11
--- /dev/null
+++ b/keystone/client/os_client_config.sls
@@ -0,0 +1,21 @@
+{%- from "keystone/map.jinja" import client with context %}
+{%- if client.enabled and client.get('os_client_config', {}).get('enabled', False)  %}
+
+keystone_os_client_config_packages:
+  pkg.installed:
+  - names: {{ client.os_client_config.pkgs }}
+
+{%- for conf_name, config in client.get('os_client_config', {}).get('cfgs', {}).items() %}
+
+keystone_os_client_config_{{ conf_name }}:
+  file.managed:
+    - name: {{ config.get('file', '/root/.config/openstack/clouds.yml') }}
+    - contents: |
+        {{ client.os_client_config.cfgs.get(conf_name).content |yaml(False)|indent(8) }}
+    - owner: {{ config.get('owner', 'root') }}
+    - group: {{ config.get('group', 'root') }}
+    - makedirs: True
+
+{%- endfor %}
+
+{%- endif %}
diff --git a/keystone/map.jinja b/keystone/map.jinja
index 12b5b18..b680d2a 100644
--- a/keystone/map.jinja
+++ b/keystone/map.jinja
@@ -66,6 +66,9 @@
         'pkgs': ['python-keystoneclient', 'python-openstackclient'],
         'service': 'keystone',
         'roles': ['admin', 'Member'],
+        'os_client_config': {
+            'pkgs': ['python-os-client-config'],
+        },
     },
     'RedHat': {
         'pkgs': ['python-keystoneclient'],