Mitaka版 OpenStack Heat環境をセットアップしてみた

今回、Ubuntuサーバに、Mitaka版 OpenStack Heat構築にチャレンジしてみました。
参考にした手順は、次のドキュメントになります。

- [Ubuntu wiki (Ubuntu Cloud Archive)](https://wiki.ubuntu.com/OpenStack/CloudArchive)
- [OpenStack Documentation Install and configure (Keystone)](http://docs.openstack.org/mitaka/install-guide-ubuntu/keystone-install.html)
- [OpenStack Documentation Install and configure (Heat)](http://docs.openstack.org/mitaka/install-guide-ubuntu/heat-install.html)

# ■ Heat環境セットアップ手順
### (1) Ubuntuサーバ環境を整備します

```
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"
```

```
$ sudo apt-get update
```

```
$ curl https://bootstrap.pypa.io/get-pip.py > get-pip.py
$ sudo python3 get-pip.py
```

- MySQLをインストールします（rootユーザのパスワードは、"secrete"としました）

```
$ sudo apt-get install mysql-server
$ mysql --version
mysql  Ver 14.14 Distrib 5.7.16, for Linux (x86_64) using  EditLine wrapper
```

- MySQL環境を、Keystone用に整備します

```
$ mysql -uroot -psecrete
mysql> CREATE DATABASE keystone;
mysql> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'secrete';
mysql> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'secrete';

mysql> exit
```
- MySQL環境を、Heat用に整備します

```
$ mysql -uroot -psecrete
mysql> CREATE DATABASE heat;
mysql> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'localhost' IDENTIFIED BY 'secrete';
mysql> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'%' IDENTIFIED BY 'secrete';

mysql> exit
```

- rabbit-mqをインストールします

```
$ sudo apt-get install rabbitmq-server
```
- 初期設定中に管理トークンとして使用するランダム値を生成します

```
$ openssl rand -hex 10
dbaf0a2ed98a5c16de46
```
- keystone サービスがインストール後に自動実行されないように無効化します

```
$ sudo -i
# echo "manual" > /etc/init/keystone.override
# exit
```

- keystone関連パッケージを、インストールします

```
$ sudo apt-get install apt-file
$ sudo apt-get install software-properties-common
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository cloud-archive:mitaka
$ sudo apt-get update

$ sudo apt-get install keystone apache2 libapache2-mod-wsgi
```
- Heat関連パッケージを、インストールします

```
$ sudo apt-get install heat-api heat-engine python-openstackclient
```
### (2) Keystone動作環境を整備します
admin_tokenパラメータには、"openssl rand -hex 10"で作成したトークン値を記述します

```
$ sudo vi /etc/keystone/keystone.conf
```
```text:/etc/keystone/keystone.conf
[DEFAULT]
admin_token = dbaf0a2ed98a5c16de46
verbose = True

[database]
connection = mysql://root:secrete@localhost/keystone

[token]
provider = fernet
```

- Keystone動作用にデータベースを設定します

```
$ sudo /bin/sh -c "keystone-manage db_sync"
```
- Fernetキーを初期化します

```
$ sudo keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
```

- Apache HTTP Server を設定します

```
$ sudo vi /etc/apache2/apache2.conf
```
```text:/etc/apache2/apache2.conf
...

ServerName localhost
```
```
$ sudo vi /etc/apache2/sites-available/wsgi-keystone.conf
```
```text:/etc/apache2/sites-available/wsgi-keystone.conf
Listen 5000
Listen 35357

<VirtualHost *:5000>
    WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-public
    WSGIScriptAlias / /usr/bin/keystone-wsgi-public
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    ErrorLogFormat "%{cu}t %M"
    ErrorLog /var/log/apache2/keystone.log
    CustomLog /var/log/apache2/keystone_access.log combined

    <Directory /usr/bin>
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:35357>
    WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-admin
    WSGIScriptAlias / /usr/bin/keystone-wsgi-admin
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    ErrorLogFormat "%{cu}t %M"
    ErrorLog /var/log/apache2/keystone.log
    CustomLog /var/log/apache2/keystone_access.log combined

    <Directory /usr/bin>
        Require all granted
    </Directory>
</VirtualHost>
```
```
$ sudo ln -s /etc/apache2/sites-available/wsgi-keystone.conf /etc/apache2/sites-enabled
```
- Apache HTTP serverを再起動します

```
$ sudo service apache2 restart
```
- 不要になったSQLite databaseを削除します

```
$ sudo rm /var/lib/keystone/keystone.db
$ sudo reboot
```

- defaultのdomainを作成します.
OS_TOKEN環境変数には、"openssl rand -hex 10"で作成したトークン値を記述します.

```
$ export OS_TOKEN=dbaf0a2ed98a5c16de46
$ export OS_URL=http://localhost:35357/v3
$ export OS_IDENTITY_API_VERSION=3 

$ openstack domain create --description "Default Domain" default 
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Default Domain                   |
| enabled     | True                             |
| id          | 4e41ddd4578a4370a9495885c723a887 |
| name        | default                          |
+-------------+----------------------------------+
```
- adminプロジェクトを作成します

```
$ openstack project create --domain default --description "Admin Project" admin
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Admin Project                    |
| domain_id   | 4e41ddd4578a4370a9495885c723a887 |
| enabled     | True                             |
| id          | 6f1763f7643e4ee9bb2d2d9dd9bb0bc6 |
| is_domain   | False                            |
| name        | admin                            |
| parent_id   | 4e41ddd4578a4370a9495885c723a887 |
+-------------+----------------------------------+
```
- serviceプロジェクトを作成します

```
$ openstack project create --domain default --description "Service Project" service
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Service Project                  |
| domain_id   | 4e41ddd4578a4370a9495885c723a887 |
| enabled     | True                             |
| id          | 2020e5f832b545f38169ed1996e2fbd5 |
| is_domain   | False                            |
| name        | service                          |
| parent_id   | 4e41ddd4578a4370a9495885c723a887 |
+-------------+----------------------------------+

$ openstack project list 
+----------------------------------+---------+
| ID                               | Name    |
+----------------------------------+---------+
| 2020e5f832b545f38169ed1996e2fbd5 | service |
| 6f1763f7643e4ee9bb2d2d9dd9bb0bc6 | admin   |
+----------------------------------+---------+
```
- adminロールを作成します

```
$ openstack role create admin
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | a1f870faaa184908b32806f84a4d3b07 |
| name      | admin                            |
+-----------+----------------------------------+
```
- Member ロール作成を作成します

```
$ openstack role create Member
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | 381f499504944a429d1da9cde9eb1c4f |
| name      | Member                           |
+-----------+----------------------------------+

$ openstack role list 
+----------------------------------+--------+
| ID                               | Name   |
+----------------------------------+--------+
| 381f499504944a429d1da9cde9eb1c4f | Member |
| a1f870faaa184908b32806f84a4d3b07 | admin  |
+----------------------------------+--------+
```
- adminユーザを作成します（adminユーザのパスワードは、"secrete"としました）

```
$ openstack user create --domain default --password-prompt admin
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | 4e41ddd4578a4370a9495885c723a887 |
| enabled   | True                             |
| id        | 5379653db96340c082a59ddc6d0765c5 |
| name      | admin                            |
+-----------+----------------------------------+
```
- admin ユーザーを admin ロール に加えます

```
$ openstack role add --project admin --user admin admin

$ openstack user list 
+----------------------------------+-------+
| ID                               | Name  |
+----------------------------------+-------+
| 5379653db96340c082a59ddc6d0765c5 | admin |
+----------------------------------+-------+
```

- Keystoneのサービスエントリを作成します

```
$ openstack service create --name keystone --description "OpenStack Identity" identity
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Identity               |
| enabled     | True                             |
| id          | 21d1372d3be54ebc93152c6570661805 |
| name        | keystone                         |
| type        | identity                         |
+-------------+----------------------------------+
```
- Keystone のエンドポイントを作成します

```
$ openstack endpoint create --region RegionOne identity public http://localhost:5000/v3 
$ openstack endpoint create --region RegionOne identity internal http://localhost:5000/v3
$ openstack endpoint create --region RegionOne identity admin http://localhost:35357/v3 

$ openstack endpoint list
+----------------------------------+-----------+--------------+--------------+---------+-----------+---------------------------+
| ID                               | Region    | Service Name | Service Type | Enabled | Interface | URL                       |
+----------------------------------+-----------+--------------+--------------+---------+-----------+---------------------------+
| 5899428b9a79485f9acafbba363c989e | RegionOne | keystone     | identity     | True    | internal  | http://localhost:5000/v3  |
| 66e0ca3a69464f43bd5d122ac932b0ca | RegionOne | keystone     | identity     | True    | admin     | http://localhost:35357/v3 |
| b4929a1819aa4e79a05d7ed31fb76fa3 | RegionOne | keystone     | identity     | True    | public    | http://localhost:5000/v3  |
+----------------------------------+-----------+--------------+--------------+---------+-----------+---------------------------+
```
- heat ユーザーを作成します（heatユーザのパスワードは、"secrete"としました）

```
$ openstack user create --domain default --password-prompt heat
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | 4e41ddd4578a4370a9495885c723a887 |
| enabled   | True                             |
| id        | 80e2489f9e2a4608a6aa02fe48f6069f |
| name      | heat                             |
+-----------+----------------------------------+
```
- admin ロールを heat ユーザーに追加します

```
$ openstack role add --project service --user heat admin
```

- Heat サービスを作成します

```
$ openstack service create --name heat --description "Orchestration" orchestration
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Orchestration                    |
| enabled     | True                             |
| id          | 938a5bb5133546eb8cf02fa9051b38c7 |
| name        | heat                             |
| type        | orchestration                    |
+-------------+----------------------------------+
```
- Orchestration のエンドポイントを作成します

```
$ openstack endpoint create --region RegionOne orchestration public http://localhost:8004/v1/%\(tenant_id\)s
$ openstack endpoint create --region RegionOne orchestration internal http://localhost:8004/v1/%\(tenant_id\)s
$ openstack endpoint create --region RegionOne orchestration admin http://localhost:8004/v1/%\(tenant_id\)s

$ openstack endpoint list
+----------------------------------+-----------+--------------+---------------+---------+-----------+----------------------------------------+
| ID                               | Region    | Service Name | Service Type  | Enabled | Interface | URL                                    |
+----------------------------------+-----------+--------------+---------------+---------+-----------+----------------------------------------+
| 1adf2772e85f4a0aae1ec5b540861774 | RegionOne | heat         | orchestration | True    | admin     | http://localhost:8004/v1/%(tenant_id)s |
| 5899428b9a79485f9acafbba363c989e | RegionOne | keystone     | identity      | True    | internal  | http://localhost:5000/v3               |
| 5a82d0a402e54500b90324a2f7d0d753 | RegionOne | heat         | orchestration | True    | public    | http://localhost:8004/v1/%(tenant_id)s |
| 66e0ca3a69464f43bd5d122ac932b0ca | RegionOne | keystone     | identity      | True    | admin     | http://localhost:35357/v3              |
| 7b15cd6b925540c09e0275298857703c | RegionOne | heat         | orchestration | True    | internal  | http://localhost:8004/v1/%(tenant_id)s |
| b4929a1819aa4e79a05d7ed31fb76fa3 | RegionOne | keystone     | identity      | True    | public    | http://localhost:5000/v3               |
+----------------------------------+-----------+--------------+---------------+---------+-----------+----------------------------------------+
```
- heat ドメインを作成します

```
$ openstack domain create --description "Stack projects and users" heat
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Stack projects and users         |
| enabled     | True                             |
| id          | 46bde267d7594cb496c79a25a00732e5 |
| name        | heat                             |
+-------------+----------------------------------+

$ openstack domain list
+----------------------------------+---------+---------+--------------------------+
| ID                               | Name    | Enabled | Description              |
+----------------------------------+---------+---------+--------------------------+
| 46bde267d7594cb496c79a25a00732e5 | heat    | True    | Stack projects and users |
| 4e41ddd4578a4370a9495885c723a887 | default | True    | Default Domain           |
+----------------------------------+---------+---------+--------------------------+
```
- heat_domain_admin ユーザーを作成します

```
$ openstack user create --domain heat --password-prompt heat_domain_admin
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | 46bde267d7594cb496c79a25a00732e5 |
| enabled   | True                             |
| id        | bcd781a873304501950e43348a6f35c5 |
| name      | heat_domain_admin                |
+-----------+----------------------------------+

$ openstack user list
+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| 5379653db96340c082a59ddc6d0765c5 | admin             |
| 80e2489f9e2a4608a6aa02fe48f6069f | heat              |
| bcd781a873304501950e43348a6f35c5 | heat_domain_admin |
+----------------------------------+-------------------+
```

- admin ロールを heat ドメインの heat_domain_admin ユーザーに追加し、 heat_domain_admin ユーザーがスタック管理の管理者特権を持つようにします

```
$ openstack role add --domain heat --user-domain heat --user heat_domain_admin admin
```
- heat_stack_owner ロールを作成します

```
$ openstack role create heat_stack_owner
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | 2ead0fa3aae246c8a5ccc5bba887e17d |
| name      | heat_stack_owner                 |
+-----------+----------------------------------+

$ openstack role list
+----------------------------------+------------------+
| ID                               | Name             |
+----------------------------------+------------------+
| 2ead0fa3aae246c8a5ccc5bba887e17d | heat_stack_owner |
| 381f499504944a429d1da9cde9eb1c4f | Member           |
| a1f870faaa184908b32806f84a4d3b07 | admin            |
+----------------------------------+------------------+
```
- demo プロジェクトを作成します

```
$ openstack project create --domain default --description "Demo Project" demo
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Demo Project                     |
| domain_id   | 4e41ddd4578a4370a9495885c723a887 |
| enabled     | True                             |
| id          | ff3fa8d2f9334e60a845d1671b925b00 |
| is_domain   | False                            |
| name        | demo                             |
| parent_id   | 4e41ddd4578a4370a9495885c723a887 |
+-------------+----------------------------------+
```
- demo ユーザーを作成します

```
$ openstack user create --domain default --password-prompt demo
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | 4e41ddd4578a4370a9495885c723a887 |
| enabled   | True                             |
| id        | 91c784e4100c4e4aaa64462173da01e8 |
| name      | demo                             |
+-----------+----------------------------------+
```
- user ロールを作成します

```
$ openstack role create user
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | d2375b8a11204866929406053a708900 |
| name      | user                             |
+-----------+----------------------------------+
```
- user ロールを demo プロジェクトと demo ユーザーに追加します

```
$ openstack role add --project demo --user demo user
```

- heat_stack_owner ロールを demo プロジェクトと demo ユーザーに追加し、 demo ユーザーがスタックの管理を行えるようにします

```
$ openstack role add --project demo --user demo heat_stack_owner
```
- heat_stack_user ロールを作成します

```
$ openstack role create heat_stack_user
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | a3edcf6aab0b4fea996d2cbfa463bcb5 |
| name      | heat_stack_user                  |
+-----------+----------------------------------+
```

### (3) Heat動作環境を整備します

```
$ sudo vi /etc/heat/heat.conf
```
```text:/etc/heat/heat.conf
[DEFAULT]
rpc_backend = rabbit
heat_metadata_server_url = http://localhost:8000
heat_waitcondition_server_url = http://localhost:8000/v1/waitcondition
stack_domain_admin = heat_domain_admin
stack_domain_admin_password = secrete
stack_user_domain_name = heat
debug = True

[database]
connection = mysql://root:secrete@localhost/heat

[keystone_authtoken]
auth_uri = http://localhost:5000
auth_url = http://localhost:35357
memcached_servers = localhost:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = heat
password = secrete

[trustee]
auth_plugin = password
auth_url = http://localhost:35357
username = heat
password = secrete
user_domain_name = default

[clients_keystone]
auth_uri = http://localhost:35357
```
- Keystoneが利用できるよう環境変数を設定します

```
$ vi $HOME/openstackrc_admin
```
```text:$HOME/openstackrc_admin
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=secrete
export OS_AUTH_URL=http://localhost:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
```
```
$ source openstackrc_admin
```
- Heat-engine動作用にデータベースを設定します

```
$ sudo /bin/sh -c "heat-manage db_sync"
```
- Heatを再起動します

```
$ sudo service heat-api restart
$ sudo service heat-engine restart
```

- Heatのバージョンを確認しておきます

```
$ heat-engine --version
6.1.0

$ heat-api --version
6.1.0
```

# ■ Heat環境セットアップ後の基本動作確認
「Mitaka版 Heat環境セットアップが正しく完了できたか？」を、手軽に確認しておきます。
本来であれば、Heat基本動作を確認するために、neutron等の他コンポーネントをインストールしておくべきですが、ここでは、その手間を省く手順で確認してみます。

### (1) ダミーなNetworkリソースを作成してみる
以前、Heat基本動作を調査した際に、活用した手順を、ここでも試してみたいと思います。
["Qiita記事:OpenStack Heat基本動作を試してみる"](http://qiita.com/ttsubo/items/92b41155fa8f6a639f2c)

- heat-engine内部を改造する（ダミーneutronクライアント化）

``` text:heat/engine/resources/openstack/neutron/net.py
    def handle_create(self):
        props = self.prepare_properties(
            self.properties,
            self.physical_resource_name())

        dhcp_agent_ids = props.pop(self.DHCP_AGENT_IDS, None)
#        qos_policy = props.pop(self.QOS_POLICY, None)
#        if qos_policy:
#            props['qos_policy_id'] = self.client_plugin().get_qos_policy_id(
#                qos_policy)

#        net = self.client().create_network({'network': props})['network']
#        self.resource_id_set(net['id'])
        self.resource_id_set('aaaaaaaa-aaaa-aaaaaaaae-aaaaaaaaaaaa')

        if dhcp_agent_ids:
            self._replace_dhcp_agents(dhcp_agent_ids)

    def _show_resource(self):
#        return self.client().show_network(
#            self.resource_id)['network']
        result = {"status": "ACTIVE", "name": "Sample", "id": "aaaaaaa-aaaa-aaaaaaaae-aaaaaaaaaaaa"}
        return result

    def check_create_complete(self, *args):
        attributes = self._show_resource()
        return self.is_built(attributes)

    def handle_delete(self):
        try:
#            self.client().delete_network(self.resource_id)
            pass
        except Exception as ex:
            self.client_plugin().ignore_not_found(ex)
        else:
            return True
```

- Heatを再起動します

```
$ sudo service heat-engine restart
```

- neutronのサービス/エンドポイントを作成します

```
$ openstack service create --name neutron --description "OpenStack Networking" network

$ openstack endpoint create --region RegionOne network public http:localhost:9696
$ openstack endpoint create --region RegionOne network internal http:localhost:9696
$ openstack endpoint create --region RegionOne network admin http:localhost:9696
```
... neutron用エンドポイントを作成せずに、networkリソースを作成すると、次のようなエラーが発生してしまうみたいです(Juno版では、networkリソースが作成できたんですけど...)

```
$ openstack stack create --parameter sample_net_name=Sample --template sample.yaml Sample-Net-Stack
ERROR: HEAT-E99001 Service neutron is not available for resource type OS::Neutron::Net, reason: Service endpoint not in service catalog.
```
- 事前に、heat-templateを配置しておきます

```text:sample.yaml
heat_template_version: 2013-05-23

description: sample heat for neutron

parameters:
  sample_net_name:
    type: string
    description: Name of Sample network to be created
    default: sample_network

resources:
  sample_net:
    type: OS::Neutron::Net
    properties:
      name: { get_param: sample_net_name }

outputs:
  status:
    description: status of sample_net
    value: { get_attr: [ sample_net, status ] }
```
- openstack clientから、Heatスタックを作成してみます

```
$ openstack stack create --parameter sample_net_name=Sample --template sample.yaml Sample-Net-Stack
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | b35fee5b-d622-4317-8f0b-d483a5bdf076 |
| stack_name          | Sample-Net-Stack                     |
| description         | sample heat for neutron              |
| creation_time       | 2016-11-19T21:46:20                  |
| updated_time        | None                                 |
| stack_status        | CREATE_COMPLETE                      |
| stack_status_reason | Stack CREATE completed successfully  |
+---------------------+--------------------------------------+
```
- Heatスタックの状態を確認してみます

```
$ openstack stack show Sample-Net-Stack
+-----------------------+--------------------------------------------------------------------------------------------------------------------------------+
| Field                 | Value                                                                                                                          |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------------+
| id                    | b35fee5b-d622-4317-8f0b-d483a5bdf076                                                                                           |
| stack_name            | Sample-Net-Stack                                                                                                               |
| description           | sample heat for neutron                                                                                                        |
| creation_time         | 2016-11-19T21:46:20                                                                                                            |
| updated_time          | None                                                                                                                           |
| stack_status          | CREATE_COMPLETE                                                                                                                |
| stack_status_reason   | Stack CREATE completed successfully                                                                                            |
| parameters            | OS::project_id: 6f1763f7643e4ee9bb2d2d9dd9bb0bc6                                                                               |
|                       | OS::stack_id: b35fee5b-d622-4317-8f0b-d483a5bdf076                                                                             |
|                       | OS::stack_name: Sample-Net-Stack                                                                                               |
|                       | sample_net_name: Sample                                                                                                        |
|                       |                                                                                                                                |
| outputs               | - description: status of sample_net                                                                                            |
|                       |   output_key: status                                                                                                           |
|                       |   output_value: ACTIVE                                                                                                         |
|                       |                                                                                                                                |
| links                 | - href: http://localhost:8004/v1/6f1763f7643e4ee9bb2d2d9dd9bb0bc6/stacks/Sample-Net-Stack/b35fee5b-d622-4317-8f0b-d483a5bdf076 |
|                       |   rel: self                                                                                                                    |
|                       |                                                                                                                                |
| disable_rollback      | True                                                                                                                           |
| parent                | None                                                                                                                           |
| tags                  | null                                                                                                                           |
|                       | ...                                                                                                                            |
|                       |                                                                                                                                |
| stack_user_project_id | 7e4693e23d4945b4aae096c012b586d1                                                                                               |
| capabilities          | []                                                                                                                             |
| notification_topics   | []                                                                                                                             |
| timeout_mins          | None                                                                                                                           |
| stack_owner           | None                                                                                                                           |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------------+
```

- networkリソースの状態も、確認しておきます

```
$ openstack stack resource list Sample-Net-Stack
+---------------+--------------------------------------+------------------+-----------------+---------------------+
| resource_name | physical_resource_id                 | resource_type    | resource_status | updated_time        |
+---------------+--------------------------------------+------------------+-----------------+---------------------+
| sample_net    | aaaaaaaa-aaaa-aaaaaaaae-aaaaaaaaaaaa | OS::Neutron::Net | CREATE_COMPLETE | 2016-11-19T21:46:20 |
+---------------+--------------------------------------+------------------+-----------------+---------------------+
```
- Heatスタックを削除しておきます

```
$ openstack stack delete Sample-Net-Stack
Are you sure you want to delete this stack(s) [y/N]? y
```
... Oops!
Heatスタック削除が完了しなくなってしまった orz

```
$ openstack stack list
+--------------------------------------+------------------+--------------------+---------------------+--------------+
| ID                                   | Stack Name       | Stack Status       | Creation Time       | Updated Time |
+--------------------------------------+------------------+--------------------+---------------------+--------------+
| b35fee5b-d622-4317-8f0b-d483a5bdf076 | Sample-Net-Stack | DELETE_IN_PROGRESS | 2016-11-19T21:46:20 | None         |
+--------------------------------------+------------------+--------------------+---------------------+--------------+
```

- 仕方がないので、heatデータベース再構築します

```
$ sudo service heat-engine stop
$ sudo service heat-api stop

$ mysql -uroot -psecrete

mysql> drop database heat;
mysql> create database heat;
mysql> exit

$ sudo /bin/sh -c "heat-manage db_sync"

$ sudo service heat-api start
$ sudo service heat-engine start
```

とりあえず、Heat環境セットアップは、完了できました。

# ■ 終わりに ...
Heatスタックが、"DELETE_IN_PROGRESS"で滞留してしまった場合、Heatデータベース再構築することなく、Heatスタックを削除する対処方法が、見つけられなかったのが、心残りですが...