Questa guida ti porta alla seconda parte della configurazione del servizio di identità OpenStack sul nodo controller, puoi anche leggere l'articolo precedente sulla configurazione di KeyStone #1. Qui tratteremo la creazione di entità di servizio e di endpoint API.
Crea l'entità del servizio e l'endpoint API:
Per creare l'entità del servizio e l'endpoint API, dobbiamo esportare sotto le variabili per passare il valore del token di autenticazione.
# export OS_TOKEN=43405b090eda983ddde2 ## Replace this token (43405b090eda983ddde2 ) with OS_TOEKEN value from keystone.conf file.
# export OS_URL=http://controller:35357/v2.0 ## Replace controller with your controller ip.
Crea l'entità del servizio per il servizio Identity.
# openstack service create --name keystone --description "OpenStack Identity" identity +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Identity | | enabled | True | | id | c65841b4f8df478cbc19524c09fd9724 | | name | keystone | | type | identity | +-------------+----------------------------------+
Verifica il servizio.
# openstack service list +----------------------------------+----------+----------+ | ID | Name | Type | +----------------------------------+----------+----------+ | c65841b4f8df478cbc19524c09fd9724 | keystone | identity | +----------------------------------+----------+----------+
Crea l'endpoint dell'API del servizio di identità.
# openstack endpoint create \ --publicurl http://controller:5000/v2.0 \ --internalurl http://controller:5000/v2.0 \ --adminurl http://controller:35357/v2.0 \ --region RegionOne \ identity +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | adminurl | http://controller:35357/v2.0 | | id | f402a9389d474c13a97a78a30f13c6e5 | | internalurl | http://controller:5000/v2.0 | | publicurl | http://controller:5000/v2.0 | | region | RegionOne | | service_id | c65841b4f8df478cbc19524c09fd9724 | | service_name | keystone | | service_type | identity | +--------------+----------------------------------+
Verifica i dettagli dell'endpoint.
# openstack endpoint list +----------------------------------+-----------+--------------+--------------+ | ID | Region | Service Name | Service Type | +----------------------------------+-----------+--------------+--------------+ | f402a9389d474c13a97a78a30f13c6e5 | RegionOne | keystone | identity | +----------------------------------+-----------+--------------+--------------+
Crea progetti, utenti e ruoli:
Crea un progetto amministratore, un utente e un ruolo per l'amministrazione, useremo il dominio predefinito per semplicità.
Crea il progetto di amministrazione.
# openstack project create --description "Admin Project" admin +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Admin Project | | enabled | True | | id | 9b05e6bffdb94c8081d665561d05e31e | | name | admin | +-------------+----------------------------------+
Crea l'utente amministratore.
# openstack user create --password-prompt admin User Password: Repeat User Password: +----------+----------------------------------+ | Field | Value | +----------+----------------------------------+ | email | None | | enabled | True | | id | 127a9a6b822a4e3eba69fa54128873cd | | name | admin | | username | admin | +----------+----------------------------------+
Crea il ruolo di amministratore.
# openstack role create admin +-------+----------------------------------+ | Field | Value | +-------+----------------------------------+ | id | 33af4f957aa34cc79451c23bf014af6f | | name | admin | +-------+----------------------------------+
Aggiungi il ruolo di amministratore al progetto di amministratore e all'utente.
# openstack role add --project admin --user admin admin +-------+----------------------------------+ | Field | Value | +-------+----------------------------------+ | id | 33af4f957aa34cc79451c23bf014af6f | | name | admin | +-------+----------------------------------+
Crea il progetto di servizio.
# openstack project create --description "Service Project" service +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Service Project | | enabled | True | | id | 39e1b9944e564ceb9e71c98623b676cd | | name | service | +-------------+----------------------------------+
Crea il progetto demo da utilizzare per l'utente normale.
# openstack project create --description "Demo Project" demo +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Demo Project | | enabled | True | | id | 909c4d7219c14a63aa0ef6f1ece18546 | | name | demo | +-------------+----------------------------------+
Crea l'utente demo.
# openstack user create --password-prompt demo User Password: Repeat User Password: +----------+----------------------------------+ | Field | Value | +----------+----------------------------------+ | email | None | | enabled | True | | id | 453ce23fa9f347b5baa53210aff7f207 | | name | demo | | username | demo | +----------+----------------------------------+
Crea il ruolo utente.
# openstack role create user +-------+----------------------------------+ | Field | Value | +-------+----------------------------------+ | id | fa78c101a7ed40b19de219e7d3eeda62 | | name | user | +-------+----------------------------------+
Aggiungi il ruolo utente al progetto demo e all'utente.
# openstack role add --project demo --user demo user +-------+----------------------------------+ | Field | Value | +-------+----------------------------------+ | id | fa78c101a7ed40b19de219e7d3eeda62 | | name | user | +-------+----------------------------------+
Verifica operazione:
# openstack project list +----------------------------------+---------+ | ID | Name | +----------------------------------+---------+ | 39e1b9944e564ceb9e71c98623b676cd | service | | 909c4d7219c14a63aa0ef6f1ece18546 | demo | | 9b05e6bffdb94c8081d665561d05e31e | admin | +----------------------------------+---------+
# openstack user list +----------------------------------+-------+ | ID | Name | +----------------------------------+-------+ | 127a9a6b822a4e3eba69fa54128873cd | admin | | 453ce23fa9f347b5baa53210aff7f207 | demo | +----------------------------------+-------+
# openstack role list +----------------------------------+-------+ | ID | Name | +----------------------------------+-------+ | 33af4f957aa34cc79451c23bf014af6f | admin | | fa78c101a7ed40b19de219e7d3eeda62 | user | +----------------------------------+-------+
Verifica l'operazione con l'accesso basato sui ruoli, per farlo disimposta le variabili esportate.
# unset OS_TOKEN OS_URL
Esegui il comando seguente per elencare i ruoli come utente amministratore.
# openstack --os-auth-url http://controller:35357 --os-project-name admin --os-username admin --os-auth-type password role list Password: +----------------------------------+-------+ | ID | Name | +----------------------------------+-------+ | 33af4f957aa34cc79451c23bf014af6f | admin | | fa78c101a7ed40b19de219e7d3eeda62 | user | +----------------------------------+-------+
Esegui il comando seguente per elencare i ruoli come utente demo, dovresti ricevere l'errore sotto.
# openstack --os-auth-url http://controller:35357 --os-project-name demo --os-username demo --os-auth-type password role list Password: ERROR: openstack You are not authorized to perform the requested action: admin_required (HTTP 403) (Request-ID: req-143ee967-4a26-4474-bf88-0b660354869d)
Questo è tutto, hai configurato correttamente KeyStone su Ubuntu 14.04.2