Create a utility for merging templates.
[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::Role: stateful
64       OpenStack::ImageBuilder::Elements: [ mysql-migration ]
65       mysql:
66         create-users:
67           - database: keystone
68             username: {Ref: KeystoneUser}
69             userhandle: {Ref: KeystonePasswordHandle}
70           - database: heat
71             username: {Ref: HeatUser}
72             userhandle: {Ref: HeatPasswordHandle}
73           - database: glance
74             username: {Ref: GlanceUser}
75             userhandle: {Ref: GlancePasswordHandle}
76       mysql-migration:
77         users:
78           root:
79             username: root
80             password: {Ref: BootstrapRootPassword}
81           dump:
82             username: dump
83             password: {Ref: BootstrapDumpPassword}
84         bootstrap_host: {Ref: BootstrapHost}
85         slave_user: {Ref: BootstrapSlaveUser}
86         slave_password: {Ref: BootstrapSlavePassword}
87       heat:
88         access_key_id:
89           Ref: ApiKey
90         secret_key:
91           Fn::GetAtt: [ ApiKey, SecretAccessKey ]
92         stack:
93           name: {Ref: 'AWS::StackName'}
94           region: {Ref: 'AWS::Region'}
95         refresh:
96           - resource: MySQL
97     Properties:
98       ImageId:
99         {Ref: MySQLImage}
100       InstanceType: {Ref: InstanceType}
101       KeyName: {Ref: KeyName}
102   GlancePasswordHandle:
103     Type: AWS::CloudFormation::WaitConditionHandle
104   GlancePassword:
105     DependsOn: MySQL
106     Type: AWS::CloudFormation::WaitCondition
107     Properties:
108       Handle: {Ref: GlancePasswordHandle}
109       Timeout: 90
110   HeatPasswordHandle:
111     Type: AWS::CloudFormation::WaitConditionHandle
112   HeatPassword:
113     DependsOn: MySQL
114     Type: AWS::CloudFormation::WaitCondition
115     Properties:
116       Handle: {Ref: HeatPasswordHandle}
117       Timeout: 90
118   KeystonePasswordHandle:
119     Type: AWS::CloudFormation::WaitConditionHandle
120   KeystonePassword:
121     DependsOn: MySQL
122     Type: AWS::CloudFormation::WaitCondition
123     Properties:
124       Handle: {Ref: KeystonePasswordHandle}
125       Timeout: 90
126 Outputs:
127     MySQLHost: 
128         Fn::GetAtt: [ MySQL , PrivateIp ]
129     KeystonePassword:
130         Fn::GetAtt: [ KeystonePassword, Data ]
131     KeystoneUser: {Ref: KeystoneUser}
132     HeatPassword:
133         Fn::GetAtt: [ HeatPassword, Data ]
134     HeatUser: {Ref: HeatUser}
135     GlancePassword:
136         Fn::GetAtt: [ GlancePassword, Data ]
137     GlanceUser: {Ref: GlanceUser}