Match Metadata with tripleo-image-elements.
[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       mysql:
61         create-users:
62           - database: keystone
63             username: {Ref: KeystoneUser}
64             userhandle: {Ref: KeystonePasswordHandle}
65           - database: heat
66             username: {Ref: HeatUser}
67             userhandle: {Ref: HeatPasswordHandle}
68       mysql-migration:
69         users:
70           root:
71             username: root
72             password: {Ref: BootstrapRootPassword}
73           dump:
74             username: dump
75             password: {Ref: BootstrapDumpPassword}
76         bootstrap_host: {Ref: BootstrapHost}
77         slave_user: {Ref: BootstrapSlaveUser}
78         slave_password: {Ref: BootstrapSlavePassword}
79       heat:
80         access_key_id:
81           Ref: ApiKey
82         secret_key:
83           Fn::GetAtt: [ ApiKey, SecretAccessKey ]
84         stack:
85           name: {Ref: 'AWS::StackName'}
86           region: {Ref: 'AWS::Region'}
87         refresh:
88           - resource: MySQL
89     Properties:
90       ImageId:
91         {Ref: MySQLImage}
92       InstanceType: {Ref: InstanceType}
93       KeyName: {Ref: KeyName}
94   HeatPasswordHandle:
95     Type: AWS::CloudFormation::WaitConditionHandle
96   HeatPassword:
97     DependsOn: MySQL
98     Type: AWS::CloudFormation::WaitCondition
99     Properties:
100       Handle: {Ref: HeatPasswordHandle}
101       Timeout: 90
102   KeystonePasswordHandle:
103     Type: AWS::CloudFormation::WaitConditionHandle
104   KeystonePassword:
105     DependsOn: MySQL
106     Type: AWS::CloudFormation::WaitCondition
107     Properties:
108       Handle: {Ref: KeystonePasswordHandle}
109       Timeout: 90
110 Outputs:
111     MySQLHost: 
112         Fn::GetAtt: [ MySQL , PrivateIp ]
113     KeystonePassword:
114         Fn::GetAtt: [ KeystonePassword, Data ]
115     KeystoneUser: {Ref: KeystoneUser}
116     HeatPassword:
117         Fn::GetAtt: [ HeatPassword, Data ]
118     HeatUser: {Ref: HeatUser}