Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: ubuntu:16.04
- image: ubuntu:20.04
steps:
- checkout
- run:
Expand Down
8 changes: 4 additions & 4 deletions deploy/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# please see the online documentation at vagrantup.com.

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu/xenial32"
config.vm.box = "ubuntu/focal64"

# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
#config.vm.box_url = "http://files.vagrantup.com/xenial32.box"
#config.vm.box_url = "http://files.vagrantup.com/focal64.box"

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
Expand Down Expand Up @@ -65,8 +65,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
aws.security_groups = ["buttonmen-dev"]
aws.iam_instance_profile_name = "ec2_instance_perms"

aws.instance_type = "t1.micro"
aws.ami = "ami-0735ea082a1534cac"
aws.instance_type = "t2.micro"
aws.ami = "ami-022d4249382309a48"

override.ssh.username = "ubuntu"
override.ssh.private_key_path = "BUTTONMEN_SSH_PRIVATE_KEY_PATH"
Expand Down
2 changes: 2 additions & 0 deletions deploy/vagrant/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Exit if anything goes wrong
set -e

export DEBIAN_FRONTEND=noninteractive

# Make sure puppet is installed
if which puppet > /dev/null ; then
echo "Puppet is already installed"
Expand Down
2 changes: 1 addition & 1 deletion deploy/vagrant/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$puppet_timestamp = generate('/bin/date', '+%s')

case "$operatingsystemrelease" {
"14.04", "16.04": {
"14.04", "16.04", "18.04", "20.04": {
$puppet_apache_sitesdir = "sites-enabled"
}
default: {
Expand Down
8 changes: 4 additions & 4 deletions deploy/vagrant/modules/apache/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}

# Monitor the error log
include "apache::server::feature::monitor-logs"
include "apache::server::feature::monitorlogs"

# Install and configure letsencrypt (SSL/certbot) for AWS instances
case "${ec2_services_partition}" {
Expand Down Expand Up @@ -49,7 +49,7 @@
include "apache::server::vagrant"
}

class apache::server::feature::monitor-logs {
class apache::server::feature::monitorlogs {

# Install the logtail package
package {
Expand All @@ -60,13 +60,13 @@
# Setup a directory for logtail2 to use for its offset files
"/var/spool/logtail":
ensure => directory,
mode => 0755;
mode => "0755";

# Install a script to use for monitoring logs
"/usr/local/sbin/monitor_apache_logs":
ensure => file,
content => template("apache/monitor_apache_logs.erb"),
mode => 0555;
mode => "0555";
}

# Run the log-monitoring script from a nightly cron job
Expand Down
2 changes: 1 addition & 1 deletion deploy/vagrant/modules/apache/templates/site_default.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## Set environment variables for buttonmen database access

# Database 1 (primary)
SetEnv DB1_HOST <%= database_fqdn %>
SetEnv DB1_HOST <%= @database_fqdn %>
SetEnv DB1_PORT 3306
SetEnv DB1_NAME buttonmen
SetEnv DB1_USER bmuser1
Expand Down
18 changes: 9 additions & 9 deletions deploy/vagrant/modules/buttonmen/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,42 @@
"/usr/local/bin/create_buttonmen_databases":
ensure => file,
content => template("buttonmen/create_databases.erb"),
mode => 0555;
mode => "0555";

"/usr/local/bin/create_rds_database":
ensure => file,
content => template("buttonmen/create_rds_database.erb"),
mode => 0555;
mode => "0555";

"/usr/local/bin/backup_buttonmen_database":
ensure => file,
content => template("buttonmen/backup_database.erb"),
mode => 0555;
mode => "0555";

"/usr/local/bin/test_buttonmen_config":
ensure => file,
content => template("buttonmen/test_config.erb"),
mode => 0555;
mode => "0555";

"/usr/local/bin/mysql_root_cli":
ensure => file,
content => template("buttonmen/mysql_root_cli.erb"),
mode => 0544;
mode => "0544";

"/usr/local/bin/run_buttonmen_tests":
ensure => file,
content => template("buttonmen/run_buttonmen_tests.erb"),
mode => 0555;
mode => "0555";

"/usr/local/bin/setup_buttonmen_ui_cache_links":
ensure => file,
content => template("buttonmen/setup_ui_cache_links.erb"),
mode => 0555;
mode => "0555";

"/usr/local/bin/audit_js_unit_test_coverage":
ensure => file,
content => template("buttonmen/audit_js_unit_test_coverage.erb"),
mode => 0555;
mode => "0555";

"/usr/local/etc/buttonmen_phpunit.php":
ensure => file,
Expand All @@ -64,7 +64,7 @@
"/srv/backup":
ensure => directory,
group => "adm",
mode => 0750;
mode => "0750";
}

exec {
Expand Down
14 changes: 7 additions & 7 deletions deploy/vagrant/modules/buttonmen/templates/apache.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
## Set environment variables for buttonmen database access

# Database 1 (primary)
SetEnv DB1_HOST <%= database_fqdn %>
SetEnv DB1_HOST <%= @database_fqdn %>
SetEnv DB1_PORT 3306
SetEnv DB1_NAME <%= buttonmen_db1_name %>
SetEnv DB1_USER <%= buttonmen_db1_user %>
SetEnv DB1_PASS <%= buttonmen_db1_pass %>
SetEnv DB1_NAME <%= @buttonmen_db1_name %>
SetEnv DB1_USER <%= @buttonmen_db1_user %>
SetEnv DB1_PASS <%= @buttonmen_db1_pass %>

# Database 2 (test)
SetEnv DB2_HOST 127.0.0.1
SetEnv DB2_PORT 3306
SetEnv DB2_NAME <%= buttonmen_db2_name %>
SetEnv DB2_USER <%= buttonmen_db2_user %>
SetEnv DB2_PASS <%= buttonmen_db2_pass %>
SetEnv DB2_NAME <%= @buttonmen_db2_name %>
SetEnv DB2_USER <%= @buttonmen_db2_user %>
SetEnv DB2_PASS <%= @buttonmen_db2_pass %>
</Directory>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
if [ -f "${CREDS_FILE}" ]; then
. ${CREDS_FILE}
# Need to disable GTID restores to backup/restore a remote RDS MySQL DB with default args
MYSQL_ARGS="-u ${BM_DB_ADMIN_USER} -p${BM_DB_ADMIN_PW} -h <%= database_fqdn %> --set-gtid-purged=OFF"
MYSQL_ARGS="-u ${BM_DB_ADMIN_USER} -p${BM_DB_ADMIN_PW} -h <%= @database_fqdn %> --set-gtid-purged=OFF"
else
MYSQL_ARGS="-u root"
fi
Expand Down
28 changes: 14 additions & 14 deletions deploy/vagrant/modules/buttonmen/templates/create_databases.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#!/bin/sh

mysqlshow -u root <%= buttonmen_db1_name %> | grep -q "^Database: buttonmen"
mysqlshow -u root <%= @buttonmen_db1_name %> | grep -q "^Database: buttonmen"
if [ "$?" = "0" ]; then
echo "<%= buttonmen_db1_name %> already exists"
echo "<%= @buttonmen_db1_name %> already exists"
else
echo "Creating <%= buttonmen_db1_name %>"
echo "CREATE DATABASE <%= buttonmen_db1_name %>" | mysql -u root
echo "GRANT ALL ON <%= buttonmen_db1_name %>.* TO <%= buttonmen_db1_user %>@localhost IDENTIFIED BY '<%= buttonmen_db1_pass %>'" | mysql -u root
echo "Creating <%= @buttonmen_db1_name %>"
echo "CREATE DATABASE <%= @buttonmen_db1_name %>" | mysql -u root
echo "GRANT ALL ON <%= @buttonmen_db1_name %>.* TO <%= @buttonmen_db1_user %>@localhost IDENTIFIED BY '<%= @buttonmen_db1_pass %>'" | mysql -u root

echo "Populating <%= buttonmen_db1_name %>"
echo "Populating <%= @buttonmen_db1_name %>"
cd /buttonmen/deploy/database
mysql -u root <%= buttonmen_db1_name %> < initialize_all.sql
mysql -u root <%= @buttonmen_db1_name %> < initialize_all.sql
fi

mysqlshow -u root <%= buttonmen_db2_name %> | grep -q "^Database: buttonmen_test"
mysqlshow -u root <%= @buttonmen_db2_name %> | grep -q "^Database: buttonmen_test"
if [ "$?" = "0" ]; then
echo "<%= buttonmen_db2_name %> already exists - recreating it"
echo "<%= @buttonmen_db2_name %> already exists - recreating it"
echo "DROP DATABASE buttonmen_test" | mysql -u root
fi
echo "Creating <%= buttonmen_db2_name %>"
echo "CREATE DATABASE <%= buttonmen_db2_name %>" | mysql -u root
echo "GRANT ALL ON <%= buttonmen_db2_name %>.* TO <%= buttonmen_db2_user %>@localhost IDENTIFIED BY '<%= buttonmen_db2_pass %>'" | mysql -u root
echo "Populating <%= buttonmen_db2_name %>"
echo "Creating <%= @buttonmen_db2_name %>"
echo "CREATE DATABASE <%= @buttonmen_db2_name %>" | mysql -u root
echo "GRANT ALL ON <%= @buttonmen_db2_name %>.* TO <%= @buttonmen_db2_user %>@localhost IDENTIFIED BY '<%= @buttonmen_db2_pass %>'" | mysql -u root
echo "Populating <%= @buttonmen_db2_name %>"
cd /buttonmen/deploy/database
mysql -u <%= buttonmen_db2_user%> -p<%= buttonmen_db2_pass %> <%= buttonmen_db2_name %> < initialize_all.sql
mysql -u <%= @buttonmen_db2_user%> -p<%= @buttonmen_db2_pass %> <%= @buttonmen_db2_name %> < initialize_all.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ if [ ! -f ${CREDS_FILE} ]; then
fi
. ${CREDS_FILE}

MYSQL_ARGS="-u ${BM_DB_ADMIN_USER} -p${BM_DB_ADMIN_PW} -h <%= database_fqdn %>"
MYSQL_ARGS="-u ${BM_DB_ADMIN_USER} -p${BM_DB_ADMIN_PW} -h <%= @database_fqdn %>"

mysqlshow ${MYSQL_ARGS} <%= buttonmen_db1_name %> | grep -q "^Database: buttonmen"
mysqlshow ${MYSQL_ARGS} <%= @buttonmen_db1_name %> | grep -q "^Database: buttonmen"
if [ "$?" = "0" ]; then
echo "<%= buttonmen_db1_name %> already exists"
echo "<%= @buttonmen_db1_name %> already exists"
else
echo "Creating <%= buttonmen_db1_name %>"
echo "CREATE DATABASE <%= buttonmen_db1_name %>" | mysql ${MYSQL_ARGS}
echo "GRANT ALL ON <%= buttonmen_db1_name %>.* TO <%= buttonmen_db1_user %>@'<%= puppet_hostname %>' IDENTIFIED BY '<%= buttonmen_db1_pass %>'" | mysql ${MYSQL_ARGS}
echo "Creating <%= @buttonmen_db1_name %>"
echo "CREATE DATABASE <%= @buttonmen_db1_name %>" | mysql ${MYSQL_ARGS}
echo "GRANT ALL ON <%= @buttonmen_db1_name %>.* TO <%= @buttonmen_db1_user %>@'<%= @puppet_hostname %>' IDENTIFIED BY '<%= @buttonmen_db1_pass %>'" | mysql ${MYSQL_ARGS}

echo "Populating <%= buttonmen_db1_name %>"
echo "Populating <%= @buttonmen_db1_name %>"
cd /buttonmen/deploy/database
mysql ${MYSQL_ARGS} <%= buttonmen_db1_name %> < initialize_all.sql
mysql ${MYSQL_ARGS} <%= @buttonmen_db1_name %> < initialize_all.sql
fi
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh

mysqlshow -u root <%= buttonmen_db2_name %> | grep -q "^Database: buttonmen_test"
mysqlshow -u root <%= @buttonmen_db2_name %> | grep -q "^Database: buttonmen_test"
if [ "$?" = "0" ]; then
echo "<%= buttonmen_db2_name %> already exists - recreating it"
echo "<%= @buttonmen_db2_name %> already exists - recreating it"
echo "DROP DATABASE buttonmen_test" | mysql -u root
fi
echo "Creating <%= buttonmen_db2_name %>"
echo "CREATE DATABASE <%= buttonmen_db2_name %>" | mysql -u root
echo "GRANT ALL ON <%= buttonmen_db2_name %>.* TO <%= buttonmen_db2_user %>@localhost IDENTIFIED BY '<%= buttonmen_db2_pass %>'" | mysql -u root
echo "Populating <%= buttonmen_db2_name %>"
echo "Creating <%= @buttonmen_db2_name %>"
echo "CREATE DATABASE <%= @buttonmen_db2_name %>" | mysql -u root
echo "GRANT ALL ON <%= @buttonmen_db2_name %>.* TO <%= @buttonmen_db2_user %>@localhost IDENTIFIED BY '<%= @buttonmen_db2_pass %>'" | mysql -u root
echo "Populating <%= @buttonmen_db2_name %>"
cd deploy/database
mysql -u <%= buttonmen_db2_user%> -p<%= buttonmen_db2_pass %> <%= buttonmen_db2_name %> < initialize_all.sql
mysql -u <%= @buttonmen_db2_user%> -p<%= @buttonmen_db2_pass %> <%= @buttonmen_db2_name %> < initialize_all.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DBNAME=buttonmen
# database, and in particular an admin password
if [ -f "${CREDS_FILE}" ]; then
. ${CREDS_FILE}
MYSQL_ARGS="-u ${BM_DB_ADMIN_USER} -p${BM_DB_ADMIN_PW} -h <%= database_fqdn %>"
MYSQL_ARGS="-u ${BM_DB_ADMIN_USER} -p${BM_DB_ADMIN_PW} -h <%= @database_fqdn %>"
else
MYSQL_ARGS="-u root"
fi
Expand Down
2 changes: 1 addition & 1 deletion deploy/vagrant/modules/buttonmen/templates/test_config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CONFIGFILE=/var/www/ui/js/Config.js
# database, and in particular an admin password
if [ -f "${CREDS_FILE}" ]; then
. ${CREDS_FILE}
MYSQL_ARGS="-u ${BM_DB_ADMIN_USER} -p${BM_DB_ADMIN_PW} -h <%= database_fqdn %> --set-gtid-purged=OFF"
MYSQL_ARGS="-u ${BM_DB_ADMIN_USER} -p${BM_DB_ADMIN_PW} -h <%= @database_fqdn %> --set-gtid-purged=OFF"
else
MYSQL_ARGS="-u root"
fi
Expand Down
2 changes: 1 addition & 1 deletion deploy/vagrant/modules/cloudwatch/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"/usr/local/bin/record_buttonmen_cloudwatch_metrics":
ensure => file,
content => template("cloudwatch/record_buttonmen_metrics.erb"),
mode => 0555;
mode => "0555";
}

# Record cloudwatch metrics from apache logs every five minutes
Expand Down
2 changes: 1 addition & 1 deletion deploy/vagrant/modules/fqdn/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"/usr/local/bin/fqdn_from_ec2_tags":
ensure => file,
content => template("fqdn/from_ec2_tags.erb"),
mode => 555;
mode => "0555";
}

# Use fqdn_from_ec2_tags to populate or update a site file
Expand Down
30 changes: 15 additions & 15 deletions deploy/vagrant/modules/php/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

# Make sure php7 and libapache2-mod-php are installed
package {
"php": ensure => installed;
"php7.4": ensure => installed;
"libapache2-mod-php": ensure => installed;
"php7.0-mbstring": ensure => installed;
"php7.4-mbstring": ensure => installed;
}

file {
"/etc/php/7.0/apache2/conf.d/buttonmen.ini":
"/etc/php/7.4/apache2/conf.d/buttonmen.ini":
ensure => file,
content => template("php/buttonmen.ini.erb"),
notify => Service["apache2"],
require => Package["libapache2-mod-php"];

"/etc/php/7.0/deploy-includes":
"/etc/php/7.4/deploy-includes":
ensure => directory,
require => Package["libapache2-mod-php"];
}
Expand Down Expand Up @@ -46,32 +46,32 @@
unless => "/usr/bin/pear config-get auto_discover | /bin/grep -q 1";

"php_wget_install_phpmd":
command => "/usr/bin/wget --no-verbose -O /etc/php/7.0/deploy-includes/phpmd.phar http://static.phpmd.org/php/latest/phpmd.phar",
creates => "/etc/php/7.0/deploy-includes/phpmd.phar",
require => File["/etc/php/7.0/deploy-includes"];
command => "/usr/bin/wget --no-verbose -O /etc/php/7.4/deploy-includes/phpmd.phar https://phpmd.org/static/latest/phpmd.phar",
creates => "/etc/php/7.4/deploy-includes/phpmd.phar",
require => File["/etc/php/7.4/deploy-includes"];

"php_wget_install_phpcpd":
command => "/usr/bin/wget --no-verbose -O /etc/php/7.0/deploy-includes/phpcpd.phar https://phar.phpunit.de/phpcpd.phar",
creates => "/etc/php/7.0/deploy-includes/phpcpd.phar",
require => File["/etc/php/7.0/deploy-includes"];
command => "/usr/bin/wget --no-verbose -O /etc/php/7.4/deploy-includes/phpcpd.phar https://phar.phpunit.de/phpcpd.phar",
creates => "/etc/php/7.4/deploy-includes/phpcpd.phar",
require => File["/etc/php/7.4/deploy-includes"];

"php_wget_install_phpcb":
command => "/usr/bin/wget --no-verbose -O /etc/php/7.0/deploy-includes/phpcb.phar https://github.com/bytepark/php-phar-qatools/blob/master/phpcb.phar",
creates => "/etc/php/7.0/deploy-includes/phpcb.phar",
require => File["/etc/php/7.0/deploy-includes"];
command => "/usr/bin/wget --no-verbose -O /etc/php/7.4/deploy-includes/phpcb.phar https://github.com/bytepark/php-phar-qatools/blob/master/phpcb.phar",
creates => "/etc/php/7.4/deploy-includes/phpcb.phar",
require => File["/etc/php/7.4/deploy-includes"];

"php_pear_discover_phpdoc":
command => "/usr/bin/pear channel-discover pear.phpdoc.org",
require => Exec["php_pear_set_auto_discover"],
unless => "/usr/bin/pear list-channels | /bin/grep pear.phpdoc.org";

"php_pear_install_phpcs":
command => "/usr/bin/wget --no-verbose -O /etc/php/7.0/deploy-includes/phpcs.phar https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar",
command => "/usr/bin/wget --no-verbose -O /etc/php/7.4/deploy-includes/phpcs.phar https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar",
require => Exec["php_pear_set_auto_discover"],
creates => "/usr/bin/phpcs";

"php_pear_install_phpdocumenter":
command => "/usr/bin/pear install phpdoc/phpDocumentor-2.7.0",
command => "/usr/bin/pear install phpdoc/phpDocumentor-2.7.4",
require => Exec["php_pear_discover_phpdoc"],
creates => "/usr/share/php/phpDocumentor";
}
Expand Down
6 changes: 3 additions & 3 deletions deploy/vagrant/modules/postfix/templates/main.cf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = <%= puppet_hostname %>
myhostname = <%= @puppet_hostname %>
mydomain = buttonweavers.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = <%= puppet_hostname %>
myorigin = <%= @puppet_hostname %>
masquerade_domains = $mydomain
mydestination = <%= puppet_hostname %>, localhost.buttonweavers.com, localhost
mydestination = <%= @puppet_hostname %>, localhost.buttonweavers.com, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
Expand Down
Loading