From 3734484056d361d76e6040f4bca47d53a5a62532 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Thu, 5 Sep 2013 20:49:48 +1000 Subject: [PATCH] Change the dbinstance to F19 The current template is based on F17 which is eol. Closes-Bug #1215797 Change-Id: I888fba67dc8412c8b57243d76b45494a6beb91c4 --- etc/heat/templates/AWS_RDS_DBInstance.yaml | 55 +++++++++++++++++----- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/etc/heat/templates/AWS_RDS_DBInstance.yaml b/etc/heat/templates/AWS_RDS_DBInstance.yaml index 6f2dd6b980..30173442e6 100644 --- a/etc/heat/templates/AWS_RDS_DBInstance.yaml +++ b/etc/heat/templates/AWS_RDS_DBInstance.yaml @@ -34,37 +34,71 @@ Mappings: db.m2.4xlarge: {Instance: m2.4xlarge} Resources: + ServerSecurityGroup: + Type: AWS::EC2::SecurityGroup + Properties: + GroupDescription: 'Enable SSH access' + SecurityGroupIngress: + - IpProtocol: icmp + FromPort: '-1' + ToPort: '-1' + CidrIp: '0.0.0.0/0' + - IpProtocol: tcp + FromPort: '22' + ToPort : '22' + CidrIp : '0.0.0.0/0' + - IpProtocol: tcp + FromPort: {Ref: Port} + ToPort : {Ref: Port} + CidrIp : '0.0.0.0/0' DatabaseInstance: Type: AWS::EC2::Instance Metadata: AWS::CloudFormation::Init: config: + files: + /tmp/db_setup.sql: + content: + 'Fn::Replace': + - DBName: {Ref: DBName} + MasterUserPassword: {Ref: MasterUserPassword} + MasterUsername: {Ref: MasterUsername} + - | + CREATE DATABASE DBName; + GRANT ALL PRIVILEGES ON DBName.* TO "MasterUsername"@"%" + IDENTIFIED BY "MasterUserPassword"; + FLUSH PRIVILEGES; + EXIT + mode: '000644' + owner: root + group: root packages: yum: - mysql : [] - mysql-server : [] + mariadb: [] + mariadb-server: [] services: systemd: mysqld: enabled: true ensureRunning: true Properties: - ImageId: F17-x86_64-cfntools + ImageId: F19-x86_64-cfntools InstanceType: {'Fn::FindInMap': [DBInstanceToInstance, {Ref: DBInstanceClass}, Instance]} KeyName: {Ref: KeyName} - + SecurityGroups: [{"Ref" : "ServerSecurityGroup"}] UserData: Fn::Base64: Fn::Replace: - 'AWS::StackName': {Ref: 'AWS::StackName'} 'AWS::Region': {Ref: 'AWS::Region'} - MasterUsername: {Ref: MasterUsername} MasterUserPassword: {Ref: MasterUserPassword} - DBName: {Ref: DBName} WaitHandle: {Ref: WaitHandle} - | #!/bin/bash -v + # + iptables -F + # Helper function function error_exit { @@ -74,13 +108,8 @@ Resources: /opt/aws/bin/cfn-init -s AWS::StackName -r DatabaseInstance --region AWS::Region || error_exit 'Failed to run cfn-init' # Setup MySQL root password and create a user mysqladmin -u root password 'MasterUserPassword' - cat << EOF | mysql -u root --password='MasterUserPassword' - CREATE DATABASE DBName; - GRANT ALL PRIVILEGES ON DBName.* TO "MasterUsername"@"%" - IDENTIFIED BY "MasterUserPassword"; - FLUSH PRIVILEGES; - EXIT - EOF + mysql -u root --password='MasterUserPassword' < /tmp/db_setup.sql || error_exit 'Failed to setup mysql' + # Database setup completed, signal success /opt/aws/bin/cfn-signal -e 0 -r "MySQL server setup complete" 'WaitHandle'