summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/keystone/tasks/keystone_config.yml
blob: e7e9297e46b02ac8db26985f6ec4219830b45fb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
##############################################################################
# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---
- name: keystone-manage db-sync
  #keystone_manage: action=dbsync
  shell: su -s /bin/sh -c 'keystone-manage db_sync' keystone

- name: wait for keystone ready
  wait_for: port=35357 delay=3 timeout=10 host={{ internal_ip }}

- name: cron job to purge expired tokens hourly
  cron:
    name: 'purge expired tokens'
    special_time: hourly
    job: '/usr/bin/keystone-manage token_flush > /var/log/keystone/keystone-tokenflush.log 2>&1'

- name: add tenants
  keystone_user:
    token: "{{ ADMIN_TOKEN }}"
    endpoint: "http://{{ internal_ip }}:35357/v2.0"
    tenant: "{{ item.tenant }}"
    tenant_description: "{{ item.tenant_description }}"
  with_items: "{{ os_users }}"

- name: add users
  keystone_user:
    token: "{{ ADMIN_TOKEN }}"
    endpoint: "http://{{ internal_ip }}:35357/v2.0"
    user: "{{ item.user }}"
    tenant: "{{ item.tenant }}"
    password: "{{ item.password }}"
    email: "{{ item.email }}"
  with_items: "{{ os_users }}"

- name: grant roles
  keystone_user:
    token: "{{ ADMIN_TOKEN }}"
    endpoint: "http://{{ internal_ip }}:35357/v2.0"
    user: "{{ item.user }}"
    role: "{{ item.role }}"
    tenant: "{{ item.tenant }}"
  with_items: "{{ os_users }}"

- name: add endpoints
  keystone_service:
    token: "{{ ADMIN_TOKEN }}"
    endpoint: "http://{{ internal_ip }}:35357/v2.0"
    name: "{{ item.name }}"
    type: "{{ item.type }}"
    region: "{{ item.region}}"
    description: "{{ item.description }}"
    publicurl: "{{ item.publicurl }}"
    internalurl: "{{ item.internalurl }}"
    adminurl: "{{ item.adminurl }}"
  with_items: "{{ os_services }}"