このエントリーをはてなブックマークに追加

8.2.3. Identity Service(Keystone)のインストール

OpenStack Identity Serviceのコード名はKeystoneです。
Keystoneはユーザ、テナント(プロジェクト)などOpenStackのコンポーネント全ての共通認証・認可を一括管理するコンポーネントです。
Keystoneをインストールすることによって各々のコンポーネントで認証・認可を行う必要がなくなります。

8.2.3.1. Keystoneのインストール

Keystoneのインストールはパッケージで行う場合は全て依存関係を解消してくれます。
$ sudo apt-get install -y keystone python-keyring

8.2.3.2. Keystoneのコンフィグ

keystoneのコンフィグを行います。
バックアップをディレクトリごととっておきましょう。
$ sudo cp -a /etc/keystone /etc/keystone_bak
DEFAULT、CATALOG、SQLの3セクションの変更が必要です。
SQLの接続先、ユーザ名、パスワードは適切なものを設定するようにして下さい。
以下のようにします。
ほとんどコメントアウトしてある物を外すだけなのでそんなに手間ではありません。
$ sudo vi /etc/keystone/keystone.conf
[DEFAULT]
# A "shared secret" between keystone and other openstack services
admin_token = ADMIN

# The IP address of the network interface to listen on
bind_host = 0.0.0.0

# The port number which the public service listens on
public_port = 5000

# The port number which the public admin listens on
admin_port = 35357

# The base endpoint URLs for keystone that are advertised to clients
# (NOTE: this does NOT affect how keystone listens for connections)
# public_endpoint = http://localhost:%(public_port)d/
# admin_endpoint = http://localhost:%(admin_port)d/

# The port number which the OpenStack Compute service listens on
compute_port = 8774

# Path to your policy definition containing identity actions
# TODO(dolph): This config method will probably be deprecated during grizzly
# policy_file = policy.json

# Rule to check if no matching policy definition is found
# FIXME(dolph): This should really be defined as [policy] default_rule
# policy_default_rule = admin_required

# === Logging Options ===
# Print debugging output
verbose = True

# Print more verbose output
# (includes plaintext request logging, potentially including passwords)
debug = True

# Name of log file to output to. If not set, logging will go to stdout.
log_file = keystone.log

# The directory to keep log files in (will be prepended to --logfile)
log_dir = /var/log/keystone

# Use syslog for logging.
# use_syslog = False

# syslog facility to receive log lines
# syslog_log_facility = LOG_USER

# If this option is specified, the logging configuration file specified is
# used and overrides any other logging options specified. Please see the
# Python logging module documentation for details on logging configuration
# files.
# log_config = logging.conf

# A logging.Formatter log message format string which may use any of the
# available logging.LogRecord attributes.
# log_format = %(asctime)s %(levelname)8s [%(name)s] %(message)s

# Format string for %(asctime)s in log records.
# log_date_format = %Y-%m-%d %H:%M:%S

# onready allows you to send a notification when the process is ready to serve
# For example, to have it notify using systemd, one could set shell command:
# onready = systemd-notify --ready
# or a module with notify() method:
# onready = keystone.common.systemd

[sql]
# The SQLAlchemy connection string used to connect to the database
#connection = sqlite:////var/lib/keystone/keystone.db
connection = mysql://keystone:password@stack01/keystone?charset=utf8

# the timeout before idle sql connections are reaped
idle_timeout = 200

[identity]
driver = keystone.identity.backends.sql.Identity

# This references the domain to use for all Identity API v2 requests (which are
# not aware of domains). A domain with this ID will be created for you by
# keystone-manage db_sync in migration 008.  The domain referenced by this ID
# cannot be deleted on the v3 API, to prevent accidentally breaking the v2 API.
# There is nothing special about this domain, other than the fact that it must
# exist to order to maintain support for your v2 clients.
# default_domain_id = default

[catalog]
# dynamic, sql-based backend (supports API/CLI-based management commands)
driver = keystone.catalog.backends.sql.Catalog

# static, file-based backend (does *NOT* support any management commands)
# driver = keystone.catalog.backends.templated.TemplatedCatalog

# template_file = default_catalog.templates

[token]
driver = keystone.token.backends.kvs.Token

# Amount of time a token should remain valid (in seconds)
# expiration = 86400

[policy]
driver = keystone.policy.backends.sql.Policy

[ec2]
driver = keystone.contrib.ec2.backends.kvs.Ec2

[ssl]
#enable = True
#certfile = /etc/keystone/ssl/certs/keystone.pem
#keyfile = /etc/keystone/ssl/private/keystonekey.pem
#ca_certs = /etc/keystone/ssl/certs/ca.pem
#cert_required = True

[signing]
token_format = UUID
#token_format = PKI
#certfile = /etc/keystone/ssl/certs/signing_cert.pem
#keyfile = /etc/keystone/ssl/private/signing_key.pem
#ca_certs = /etc/keystone/ssl/certs/ca.pem
#key_size = 1024
#valid_days = 3650
#ca_password = None

[ldap]
# url = ldap://localhost
# user = dc=Manager,dc=example,dc=com
# password = None
# suffix = cn=example,cn=com
# use_dumb_member = False
# allow_subtree_delete = False
# dumb_member = cn=dumb,dc=example,dc=com

# user_tree_dn = ou=Users,dc=example,dc=com
# user_filter =
# user_objectclass = inetOrgPerson
# user_id_attribute = cn
# user_name_attribute = sn
# user_mail_attribute = email
# user_pass_attribute = userPassword
# user_enabled_attribute = enabled
# user_enabled_mask = 0
# user_enabled_default = True
# user_attribute_ignore = tenant_id,tenants
# user_allow_create = True
# user_allow_update = True
# user_allow_delete = True

# tenant_tree_dn = ou=Groups,dc=example,dc=com
# tenant_filter =
# tenant_objectclass = groupOfNames
# tenant_id_attribute = cn
# tenant_member_attribute = member
# tenant_name_attribute = ou
# tenant_desc_attribute = desc
# tenant_enabled_attribute = enabled
# tenant_attribute_ignore =
# tenant_allow_create = True
# tenant_allow_update = True
# tenant_allow_delete = True

# role_tree_dn = ou=Roles,dc=example,dc=com
# role_filter =
# role_objectclass = organizationalRole
# role_id_attribute = cn
# role_name_attribute = ou
# role_member_attribute = roleOccupant
# role_attribute_ignore =
# role_allow_create = True
# role_allow_update = True
# role_allow_delete = True

# group_tree_dn =
# group_filter =
# group_objectclass = groupOfNames
# group_id_attribute = cn
# group_name_attribute = ou
# group_member_attribute = member
# group_desc_attribute = desc
# group_attribute_ignore =
# group_allow_create = True
# group_allow_update = True
# group_allow_delete = True

[filter:debug]
paste.filter_factory = keystone.common.wsgi:Debug.factory

[filter:token_auth]
paste.filter_factory = keystone.middleware:TokenAuthMiddleware.factory

[filter:admin_token_auth]
paste.filter_factory = keystone.middleware:AdminTokenAuthMiddleware.factory

[filter:xml_body]
paste.filter_factory = keystone.middleware:XmlBodyMiddleware.factory

[filter:json_body]
paste.filter_factory = keystone.middleware:JsonBodyMiddleware.factory

[filter:user_crud_extension]
paste.filter_factory = keystone.contrib.user_crud:CrudExtension.factory

[filter:crud_extension]
paste.filter_factory = keystone.contrib.admin_crud:CrudExtension.factory

[filter:ec2_extension]
paste.filter_factory = keystone.contrib.ec2:Ec2Extension.factory

[filter:s3_extension]
paste.filter_factory = keystone.contrib.s3:S3Extension.factory

[filter:url_normalize]
paste.filter_factory = keystone.middleware:NormalizingFilter.factory

[filter:sizelimit]
paste.filter_factory = keystone.middleware:RequestBodySizeLimiter.factory

[filter:stats_monitoring]
paste.filter_factory = keystone.contrib.stats:StatsMiddleware.factory

[filter:stats_reporting]
paste.filter_factory = keystone.contrib.stats:StatsExtension.factory

[app:public_service]
paste.app_factory = keystone.service:public_app_factory

[app:service_v3]
paste.app_factory = keystone.service:v3_app_factory

[app:admin_service]
paste.app_factory = keystone.service:admin_app_factory

[pipeline:public_api]
pipeline = sizelimit stats_monitoring url_normalize token_auth admin_token_auth xml_body json_body debug ec2_extension user_crud_extension public_service

[pipeline:admin_api]
pipeline = sizelimit stats_monitoring url_normalize token_auth admin_token_auth xml_body json_body debug stats_reporting ec2_extension s3_extension crud_extension admin_service

[pipeline:api_v3]
pipeline = sizelimit stats_monitoring url_normalize token_auth admin_token_auth xml_body json_body debug stats_reporting ec2_extension s3_extension service_v3

[app:public_version_service]
paste.app_factory = keystone.service:public_version_app_factory

[app:admin_version_service]
paste.app_factory = keystone.service:admin_version_app_factory

[pipeline:public_version_api]
pipeline = sizelimit stats_monitoring url_normalize xml_body public_version_service

[pipeline:admin_version_api]
pipeline = sizelimit stats_monitoring url_normalize xml_body admin_version_service

[composite:main]
use = egg:Paste#urlmap
/v2.0 = public_api
/v3 = api_v3
/ = public_version_api

[composite:admin]
use = egg:Paste#urlmap
/v2.0 = admin_api
/v3 = api_v3
/ = admin_version_api

8.2.3.3. データベースの作成

Keystoneが利用するデータベースを作成します。
データベース名keystone、ユーザ名keystone、パスワードはpasswordとしているため適切なものへ変更してください。
ホスト名も同様にstack01としていますので変更が必要であればおこなって下さい。
$ MYSQL_PASS_KEYSTONE=password
$ NOVA_CONTOLLER_HOSTNAME=stack01
$ mysql -uroot -pnova -e "drop database if exists keystone;"
$ mysql -uroot -pnova -e "create database keystone character set utf8;"
$ mysql -uroot -pnova -e "grant all privileges on keystone.* to 'keystone'@'%' identified by '$MYSQL_PASS_KEYSTONE';"
$ mysql -uroot -pnova -e "grant all privileges on keystone.* to 'keystone'@'localhost' identified by '$MYSQL_PASS_KEYSTONE';"
$ mysql -uroot -pnova -e "grant all privileges on keystone.* to 'keystone'@'$NOVA_CONTOLLER_HOSTNAME' identified by '$MYSQL_PASS_KEYSTONE';"
$ sudo keystone-manage db_sync

8.2.3.4. プロセスの再起動

Keystoneを再起動します。
$ sudo restart keystone

8.2.3.5. データの作成

KeystoneにOpenStackで利用するサービス、サービスに対するユーザ、ロールの設定を行います。
ここではサンプルのシェルを利用して作成します。
実際には環境にあった設定を利用したシェルの作成などが必要かも知れません。
Swift、Quantum、Cinder、Heatを利用する際にはコマンドで追加する手順を記述しますので参考にして下さい。
サンプルを利用はしますがサンプルへ最低限の設定を行います。
サンプルシェルを利用するための環境変数を先に設定しています。

データ投入スクリプトのコピー

$ cd /usr/local/src ; sudo cp -a /usr/share/keystone/sample_data.sh .

環境変数の設定

$ export CONTROLLER_HOST=stack01
$ export SERVICE_ENDPOINT=http://$CONTROLLER_HOST:35357/v2.0/
$ export ADMIN_PASSWORD=password
$ sudo sed -i "s/127.0.0.1/$CONTROLLER_HOST/" /usr/local/src/sample_data.sh
$ sudo sed -i "s/localhost/$CONTROLLER_HOST/" /usr/local/src/sample_data.sh
$ export ENABLE_ENDPOINTS=yes
$ sudo -E bash /usr/local/src/sample_data.sh

8.2.3.6. 設定確認

実際にデータが作成されていることを確認しましょう。
ユーザがkeystoneを操作するにはオプションを付与する必要があります。
操作するテナント名、テナントに対するユーザ名、パスワード、エンドポイントを設定する必要があります。
エンドポイントとは、APIを利用するための接続先であるURLのことです。
OpenStackの各コンポーネントはそれぞれエンドポイントを持つことになります。
ここではKeystoneのためのエンドポイントを環境変数に設定します。
エンドポイントにはパブリックURL、インターナルURL、管理用URLの3種類があります。
エンドポイントの種類 概要
パブリックURL エンドユーザがアクセスするためのURL
インターナルURL LAN経由でアクセス可能なユーザのためのURL
管理用URL 管理者用がアクセスするためのURL
一度ログアウトしてログインしなおしてみてから確認しましょう。
環境変数の読み込みを行ってから確認します。
$ export OS_SERVICE_TOKEN=ADMIN
$ export OS_SERVICE_ENDPOINT=http://stack01:35357/v2.0/
$ keystone tenant-list
+----------------------------------+--------+---------+--------------------+
|                id                |  name  | enabled |       email        |
+----------------------------------+--------+---------+--------------------+
| 67aa39f1061343498239a523ea4ed822 | admin  |   True  | admin@example.com  |
| 416572a042a84149a5192a155cf3516c |  demo  |   True  | admin@example.com  |
| 2c63e43d260645d7814c2a0bfa838452 | glance |   True  | glance@example.com |
| b724a9b764c54b7098ee2afe499c6207 |  nova  |   True  |  nova@example.com  |
+----------------------------------+--------+---------+--------------------+
$ keystone user-list
+----------------------------------+--------+---------+--------------------+
|                id                |  name  | enabled |       email        |
+----------------------------------+--------+---------+--------------------+
| 67aa39f1061343498239a523ea4ed822 | admin  |   True  | admin@example.com  |
| 416572a042a84149a5192a155cf3516c |  demo  |   True  | admin@example.com  |
| 2c63e43d260645d7814c2a0bfa838452 | glance |   True  | glance@example.com |
| b724a9b764c54b7098ee2afe499c6207 |  nova  |   True  |  nova@example.com  |
+----------------------------------+--------+---------+--------------------+
$ keystone role-list
+----------------------------------+----------------------+
|                id                |         name         |
+----------------------------------+----------------------+
| ed4fe120fb7d47759ee423a039f57b98 |    KeystoneAdmin     |
| d8d23079e11c4191a6d00ccec7b1afbe | KeystoneServiceAdmin |
| 9872d9f619394241bb3012460fa234df |        Member        |
| 74c180d503074cd1833703f2537efd26 |        admin         |
| 8d6fd4b072104537bd4af07855478de7 |       netadmin       |
| 4ca6ba9d704e4074a402b330e292a565 |       sysadmin       |
+----------------------------------+----------------------+
$ keystone service-list

+----------------------------------+-------------+-----------+---------------------------+
|                id                |     name    |    type   |        description        |
+----------------------------------+-------------+-----------+---------------------------+
| efcc7bc48fa941f3b75e1888f7247061 |     ec2     |    ec2    |  EC2 Compatibility Layer  |
| d25b60bab6524f03849004969ebb0232 |    glance   |   image   |    Glance Image Service   |
| f38601f9b3d94435a832ed8093140350 |   horizon   | dashboard |    OpenStack Dashboard    |
| e0734b3d8cf84a0899c2384e28513018 |   keystone  |  identity | Keystone Identity Service |
| 3aca80b93edc4c3a8fc2750cf67fa378 |     nova    |  compute  |    Nova Compute Service   |
| 2b3aa8e20a924e3ea396acbe521de8b4 | nova-volume |   volume  |    Nova Volume Service    |
+----------------------------------+-------------+-----------+---------------------------+
$ keystone endpoint-list

+----------------------------------+-----------+----------------------------------------------------+----------------------------------------------------+----------------------------------------------------+----------------------------------+
|                id                |   region  |                     publicurl                      |                    internalurl                     |                      adminurl                      |            service_id            |
+----------------------------------+-----------+----------------------------------------------------+----------------------------------------------------+----------------------------------------------------+----------------------------------+
| 122244d8334140cd8f81108354447abc | RegionOne | http://stack01:$(compute_port)s/v1.1/$(tenant_id)s | http://stack01:$(compute_port)s/v1.1/$(tenant_id)s | http://stack01:$(compute_port)s/v1.1/$(tenant_id)s | 3aca80b93edc4c3a8fc2750cf67fa378 |
| 53059199c05240bd87aa12ab1de893c3 | RegionOne |               http://stack01:9292/v1               |               http://stack01:9292/v1               |               http://stack01:9292/v1               | d25b60bab6524f03849004969ebb0232 |
| 5d92796503ae4f56a8f7a1cd793a871a | RegionOne |        http://stack01:8776/v1/$(tenant_id)s        |        http://stack01:8776/v1/$(tenant_id)s        |        http://stack01:8776/v1/$(tenant_id)s        | 2b3aa8e20a924e3ea396acbe521de8b4 |
| 8672dfbd30a841bf999668ac382528ea | RegionOne |         http://stack01:8773/services/Cloud         |         http://stack01:8773/services/Cloud         |         http://stack01:8773/services/Admin         | efcc7bc48fa941f3b75e1888f7247061 |
| a48ed6c8ad5d444ab110ec98c53111c5 | RegionOne |        http://stack01:$(public_port)s/v2.0         |        http://stack01:$(public_port)s/v2.0         |         http://stack01:$(admin_port)s/v2.0         | e0734b3d8cf84a0899c2384e28513018 |
+----------------------------------+-----------+----------------------------------------------------+----------------------------------------------------+----------------------------------------------------+----------------------------------+
Keystoneのインストール、設定はここで終了です。