blob: c7c137f024cf75aec15a06fe6a0095fef9140add [file] [log] [blame]
Ales Komarek74a3ba62016-10-05 12:16:52 +02001{%- from "keystone/map.jinja" import client with context %}
2{%- if client.enabled %}
3
4{%- for server_name, server in client.get('server', {}).iteritems() %}
5
6{%- if server.admin.get('api_version', '2') == '3' %}
7{%- set version = "v3" %}
8{%- else %}
9{%- set version = "v2.0" %}
10{%- endif %}
11
12{%- if server.admin.get('protocol', 'http') == 'http' %}
13{%- set protocol = 'http' %}
14{%- else %}
15{%- set protocol = 'https' %}
16{%- endif %}
17
18
19{%- if server.admin.token is defined %}
20{%- set connection_args = {'endpoint': protocol+'://'+server.admin.host+':'+server.admin.port|string+'/'+version,
21 'token': server.admin.token} %}
22{%- else %}
23{%- set connection_args = {'auth_url': protocol+'://'+server.admin.host+':'+server.admin.port|string+'/'+version,
24 'tenant': server.admin.project,
25 'user': server.admin.user,
26 'password': server.admin.password} %}
27{%- endif %}
28
29keystone_{{ server_name }}_roles:
30 keystone.role_present:
31 - names: {{ server.roles }}
32 {%- if server.admin.token is defined %}
33 - connection_token: {{ connection_args.token }}
34 - connection_endpoint: {{ connection_args.endpoint }}
35 {%- else %}
36 - connection_user: {{ connection_args.user }}
37 - connection_password: {{ connection_args.password }}
38 - connection_tenant: {{ connection_args.tenant }}
39 - connection_auth_url: {{ connection_args.auth_url }}
40 {%- endif %}
41
42{% for service_name, service in server.get('service', {}).iteritems() %}
43
44keystone_{{ server_name }}_service_{{ service_name }}:
45 keystone.service_present:
46 - name: {{ service_name }}
47 - service_type: {{ service.type }}
48 - description: {{ service.description }}
49 {%- if server.admin.token is defined %}
50 - connection_token: {{ connection_args.token }}
51 - connection_endpoint: {{ connection_args.endpoint }}
52 {%- else %}
53 - connection_user: {{ connection_args.user }}
54 - connection_password: {{ connection_args.password }}
55 - connection_tenant: {{ connection_args.tenant }}
56 - connection_auth_url: {{ connection_args.auth_url }}
57 {%- endif %}
58
59{%- for endpoint in service.get('endpoints', ()) %}
60
61keystone_{{ server_name }}_service_{{ service_name }}_endpoint_{{ endpoint.region }}:
62 keystone.endpoint_present:
63 - name: {{ service_name }}
64 - publicurl: '{{ endpoint.get('public_protocol', 'http') }}://{{ endpoint.public_address }}:{{ endpoint.public_port }}{{ endpoint.public_path }}'
65 - internalurl: '{{ endpoint.get('internal_protocol', 'http') }}://{{ endpoint.internal_address }}:{{ endpoint.internal_port }}{{ endpoint.internal_path }}'
66 - adminurl: '{{ endpoint.get('admin_protocol', 'http') }}://{{ endpoint.admin_address }}:{{ endpoint.admin_port }}{{ endpoint.admin_path }}'
67 - region: {{ endpoint.region }}
68 - require:
69 - keystone: keystone_{{ server_name }}_service_{{ service_name }}
70 {%- if server.admin.token is defined %}
71 - connection_token: {{ connection_args.token }}
72 - connection_endpoint: {{ connection_args.endpoint }}
73 {%- else %}
74 - connection_user: {{ connection_args.user }}
75 - connection_password: {{ connection_args.password }}
76 - connection_tenant: {{ connection_args.tenant }}
77 - connection_auth_url: {{ connection_args.auth_url }}
78 {%- endif %}
79
80{%- endfor %}
81
82{%- endfor %}
83
84{%- for tenant_name, tenant in server.get('project', {}).iteritems() %}
85
86keystone_{{ server_name }}_tenant_{{ tenant_name }}:
87 keystone.tenant_present:
88 - name: {{ tenant_name }}
89 {%- if tenant.description is defined %}
90 - description: {{ tenant.description }}
91 {%- endif %}
92 {%- if server.admin.token is defined %}
93 - connection_token: {{ connection_args.token }}
94 - connection_endpoint: {{ connection_args.endpoint }}
95 {%- else %}
96 - connection_user: {{ connection_args.user }}
97 - connection_password: {{ connection_args.password }}
98 - connection_tenant: {{ connection_args.tenant }}
99 - connection_auth_url: {{ connection_args.auth_url }}
100 {%- endif %}
101
102{%- for user_name, user in tenant.get('user', {}).iteritems() %}
103
104keystone_{{ server_name }}_tenant_{{ tenant_name }}_user_{{ user_name }}:
105 keystone.user_present:
106 - name: {{ user_name }}
107 - password: {{ user.password }}
108 {%- if user.email is defined %}
109 - email: {{ user.email }}
110 {%- endif %}
111 - tenant: {{ tenant_name }}
112 - roles:
113 "{{ tenant_name }}":
114 {%- if user.get('is_admin', False) %}
115 - admin
116 {%- elif user.get('roles', False) %}
117 {{ user.roles }}
118 {%- else %}
119 - Member
120 {%- endif %}
121 - require:
122 - keystone: keystone_{{ server_name }}_tenant_{{ tenant_name }}
123 - keystone: keystone_{{ server_name }}_roles
124 {%- if server.admin.token is defined %}
125 - connection_token: {{ connection_args.token }}
126 - connection_endpoint: {{ connection_args.endpoint }}
127 {%- else %}
128 - connection_user: {{ connection_args.user }}
129 - connection_password: {{ connection_args.password }}
130 - connection_tenant: {{ connection_args.tenant }}
131 - connection_auth_url: {{ connection_args.auth_url }}
132 {%- endif %}
133
134{%- endfor %}
135
136{%- endfor %}
137
138{%- endfor %}
139
140{%- endif %}