dslh 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d2dfc05d04e7e6e193b066d2ecb8c7cff66c543
4
- data.tar.gz: 33496a369aa2d80a63a5cf4aeceb3bf2f9141a10
3
+ metadata.gz: bb83267e46deb85fd756f9944f66a5ad898551a0
4
+ data.tar.gz: 11fab0af1cd6c6202a3fa92ce88ffbf7c453cf05
5
5
  SHA512:
6
- metadata.gz: 89010f761b726a054d10815815c5971e3dd20937410cd1b533272edbd6cd4b133e18f16021f67c1e7eec125d98ca9c2cf322ae66eadbeda2df8f19a088996ef5
7
- data.tar.gz: ce5a58b6eff9972b0621e3a62ec2ec42f36a9e677990dfa7028ef2ffef7f4db1128b743cc2c167cbd976fc65db49fb7dcc7339b8c1b60d67c8e5703a963ac7f4
6
+ metadata.gz: c39c110477cc9cb2ba1cbbdae481fb13e08160a4b1e7f8de0f6081fc375179bd51d6fc81da76fc7f9029596e438429b0aa625fa5075ceb5791cd7d64dde53fd8
7
+ data.tar.gz: db1cdd35bbe981c41e590882fe8a1ff08663279d1673b21f3606d3af5efa05a2469baa4f0836f9bf6a1c8d187a71717472b66e0d5ae996694cf5eafd43df677c
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  It define Hash as a DSL.
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/dslh.png)](http://badge.fury.io/rb/dslh)
6
- [![Build Status](https://drone.io/github.com/winebarrel/dslh/status.png)](https://drone.io/github.com/winebarrel/dslh/latest)
5
+ [![Gem Version](https://badge.fury.io/rb/dslh.png?201403022334)](http://badge.fury.io/rb/dslh)
6
+ [![Build Status](https://drone.io/github.com/winebarrel/dslh/status.png?201403022334)](https://drone.io/github.com/winebarrel/dslh/latest)
7
7
 
8
8
  ## Installation
9
9
 
data/lib/dslh.rb CHANGED
@@ -107,7 +107,7 @@ class Dslh
107
107
  end
108
108
  end
109
109
 
110
- def value_proc(value, depth, value_buf)
110
+ def value_proc(value, depth, value_buf, newline = true)
111
111
  indent = (INDENT_SPACES * depth)
112
112
  next_indent = (INDENT_SPACES * (depth + 1))
113
113
  value_conv = @options[:value_conv]
@@ -129,10 +129,14 @@ class Dslh
129
129
  value_buf.puts(' [')
130
130
 
131
131
  value.each_with_index do |v, i|
132
- if v.kind_of?(Hash)
132
+ case v
133
+ when Hash
133
134
  value_buf.puts(next_indent + '_{')
134
135
  deval0(v, depth + 2, value_buf)
135
136
  value_buf.print(next_indent + '}')
137
+ when Array
138
+ value_buf.print(next_indent.slice(0...-1))
139
+ value_proc(v, depth + 1, value_buf, false)
136
140
  else
137
141
  value_buf.print(next_indent + v.pretty_inspect.strip.gsub("\n", "\n" + next_indent))
138
142
  end
@@ -140,7 +144,11 @@ class Dslh
140
144
  value_buf.puts(i < (value.length - 1) ? ',' : '')
141
145
  end
142
146
 
143
- value_buf.puts(indent + ']')
147
+ if newline
148
+ value_buf.puts(indent + ']')
149
+ else
150
+ value_buf.print(indent + ']')
151
+ end
144
152
  elsif value.length == 1
145
153
  value_buf.puts(' ' + value.inspect)
146
154
  else
data/lib/dslh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Dslh
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
data/spec/dslh_spec.rb CHANGED
@@ -688,7 +688,13 @@ Resources do
688
688
  Resource do
689
689
  Fn__Join [
690
690
  "",
691
- ["arn:aws:s3:::", {"Ref"=>"S3Bucket"}, "/*"]
691
+ [
692
+ "arn:aws:s3:::",
693
+ _{
694
+ Ref "S3Bucket"
695
+ },
696
+ "/*"
697
+ ]
692
698
  ]
693
699
  end
694
700
  Principal do
@@ -917,80 +923,110 @@ Resources do
917
923
  Fn__Base64 do
918
924
  Fn__Join [
919
925
  "",
920
- ["#!/bin/bash -v\n",
921
- "yum update -y aws-cfn-bootstrap\n",
922
- "# Helper function\n",
923
- "function error_exit\n",
924
- "{\n",
925
- " /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '",
926
- {"Ref"=>"WaitHandle"},
927
- "'\n",
928
- " exit 1\n",
929
- "}\n",
930
- "# Install Apache Web Server, MySQL and Drupal\n",
931
- "/opt/aws/bin/cfn-init -s ",
932
- {"Ref"=>"AWS::StackId"},
933
- " -r LaunchConfig ",
934
- " --region ",
935
- {"Ref"=>"AWS::Region"},
936
- " || error_exit 'Failed to run cfn-init'\n",
937
- "# Install s3fs\n",
938
- "cd /home/ec2-user/s3fs/s3fs-1.61\n",
939
- "./configure --prefix=/usr\n",
940
- "make\n",
941
- "make install\n",
942
- "# Move the website files to the top level\n",
943
- "mv /var/www/html/drupal-7.8/* /var/www/html\n",
944
- "mv /var/www/html/drupal-7.8/.htaccess /var/www/html\n",
945
- "rm -Rf /var/www/html/drupal-7.8\n",
946
- "# Mount the S3 bucket\n",
947
- "mv /var/www/html/sites/default/files /var/www/html/sites/default/files_original\n",
948
- "mkdir -p /var/www/html/sites/default/files\n",
949
- "s3fs -o allow_other -o use_cache=/tmp ",
950
- {"Ref"=>"S3Bucket"},
951
- " /var/www/html/sites/default/files || error_exit 'Failed to mount the S3 bucket'\n",
952
- "echo `hostname` >> /var/www/html/sites/default/files/hosts\n",
953
- "# Make changes to Apache Web Server configuration\n",
954
- "sed -i 's/AllowOverride None/AllowOverride All/g' /etc/httpd/conf/httpd.conf\n",
955
- "service httpd restart\n",
956
- "# Only execute the site install if we are the first host up - otherwise we'll end up losing all the data\n",
957
- "read first < /var/www/html/sites/default/files/hosts\n",
958
- "if [ `hostname` = $first ]\n",
959
- "then\n",
960
- " # Create the site in Drupal\n",
961
- " cd /var/www/html\n",
962
- " ~ec2-user/drush/drush site-install standard --yes",
963
- " --site-name='",
964
- {"Ref"=>"SiteName"},
965
- "' --site-mail=",
966
- {"Ref"=>"SiteEMail"},
967
- " --account-name=",
968
- {"Ref"=>"SiteAdmin"},
969
- " --account-pass=",
970
- {"Ref"=>"SitePassword"},
971
- " --db-url=mysql://",
972
- {"Ref"=>"DBUsername"},
973
- ":",
974
- {"Ref"=>"DBPassword"},
975
- "@",
976
- {"Fn::GetAtt"=>["DBInstance", "Endpoint.Address"]},
977
- ":",
978
- {"Fn::GetAtt"=>["DBInstance", "Endpoint.Port"]},
979
- "/",
980
- {"Ref"=>"DBName"},
981
- " --db-prefix=drupal_\n",
982
- " # use the S3 bucket for shared file storage\n",
983
- " cp -R sites/default/files_original/* sites/default/files\n",
984
- " cp -R sites/default/files_original/.htaccess sites/default/files\n",
985
- "else\n",
986
- " # Copy settings.php file since everything else is configured\n",
987
- " cp /home/ec2-user/settings.php /var/www/html/sites/default\n",
988
- "fi\n",
989
- "rm /home/ec2-user/settings.php\n",
990
- "# All is well so signal success\n",
991
- "/opt/aws/bin/cfn-signal -e 0 -r \"Drupal setup complete\" '",
992
- {"Ref"=>"WaitHandle"},
993
- "'\n"]
926
+ [
927
+ "#!/bin/bash -v\n",
928
+ "yum update -y aws-cfn-bootstrap\n",
929
+ "# Helper function\n",
930
+ "function error_exit\n",
931
+ "{\n",
932
+ " /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '",
933
+ _{
934
+ Ref "WaitHandle"
935
+ },
936
+ "'\n",
937
+ " exit 1\n",
938
+ "}\n",
939
+ "# Install Apache Web Server, MySQL and Drupal\n",
940
+ "/opt/aws/bin/cfn-init -s ",
941
+ _{
942
+ Ref "AWS::StackId"
943
+ },
944
+ " -r LaunchConfig ",
945
+ " --region ",
946
+ _{
947
+ Ref "AWS::Region"
948
+ },
949
+ " || error_exit 'Failed to run cfn-init'\n",
950
+ "# Install s3fs\n",
951
+ "cd /home/ec2-user/s3fs/s3fs-1.61\n",
952
+ "./configure --prefix=/usr\n",
953
+ "make\n",
954
+ "make install\n",
955
+ "# Move the website files to the top level\n",
956
+ "mv /var/www/html/drupal-7.8/* /var/www/html\n",
957
+ "mv /var/www/html/drupal-7.8/.htaccess /var/www/html\n",
958
+ "rm -Rf /var/www/html/drupal-7.8\n",
959
+ "# Mount the S3 bucket\n",
960
+ "mv /var/www/html/sites/default/files /var/www/html/sites/default/files_original\n",
961
+ "mkdir -p /var/www/html/sites/default/files\n",
962
+ "s3fs -o allow_other -o use_cache=/tmp ",
963
+ _{
964
+ Ref "S3Bucket"
965
+ },
966
+ " /var/www/html/sites/default/files || error_exit 'Failed to mount the S3 bucket'\n",
967
+ "echo `hostname` >> /var/www/html/sites/default/files/hosts\n",
968
+ "# Make changes to Apache Web Server configuration\n",
969
+ "sed -i 's/AllowOverride None/AllowOverride All/g' /etc/httpd/conf/httpd.conf\n",
970
+ "service httpd restart\n",
971
+ "# Only execute the site install if we are the first host up - otherwise we'll end up losing all the data\n",
972
+ "read first < /var/www/html/sites/default/files/hosts\n",
973
+ "if [ `hostname` = $first ]\n",
974
+ "then\n",
975
+ " # Create the site in Drupal\n",
976
+ " cd /var/www/html\n",
977
+ " ~ec2-user/drush/drush site-install standard --yes",
978
+ " --site-name='",
979
+ _{
980
+ Ref "SiteName"
981
+ },
982
+ "' --site-mail=",
983
+ _{
984
+ Ref "SiteEMail"
985
+ },
986
+ " --account-name=",
987
+ _{
988
+ Ref "SiteAdmin"
989
+ },
990
+ " --account-pass=",
991
+ _{
992
+ Ref "SitePassword"
993
+ },
994
+ " --db-url=mysql://",
995
+ _{
996
+ Ref "DBUsername"
997
+ },
998
+ ":",
999
+ _{
1000
+ Ref "DBPassword"
1001
+ },
1002
+ "@",
1003
+ _{
1004
+ Fn__GetAtt "DBInstance", "Endpoint.Address"
1005
+ },
1006
+ ":",
1007
+ _{
1008
+ Fn__GetAtt "DBInstance", "Endpoint.Port"
1009
+ },
1010
+ "/",
1011
+ _{
1012
+ Ref "DBName"
1013
+ },
1014
+ " --db-prefix=drupal_\n",
1015
+ " # use the S3 bucket for shared file storage\n",
1016
+ " cp -R sites/default/files_original/* sites/default/files\n",
1017
+ " cp -R sites/default/files_original/.htaccess sites/default/files\n",
1018
+ "else\n",
1019
+ " # Copy settings.php file since everything else is configured\n",
1020
+ " cp /home/ec2-user/settings.php /var/www/html/sites/default\n",
1021
+ "fi\n",
1022
+ "rm /home/ec2-user/settings.php\n",
1023
+ "# All is well so signal success\n",
1024
+ "/opt/aws/bin/cfn-signal -e 0 -r \"Drupal setup complete\" '",
1025
+ _{
1026
+ Ref "WaitHandle"
1027
+ },
1028
+ "'\n"
1029
+ ]
994
1030
  ]
995
1031
  end
996
1032
  end
@@ -1082,7 +1118,12 @@ Outputs do
1082
1118
  Value do
1083
1119
  Fn__Join [
1084
1120
  "",
1085
- ["http://", {"Fn::GetAtt"=>["ElasticLoadBalancer", "DNSName"]}]
1121
+ [
1122
+ "http://",
1123
+ _{
1124
+ Fn__GetAtt "ElasticLoadBalancer", "DNSName"
1125
+ }
1126
+ ]
1086
1127
  ]
1087
1128
  end
1088
1129
  Description "Drupal Website"
@@ -1284,7 +1325,13 @@ Resources do
1284
1325
  Resource do
1285
1326
  Fn__Join [
1286
1327
  "",
1287
- ["arn:aws:s3:::", {"Ref"=>"S3Bucket"}, "/*"]
1328
+ [
1329
+ "arn:aws:s3:::",
1330
+ _{
1331
+ Ref "S3Bucket"
1332
+ },
1333
+ "/*"
1334
+ ]
1288
1335
  ]
1289
1336
  end
1290
1337
  Principal do
@@ -1416,7 +1463,16 @@ Resources do
1416
1463
  content do
1417
1464
  Fn__Join [
1418
1465
  "",
1419
- [{"Ref"=>"S3Keys"}, ":", {"Fn::GetAtt"=>["S3Keys", "SecretAccessKey"]}, "\n"]
1466
+ [
1467
+ _{
1468
+ Ref "S3Keys"
1469
+ },
1470
+ ":",
1471
+ _{
1472
+ Fn__GetAtt "S3Keys", "SecretAccessKey"
1473
+ },
1474
+ "\n"
1475
+ ]
1420
1476
  ]
1421
1477
  end
1422
1478
  mode "000400"
@@ -1427,42 +1483,54 @@ Resources do
1427
1483
  content do
1428
1484
  Fn__Join [
1429
1485
  "",
1430
- ["<?php\n",
1431
- "\n",
1432
- "$databases = array (\n",
1433
- " 'default' =>\n",
1434
- " array (\n",
1435
- " 'default' =>\n",
1436
- " array (\n",
1437
- " 'database' => '",
1438
- {"Ref"=>"DBName"},
1439
- "',\n",
1440
- " 'username' => '",
1441
- {"Ref"=>"DBUsername"},
1442
- "',\n",
1443
- " 'password' => '",
1444
- {"Ref"=>"DBPassword"},
1445
- "',\n",
1446
- " 'host' => '",
1447
- {"Fn::GetAtt"=>["DBInstance", "Endpoint.Address"]},
1448
- "',\n",
1449
- " 'port' => '",
1450
- {"Fn::GetAtt"=>["DBInstance", "Endpoint.Port"]},
1451
- "',\n",
1452
- " 'driver' => 'mysql',\n",
1453
- " 'prefix' => 'drupal_',\n",
1454
- " ),\n",
1455
- " ),\n",
1456
- ");\n",
1457
- "\n",
1458
- "$update_free_access = FALSE;\n",
1459
- "\n",
1460
- "$drupal_hash_salt = '0c3R8noNALe3shsioQr5hK1dMHdwRfikLoSfqn0_xpA';\n",
1461
- "\n",
1462
- "ini_set('session.gc_probability', 1);\n",
1463
- "ini_set('session.gc_divisor', 100);\n",
1464
- "ini_set('session.gc_maxlifetime', 200000);\n",
1465
- "ini_set('session.cookie_lifetime', 2000000);\n"]
1486
+ [
1487
+ "<?php\n",
1488
+ "\n",
1489
+ "$databases = array (\n",
1490
+ " 'default' =>\n",
1491
+ " array (\n",
1492
+ " 'default' =>\n",
1493
+ " array (\n",
1494
+ " 'database' => '",
1495
+ _{
1496
+ Ref "DBName"
1497
+ },
1498
+ "',\n",
1499
+ " 'username' => '",
1500
+ _{
1501
+ Ref "DBUsername"
1502
+ },
1503
+ "',\n",
1504
+ " 'password' => '",
1505
+ _{
1506
+ Ref "DBPassword"
1507
+ },
1508
+ "',\n",
1509
+ " 'host' => '",
1510
+ _{
1511
+ Fn__GetAtt "DBInstance", "Endpoint.Address"
1512
+ },
1513
+ "',\n",
1514
+ " 'port' => '",
1515
+ _{
1516
+ Fn__GetAtt "DBInstance", "Endpoint.Port"
1517
+ },
1518
+ "',\n",
1519
+ " 'driver' => 'mysql',\n",
1520
+ " 'prefix' => 'drupal_',\n",
1521
+ " ),\n",
1522
+ " ),\n",
1523
+ ");\n",
1524
+ "\n",
1525
+ "$update_free_access = FALSE;\n",
1526
+ "\n",
1527
+ "$drupal_hash_salt = '0c3R8noNALe3shsioQr5hK1dMHdwRfikLoSfqn0_xpA';\n",
1528
+ "\n",
1529
+ "ini_set('session.gc_probability', 1);\n",
1530
+ "ini_set('session.gc_divisor', 100);\n",
1531
+ "ini_set('session.gc_maxlifetime', 200000);\n",
1532
+ "ini_set('session.cookie_lifetime', 2000000);\n"
1533
+ ]
1466
1534
  ]
1467
1535
  end
1468
1536
  mode "000400"
@@ -1518,80 +1586,110 @@ Resources do
1518
1586
  Fn__Base64 do
1519
1587
  Fn__Join [
1520
1588
  "",
1521
- ["#!/bin/bash -v\n",
1522
- "yum update -y aws-cfn-bootstrap\n",
1523
- "# Helper function\n",
1524
- "function error_exit\n",
1525
- "{\n",
1526
- " /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '",
1527
- {"Ref"=>"WaitHandle"},
1528
- "'\n",
1529
- " exit 1\n",
1530
- "}\n",
1531
- "# Install Apache Web Server, MySQL and Drupal\n",
1532
- "/opt/aws/bin/cfn-init -s ",
1533
- {"Ref"=>"AWS::StackId"},
1534
- " -r LaunchConfig ",
1535
- " --region ",
1536
- {"Ref"=>"AWS::Region"},
1537
- " || error_exit 'Failed to run cfn-init'\n",
1538
- "# Install s3fs\n",
1539
- "cd /home/ec2-user/s3fs/s3fs-1.61\n",
1540
- "./configure --prefix=/usr\n",
1541
- "make\n",
1542
- "make install\n",
1543
- "# Move the website files to the top level\n",
1544
- "mv /var/www/html/drupal-7.8/* /var/www/html\n",
1545
- "mv /var/www/html/drupal-7.8/.htaccess /var/www/html\n",
1546
- "rm -Rf /var/www/html/drupal-7.8\n",
1547
- "# Mount the S3 bucket\n",
1548
- "mv /var/www/html/sites/default/files /var/www/html/sites/default/files_original\n",
1549
- "mkdir -p /var/www/html/sites/default/files\n",
1550
- "s3fs -o allow_other -o use_cache=/tmp ",
1551
- {"Ref"=>"S3Bucket"},
1552
- " /var/www/html/sites/default/files || error_exit 'Failed to mount the S3 bucket'\n",
1553
- "echo `hostname` >> /var/www/html/sites/default/files/hosts\n",
1554
- "# Make changes to Apache Web Server configuration\n",
1555
- "sed -i 's/AllowOverride None/AllowOverride All/g' /etc/httpd/conf/httpd.conf\n",
1556
- "service httpd restart\n",
1557
- "# Only execute the site install if we are the first host up - otherwise we'll end up losing all the data\n",
1558
- "read first < /var/www/html/sites/default/files/hosts\n",
1559
- "if [ `hostname` = $first ]\n",
1560
- "then\n",
1561
- " # Create the site in Drupal\n",
1562
- " cd /var/www/html\n",
1563
- " ~ec2-user/drush/drush site-install standard --yes",
1564
- " --site-name='",
1565
- {"Ref"=>"SiteName"},
1566
- "' --site-mail=",
1567
- {"Ref"=>"SiteEMail"},
1568
- " --account-name=",
1569
- {"Ref"=>"SiteAdmin"},
1570
- " --account-pass=",
1571
- {"Ref"=>"SitePassword"},
1572
- " --db-url=mysql://",
1573
- {"Ref"=>"DBUsername"},
1574
- ":",
1575
- {"Ref"=>"DBPassword"},
1576
- "@",
1577
- {"Fn::GetAtt"=>["DBInstance", "Endpoint.Address"]},
1578
- ":",
1579
- {"Fn::GetAtt"=>["DBInstance", "Endpoint.Port"]},
1580
- "/",
1581
- {"Ref"=>"DBName"},
1582
- " --db-prefix=drupal_\n",
1583
- " # use the S3 bucket for shared file storage\n",
1584
- " cp -R sites/default/files_original/* sites/default/files\n",
1585
- " cp -R sites/default/files_original/.htaccess sites/default/files\n",
1586
- "else\n",
1587
- " # Copy settings.php file since everything else is configured\n",
1588
- " cp /home/ec2-user/settings.php /var/www/html/sites/default\n",
1589
- "fi\n",
1590
- "rm /home/ec2-user/settings.php\n",
1591
- "# All is well so signal success\n",
1592
- "/opt/aws/bin/cfn-signal -e 0 -r \"Drupal setup complete\" '",
1593
- {"Ref"=>"WaitHandle"},
1594
- "'\n"]
1589
+ [
1590
+ "#!/bin/bash -v\n",
1591
+ "yum update -y aws-cfn-bootstrap\n",
1592
+ "# Helper function\n",
1593
+ "function error_exit\n",
1594
+ "{\n",
1595
+ " /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '",
1596
+ _{
1597
+ Ref "WaitHandle"
1598
+ },
1599
+ "'\n",
1600
+ " exit 1\n",
1601
+ "}\n",
1602
+ "# Install Apache Web Server, MySQL and Drupal\n",
1603
+ "/opt/aws/bin/cfn-init -s ",
1604
+ _{
1605
+ Ref "AWS::StackId"
1606
+ },
1607
+ " -r LaunchConfig ",
1608
+ " --region ",
1609
+ _{
1610
+ Ref "AWS::Region"
1611
+ },
1612
+ " || error_exit 'Failed to run cfn-init'\n",
1613
+ "# Install s3fs\n",
1614
+ "cd /home/ec2-user/s3fs/s3fs-1.61\n",
1615
+ "./configure --prefix=/usr\n",
1616
+ "make\n",
1617
+ "make install\n",
1618
+ "# Move the website files to the top level\n",
1619
+ "mv /var/www/html/drupal-7.8/* /var/www/html\n",
1620
+ "mv /var/www/html/drupal-7.8/.htaccess /var/www/html\n",
1621
+ "rm -Rf /var/www/html/drupal-7.8\n",
1622
+ "# Mount the S3 bucket\n",
1623
+ "mv /var/www/html/sites/default/files /var/www/html/sites/default/files_original\n",
1624
+ "mkdir -p /var/www/html/sites/default/files\n",
1625
+ "s3fs -o allow_other -o use_cache=/tmp ",
1626
+ _{
1627
+ Ref "S3Bucket"
1628
+ },
1629
+ " /var/www/html/sites/default/files || error_exit 'Failed to mount the S3 bucket'\n",
1630
+ "echo `hostname` >> /var/www/html/sites/default/files/hosts\n",
1631
+ "# Make changes to Apache Web Server configuration\n",
1632
+ "sed -i 's/AllowOverride None/AllowOverride All/g' /etc/httpd/conf/httpd.conf\n",
1633
+ "service httpd restart\n",
1634
+ "# Only execute the site install if we are the first host up - otherwise we'll end up losing all the data\n",
1635
+ "read first < /var/www/html/sites/default/files/hosts\n",
1636
+ "if [ `hostname` = $first ]\n",
1637
+ "then\n",
1638
+ " # Create the site in Drupal\n",
1639
+ " cd /var/www/html\n",
1640
+ " ~ec2-user/drush/drush site-install standard --yes",
1641
+ " --site-name='",
1642
+ _{
1643
+ Ref "SiteName"
1644
+ },
1645
+ "' --site-mail=",
1646
+ _{
1647
+ Ref "SiteEMail"
1648
+ },
1649
+ " --account-name=",
1650
+ _{
1651
+ Ref "SiteAdmin"
1652
+ },
1653
+ " --account-pass=",
1654
+ _{
1655
+ Ref "SitePassword"
1656
+ },
1657
+ " --db-url=mysql://",
1658
+ _{
1659
+ Ref "DBUsername"
1660
+ },
1661
+ ":",
1662
+ _{
1663
+ Ref "DBPassword"
1664
+ },
1665
+ "@",
1666
+ _{
1667
+ Fn__GetAtt "DBInstance", "Endpoint.Address"
1668
+ },
1669
+ ":",
1670
+ _{
1671
+ Fn__GetAtt "DBInstance", "Endpoint.Port"
1672
+ },
1673
+ "/",
1674
+ _{
1675
+ Ref "DBName"
1676
+ },
1677
+ " --db-prefix=drupal_\n",
1678
+ " # use the S3 bucket for shared file storage\n",
1679
+ " cp -R sites/default/files_original/* sites/default/files\n",
1680
+ " cp -R sites/default/files_original/.htaccess sites/default/files\n",
1681
+ "else\n",
1682
+ " # Copy settings.php file since everything else is configured\n",
1683
+ " cp /home/ec2-user/settings.php /var/www/html/sites/default\n",
1684
+ "fi\n",
1685
+ "rm /home/ec2-user/settings.php\n",
1686
+ "# All is well so signal success\n",
1687
+ "/opt/aws/bin/cfn-signal -e 0 -r \"Drupal setup complete\" '",
1688
+ _{
1689
+ Ref "WaitHandle"
1690
+ },
1691
+ "'\n"
1692
+ ]
1595
1693
  ]
1596
1694
  end
1597
1695
  end
@@ -1683,7 +1781,12 @@ Outputs do
1683
1781
  Value do
1684
1782
  Fn__Join [
1685
1783
  "",
1686
- ["http://", {"Fn::GetAtt"=>["ElasticLoadBalancer", "DNSName"]}]
1784
+ [
1785
+ "http://",
1786
+ _{
1787
+ Fn__GetAtt "ElasticLoadBalancer", "DNSName"
1788
+ }
1789
+ ]
1687
1790
  ]
1688
1791
  end
1689
1792
  Description "Drupal Website"
@@ -1874,20 +1977,32 @@ Resources do
1874
1977
  content do
1875
1978
  Fn__Join [
1876
1979
  "",
1877
- ["CREATE DATABASE ",
1878
- {"Ref"=>"DBName"},
1879
- ";\n",
1880
- "CREATE USER '",
1881
- {"Ref"=>"DBUsername"},
1882
- "'@'localhost' IDENTIFIED BY '",
1883
- {"Ref"=>"DBPassword"},
1884
- "';\n",
1885
- "GRANT ALL ON ",
1886
- {"Ref"=>"DBName"},
1887
- ".* TO '",
1888
- {"Ref"=>"DBUsername"},
1889
- "'@'localhost';\n",
1890
- "FLUSH PRIVILEGES;\n"]
1980
+ [
1981
+ "CREATE DATABASE ",
1982
+ _{
1983
+ Ref "DBName"
1984
+ },
1985
+ ";\n",
1986
+ "CREATE USER '",
1987
+ _{
1988
+ Ref "DBUsername"
1989
+ },
1990
+ "'@'localhost' IDENTIFIED BY '",
1991
+ _{
1992
+ Ref "DBPassword"
1993
+ },
1994
+ "';\n",
1995
+ "GRANT ALL ON ",
1996
+ _{
1997
+ Ref "DBName"
1998
+ },
1999
+ ".* TO '",
2000
+ _{
2001
+ Ref "DBUsername"
2002
+ },
2003
+ "'@'localhost';\n",
2004
+ "FLUSH PRIVILEGES;\n"
2005
+ ]
1891
2006
  ]
1892
2007
  end
1893
2008
  mode "000644"
@@ -1947,59 +2062,87 @@ Resources do
1947
2062
  Fn__Base64 do
1948
2063
  Fn__Join [
1949
2064
  "",
1950
- ["#!/bin/bash -v\n",
1951
- "yum update -y aws-cfn-bootstrap\n",
1952
- "# Helper function\n",
1953
- "function error_exit\n",
1954
- "{\n",
1955
- " /opt/aws/bin/cfn-signal -e 0 -r \"$1\" '",
1956
- {"Ref"=>"WaitHandle"},
1957
- "'\n",
1958
- " exit 1\n",
1959
- "}\n",
1960
- "# Install Apache Web Server, MySQL, PHP and Drupal\n",
1961
- "/opt/aws/bin/cfn-init -s ",
1962
- {"Ref"=>"AWS::StackId"},
1963
- " -r WebServer ",
1964
- " --region ",
1965
- {"Ref"=>"AWS::Region"},
1966
- " || error_exit 'Failed to run cfn-init'\n",
1967
- "# Setup MySQL root password and create a user\n",
1968
- "mysqladmin -u root password '",
1969
- {"Ref"=>"DBRootPassword"},
1970
- "' || error_exit 'Failed to initialize root password'\n",
1971
- "mysql -u root --password='",
1972
- {"Ref"=>"DBRootPassword"},
1973
- "' < /tmp/setup.mysql || error_exit 'Failed to create database user'\n",
1974
- "# Make changes to Apache Web Server configuration\n",
1975
- "mv /var/www/html/drupal-7.8/* /var/www/html\n",
1976
- "mv /var/www/html/drupal-7.8/.* /var/www/html\n",
1977
- "rmdir /var/www/html/drupal-7.8\n",
1978
- "sed -i 's/AllowOverride None/AllowOverride All/g' /etc/httpd/conf/httpd.conf\n",
1979
- "service httpd restart\n",
1980
- "# Create the site in Drupal\n",
1981
- "cd /var/www/html\n",
1982
- "~ec2-user/drush/drush site-install standard --yes",
1983
- " --site-name='",
1984
- {"Ref"=>"SiteName"},
1985
- "' --site-mail=",
1986
- {"Ref"=>"SiteEMail"},
1987
- " --account-name=",
1988
- {"Ref"=>"SiteAdmin"},
1989
- " --account-pass=",
1990
- {"Ref"=>"SitePassword"},
1991
- " --db-url=mysql://",
1992
- {"Ref"=>"DBUsername"},
1993
- ":",
1994
- {"Ref"=>"DBPassword"},
1995
- "@localhost/",
1996
- {"Ref"=>"DBName"},
1997
- " --db-prefix=drupal_\n",
1998
- "chown apache:apache sites/default/files\n",
1999
- "# All is well so signal success\n",
2000
- "/opt/aws/bin/cfn-signal -e 0 -r \"Drupal setup complete\" '",
2001
- {"Ref"=>"WaitHandle"},
2002
- "'\n"]
2065
+ [
2066
+ "#!/bin/bash -v\n",
2067
+ "yum update -y aws-cfn-bootstrap\n",
2068
+ "# Helper function\n",
2069
+ "function error_exit\n",
2070
+ "{\n",
2071
+ " /opt/aws/bin/cfn-signal -e 0 -r \"$1\" '",
2072
+ _{
2073
+ Ref "WaitHandle"
2074
+ },
2075
+ "'\n",
2076
+ " exit 1\n",
2077
+ "}\n",
2078
+ "# Install Apache Web Server, MySQL, PHP and Drupal\n",
2079
+ "/opt/aws/bin/cfn-init -s ",
2080
+ _{
2081
+ Ref "AWS::StackId"
2082
+ },
2083
+ " -r WebServer ",
2084
+ " --region ",
2085
+ _{
2086
+ Ref "AWS::Region"
2087
+ },
2088
+ " || error_exit 'Failed to run cfn-init'\n",
2089
+ "# Setup MySQL root password and create a user\n",
2090
+ "mysqladmin -u root password '",
2091
+ _{
2092
+ Ref "DBRootPassword"
2093
+ },
2094
+ "' || error_exit 'Failed to initialize root password'\n",
2095
+ "mysql -u root --password='",
2096
+ _{
2097
+ Ref "DBRootPassword"
2098
+ },
2099
+ "' < /tmp/setup.mysql || error_exit 'Failed to create database user'\n",
2100
+ "# Make changes to Apache Web Server configuration\n",
2101
+ "mv /var/www/html/drupal-7.8/* /var/www/html\n",
2102
+ "mv /var/www/html/drupal-7.8/.* /var/www/html\n",
2103
+ "rmdir /var/www/html/drupal-7.8\n",
2104
+ "sed -i 's/AllowOverride None/AllowOverride All/g' /etc/httpd/conf/httpd.conf\n",
2105
+ "service httpd restart\n",
2106
+ "# Create the site in Drupal\n",
2107
+ "cd /var/www/html\n",
2108
+ "~ec2-user/drush/drush site-install standard --yes",
2109
+ " --site-name='",
2110
+ _{
2111
+ Ref "SiteName"
2112
+ },
2113
+ "' --site-mail=",
2114
+ _{
2115
+ Ref "SiteEMail"
2116
+ },
2117
+ " --account-name=",
2118
+ _{
2119
+ Ref "SiteAdmin"
2120
+ },
2121
+ " --account-pass=",
2122
+ _{
2123
+ Ref "SitePassword"
2124
+ },
2125
+ " --db-url=mysql://",
2126
+ _{
2127
+ Ref "DBUsername"
2128
+ },
2129
+ ":",
2130
+ _{
2131
+ Ref "DBPassword"
2132
+ },
2133
+ "@localhost/",
2134
+ _{
2135
+ Ref "DBName"
2136
+ },
2137
+ " --db-prefix=drupal_\n",
2138
+ "chown apache:apache sites/default/files\n",
2139
+ "# All is well so signal success\n",
2140
+ "/opt/aws/bin/cfn-signal -e 0 -r \"Drupal setup complete\" '",
2141
+ _{
2142
+ Ref "WaitHandle"
2143
+ },
2144
+ "'\n"
2145
+ ]
2003
2146
  ]
2004
2147
  end
2005
2148
  end
@@ -2046,7 +2189,12 @@ Outputs do
2046
2189
  Value do
2047
2190
  Fn__Join [
2048
2191
  "",
2049
- ["http://", {"Fn::GetAtt"=>["WebServer", "PublicDnsName"]}]
2192
+ [
2193
+ "http://",
2194
+ _{
2195
+ Fn__GetAtt "WebServer", "PublicDnsName"
2196
+ }
2197
+ ]
2050
2198
  ]
2051
2199
  end
2052
2200
  Description "Drupal Website"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dslh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara