aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/keystone/tasks/keystone_create.yml
blob: 5307777654457c4e2cf0b1e73360b9528aac01a3 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
##############################################################################
# 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: set keystone endpoint
  shell:
    . /opt/admin-openrc.sh;
    openstack endpoint set \
         --interface public \
         --url {{ item.publicurl }} \
         $(openstack endpoint list | grep keystone | grep public | awk '{print $2}');
    openstack endpoint set \
         --interface internal \
         --url {{ item.internalurl }} \
         $(openstack endpoint list | grep keystone | grep internal | awk '{print $2}');
    openstack endpoint set \
         --interface admin \
         --url {{ item.adminurl }} \
         $(openstack endpoint list | grep keystone | grep admin | awk '{print $2}');
  with_items: "{{ os_services[0:1] }}"

- name: add service
  shell:
    . /opt/admin-openrc.sh;
    openstack service create \
        --name "{{ item.name }}"
        --description "{{ item.description }}" \
        {{ item.type }}
  with_items: "{{ os_services[1:] }}"

- name: add project
  shell:
    . /opt/admin-openrc.sh;
    openstack project create --description "Service Project" service;
    openstack project create --domain default --description "Demo Project" demo;

- name: set admin user
  shell:
    . /opt/admin-openrc.sh;
    openstack user set \
        --email "{{ item.email }}" \
        --project "{{ item.tenant }}" \
        --description "{{ item.tenant_description }}" \
        --password "{{ item.password }}" \
        {{ item.user }}
  with_items: "{{ os_users }}"
  when: item["user"] == "admin"

- name: add user
  shell:
    . /opt/admin-openrc.sh;
    openstack user create \
        --email "{{ item.email }}" \
        --project "{{ item.tenant }}" \
        --description "{{ item.tenant_description }}" \
        --password "{{ item.password }}" \
        {{ item.user }}
  with_items: "{{ os_users[1:] }}"

- name: add roles
  shell:
    . /opt/admin-openrc.sh;
    openstack role create {{ item.role }}
  with_items: "{{ os_users }}"
  when: item["user"] == "demo"

- name: grant roles
  shell:
    . /opt/admin-openrc.sh;
    openstack role add \
        --project "{{ item.tenant }}" \
        --user "{{ item.user }}" \
        {{ item.role }}
  with_items: "{{ os_users }}"

- name: add endpoints
  shell:
    . /opt/admin-openrc.sh;
    openstack endpoint create \
        --region {{ item.region }} \
        {{ item.name }} public {{ item.publicurl }};
    openstack endpoint create \
        --region {{ item.region }} \
        {{ item.name }} internal {{ item.internalurl }};
    openstack endpoint create \
        --region {{ item.region }} \
        {{ item.name }} admin {{ item.adminurl }};
  with_items: "{{ os_services[1:] }}"