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