Add Heat and RabbitMQ to base stack.
[apex-tripleo-heat-templates.git] / mysql.yaml
1 HeatTemplateFormatVersion: '2012-12-12'
2 Description: 'HEAT Template - Dedicated MySQL server'
3 Parameters:
4   KeyName: 
5     Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
6     Type: String
7     Default: default
8   InstanceType:
9     Description: Use this flavor
10     Type: String
11     Default: bm.small
12   KeystoneUser:
13     Description: Keystone database username.
14     Type: String
15     Default: keystone
16   HeatUser:
17     Description: Heat database username.
18     Type: String
19     Default: heat
20   MySQLImage:
21     Type: String
22   BootstrapHost:
23     Description: Load mysqldump from this Host
24     Type: String
25     Default: ''
26   BootstrapRootPassword:
27     Description: Root password for localhost access after bootstrap
28     Type: String
29     Default: ''
30   BootstrapDumpPassword:
31     Description: Password to use for mysqldump from Bootstrap Host
32     Type: String
33     Default: ''
34   BootstrapSlaveUser:
35     Description: User to use for replication from bootstrap host
36     Type: String
37     Default: ''
38   BootstrapSlavePassword:
39     Description: Password to use with BootstrapSlaveUser
40     Type: String
41     Default: ''
42 Resources:
43   ApiAccessPolicy:
44     Type: OS::Heat::AccessPolicy
45     Properties:
46       AllowedResources: [ MySQL ]
47   ApiUser:
48     Type: AWS::IAM::User
49     Properties:
50       Policies: [ { Ref: ApiAccessPolicy } ]
51   ApiKey:
52     Type: AWS::IAM::AccessKey
53     Properties:
54       UserName:
55         Ref: ApiUser
56   MySQL:
57     Type: AWS::EC2::Instance
58     Metadata:
59       OpenStack::ImageBuilder::Elements: [ mysql-migration ]
60       OpenStack::Config:
61         mysql:
62           create-users:
63             - database: keystone
64               username: {Ref: KeystoneUser}
65               userhandle: {Ref: KeystonePasswordHandle}
66             - database: heat
67               username: {Ref: HeatUser}
68               userhandle: {Ref: HeatPasswordHandle}
69         mysql-migration:
70           users:
71             root:
72               username: root
73               password: {Ref: BootstrapRootPassword}
74             dump:
75               username: dump
76               password: {Ref: BootstrapDumpPassword}
77           bootstrap_host: {Ref: BootstrapHost}
78           slave_user: {Ref: BootstrapSlaveUser}
79           slave_password: {Ref: BootstrapSlavePassword}
80         heat:
81           access_key_id:
82             Ref: ApiKey
83           secret_key:
84             Fn::GetAtt: [ ApiKey, SecretAccessKey ]
85           stack:
86             name: {Ref: 'AWS::StackName'}
87             region: {Ref: 'AWS::Region'}
88           refresh:
89             - resource: MySQL
90     Properties:
91       ImageId:
92         {Ref: MySQLImage}
93       InstanceType: {Ref: InstanceType}
94       KeyName: {Ref: KeyName}
95   HeatPasswordHandle:
96     Type: AWS::CloudFormation::WaitConditionHandle
97   HeatPassword:
98     DependsOn: MySQL
99     Type: AWS::CloudFormation::WaitCondition
100     Properties:
101       Handle: {Ref: HeatPasswordHandle}
102       Timeout: 90
103   KeystonePasswordHandle:
104     Type: AWS::CloudFormation::WaitConditionHandle
105   KeystonePassword:
106     DependsOn: MySQL
107     Type: AWS::CloudFormation::WaitCondition
108     Properties:
109       Handle: {Ref: KeystonePasswordHandle}
110       Timeout: 90
111 Outputs:
112     MySQLHost: 
113         Fn::GetAtt: [ MySQL , PrivateIp ]
114     KeystonePassword:
115         Fn::GetAtt: [ KeystonePassword, Data ]
116     KeystoneUser: {Ref: KeystoneUser}
117     HeatPassword:
118         Fn::GetAtt: [ HeatPassword, Data ]
119     HeatUser: {Ref: HeatUser}