Hand modifying notcompute to work with elements.
[apex-tripleo-heat-templates.git] / mysql.yaml
1 HeatTemplateFormatVersion: '2012-12-12'
2 Description: '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   GlanceUser:
21     Description: Glance database username.
22     Type: String
23     Default: heat
24   NovaUser:
25     Description: Glance database username.
26     Type: String
27     Default: heat
28   MySQLImage:
29     Type: String
30   BootstrapHost:
31     Description: Load mysqldump from this Host
32     Type: String
33     Default: ''
34   BootstrapRootPassword:
35     Description: Root password for localhost access after bootstrap
36     Type: String
37     Default: ''
38   BootstrapDumpPassword:
39     Description: Password to use for mysqldump from Bootstrap Host
40     Type: String
41     Default: ''
42   BootstrapSlaveUser:
43     Description: User to use for replication from bootstrap host
44     Type: String
45     Default: ''
46   BootstrapSlavePassword:
47     Description: Password to use with BootstrapSlaveUser
48     Type: String
49     Default: ''
50 Resources:
51   ApiAccessPolicy:
52     Type: OS::Heat::AccessPolicy
53     Properties:
54       AllowedResources: [ MySQL ]
55   ApiUser:
56     Type: AWS::IAM::User
57     Properties:
58       Policies: [ { Ref: ApiAccessPolicy } ]
59   ApiKey:
60     Type: AWS::IAM::AccessKey
61     Properties:
62       UserName:
63         Ref: ApiUser
64   MySQL:
65     Type: AWS::EC2::Instance
66     Metadata:
67       OpenStack::Role: stateful
68       OpenStack::ImageBuilder::Elements: [ mysql-migration ]
69       mysql:
70         create-users:
71           - database: keystone
72             username: {Ref: KeystoneUser}
73             userhandle: {Ref: KeystonePasswordHandle}
74           - database: heat
75             username: {Ref: HeatUser}
76             userhandle: {Ref: HeatPasswordHandle}
77           - database: glance
78             username: {Ref: GlanceUser}
79             userhandle: {Ref: GlancePasswordHandle}
80           - database: nova
81             username: {Ref: NovaUser}
82             userhandle: {Ref: NovaPasswordHandle}
83       mysql-migration:
84         users:
85           root:
86             username: root
87             password: {Ref: BootstrapRootPassword}
88           dump:
89             username: dump
90             password: {Ref: BootstrapDumpPassword}
91         bootstrap_host: {Ref: BootstrapHost}
92         slave_user: {Ref: BootstrapSlaveUser}
93         slave_password: {Ref: BootstrapSlavePassword}
94       heat:
95         access_key_id:
96           Ref: ApiKey
97         secret_key:
98           Fn::GetAtt: [ ApiKey, SecretAccessKey ]
99         stack:
100           name: {Ref: 'AWS::StackName'}
101           region: {Ref: 'AWS::Region'}
102         refresh:
103           - resource: MySQL
104     Properties:
105       ImageId:
106         {Ref: MySQLImage}
107       InstanceType: {Ref: InstanceType}
108       KeyName: {Ref: KeyName}
109   NovaPasswordHandle:
110     Type: AWS::CloudFormation::WaitConditionHandle
111   NovaPassword:
112     DependsOn: MySQL
113     Type: AWS::CloudFormation::WaitCondition
114     Properties:
115       Handle: {Ref: NovaPasswordHandle}
116       Timeout: 90
117   GlancePasswordHandle:
118     Type: AWS::CloudFormation::WaitConditionHandle
119   GlancePassword:
120     DependsOn: MySQL
121     Type: AWS::CloudFormation::WaitCondition
122     Properties:
123       Handle: {Ref: GlancePasswordHandle}
124       Timeout: 90
125   HeatPasswordHandle:
126     Type: AWS::CloudFormation::WaitConditionHandle
127   HeatPassword:
128     DependsOn: MySQL
129     Type: AWS::CloudFormation::WaitCondition
130     Properties:
131       Handle: {Ref: HeatPasswordHandle}
132       Timeout: 90
133   KeystonePasswordHandle:
134     Type: AWS::CloudFormation::WaitConditionHandle
135   KeystonePassword:
136     DependsOn: MySQL
137     Type: AWS::CloudFormation::WaitCondition
138     Properties:
139       Handle: {Ref: KeystonePasswordHandle}
140       Timeout: 90
141 Outputs:
142     MySQLHost: 
143         Fn::GetAtt: [ MySQL , PrivateIp ]
144     KeystonePassword:
145         Fn::GetAtt: [ KeystonePassword, Data ]
146     KeystoneUser: {Ref: KeystoneUser}
147     HeatPassword:
148         Fn::GetAtt: [ HeatPassword, Data ]
149     HeatUser: {Ref: HeatUser}
150     GlancePassword:
151         Fn::GetAtt: [ GlancePassword, Data ]
152     GlanceUser: {Ref: GlanceUser}
153     NovaPassword:
154         Fn::GetAtt: [ NovaPassword, Data ]
155     NovaUser: {Ref: NovaUser}