From 5d681709bd56a44051330a2764a511eff7469f49 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Tue, 29 Sep 2020 18:29:31 +0200 Subject: [PATCH 01/37] make it so wp initial build take the RDS host into account --- util/mysqlpreparenoimport_wp.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/util/mysqlpreparenoimport_wp.sh b/util/mysqlpreparenoimport_wp.sh index f57dcdcc..917e1b6f 100755 --- a/util/mysqlpreparenoimport_wp.sh +++ b/util/mysqlpreparenoimport_wp.sh @@ -9,6 +9,7 @@ myFile='/etc/mysql/debian.cnf' myUser=`grep user $myFile | awk '{print $3}' | uniq` myPass=`grep password $myFile | awk '{print $3}' | uniq` +myHost=`grep host $myFile | awk '{print $3}' | uniq` # Args that must be passed @@ -47,7 +48,7 @@ fi ORIGDB=$NEWDB while [ $COUNTER -lt 99 ]; do - DB=`mysql -u$myUser -p$myPass -Bse 'show databases'| egrep "^${NEWDB}$"` + DB=`mysql -u$myUser -p$myPass -h$myHost -Bse 'show databases'| egrep "^${NEWDB}$"` if [ "$DB" = "$NEWDB" ]; then echo "The database $NEWDB already exists" let COUNTER=COUNTER+1 @@ -55,14 +56,14 @@ while [ $COUNTER -lt 99 ]; do continue else echo "Creating a database for $NEWDB" - mysqladmin -u$myUser -p$myPass create $NEWDB || exit 1 + mysqladmin -u$myUser -p$myPass -h$myHost create $NEWDB || exit 1 echo "Generating a user/pass for database $NEWDB" - mysql -u$myUser -p$myPass -e "GRANT ALL ON \`$NEWDB\`.* to '$NEWDB'@'localhost' IDENTIFIED BY '$PASS'" || exit 1 + mysql -u$myUser -p$myPass -h$myHost -e "GRANT ALL ON \`$NEWDB\`.* to '$NEWDB'@'localhost' IDENTIFIED BY '$PASS'" || exit 1 break fi done -DB=`mysql -u$myUser -p$myPass -Bse 'show databases'| egrep "^${NEWDB}$"` +DB=`mysql -u$myUser -p$myPass -h$myHost -Bse 'show databases'| egrep "^${NEWDB}$"` # Only do any importing if the database exists ( we should have failed above if [ $? -eq 0 ]; then ######################################################################### @@ -83,7 +84,7 @@ if [ $? -eq 0 ]; then # ######################################################################### - wp --path=$SITE_ROOT --allow-root core config --dbname=$NEWDB --dbuser=$NEWDB --dbpass=$PASS + wp --path=$SITE_ROOT --allow-root core config --dbname=$NEWDB --dbuser=$NEWDB --dbpass=$PASS --dbhost=$myHost wp --path=$SITE_ROOT --allow-root core install --url=$URL --title=$NEWDB --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=$PASS else echo "Something went wrong and we couldn't import a database or populate wp-config.php. Maybe we couldn't create the database?" From 9e8692dab9da695ad37f918da7e97da21d72da21 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Tue, 29 Sep 2020 18:36:46 +0200 Subject: [PATCH 02/37] missed the user creation using localhost --- util/mysqlpreparenoimport_wp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/mysqlpreparenoimport_wp.sh b/util/mysqlpreparenoimport_wp.sh index 917e1b6f..3ac32edb 100755 --- a/util/mysqlpreparenoimport_wp.sh +++ b/util/mysqlpreparenoimport_wp.sh @@ -58,7 +58,7 @@ while [ $COUNTER -lt 99 ]; do echo "Creating a database for $NEWDB" mysqladmin -u$myUser -p$myPass -h$myHost create $NEWDB || exit 1 echo "Generating a user/pass for database $NEWDB" - mysql -u$myUser -p$myPass -h$myHost -e "GRANT ALL ON \`$NEWDB\`.* to '$NEWDB'@'localhost' IDENTIFIED BY '$PASS'" || exit 1 + mysql -u$myUser -p$myPass -h$myHost -e "GRANT ALL ON \`$NEWDB\`.* to '$NEWDB'@'$myHost' IDENTIFIED BY '$PASS'" || exit 1 break fi done From 8ed3439be3a0b6cfc88d801978191d62b004148d Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 11:37:40 +0200 Subject: [PATCH 03/37] refactoring --- wordpress/InitialBuild.py | 61 ++++++++++++++++++++------------------- wordpress/fabfile.py | 5 ++-- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 27b4dc38..15c0e158 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -9,7 +9,7 @@ # Stuff to do when this is the initial build @task -def initial_build(repo, url, branch, build, profile, webserverport): +def initial_build(repo, url, branch, build, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster=False, autoscale=False, rds=False): print "===> This looks like the first build! We have some things to do.." print "===> Setting the live document root symlink" @@ -23,38 +23,41 @@ def initial_build(repo, url, branch, build, profile, webserverport): print "===> Preparing the database" # this process creates a database, database user/pass, imports the db dump from the repo # and generates the wp-config.php database file. - newpass = common.Utils._gen_passwd() - # Check if a db/ directory exists first. - db_dir = False - with settings(warn_only=True): - if run("find /var/www/%s_%s_%s -maxdepth 1 -type d -name db | egrep '.*'" % (repo, branch, build)).return_code == 0: - db_dir = True - - if db_dir: - sudo("bunzip2 /var/www/%s_%s_%s/db/*.sql.bz2" % (repo, branch, build)) - # Copying the database script to the server. - script_dir = os.path.dirname(os.path.realpath(__file__)) - if put(script_dir + '/../util/mysqlprepare_wp.sh', '/home/jenkins', mode=0755).failed: - raise SystemExit("Could not copy the database script to the application server, aborting because we won't be able to make a database") - else: - print "===> Database preparation script mysqlprepare_wp.sh copied to %s:/home/jenkins/mysqlprepare_wp.sh" % (env.host) - # Note, Wordpress version of script, mysqlprepare_wp.sh - sudo("/home/jenkins/mysqlprepare_wp.sh %s %s /var/www/live.%s.%s %s $(find /var/www/%s_%s_%s/db -type f -name *.sql)" % (repo, newpass, repo, branch, branch, repo, branch, build)) - else: - sitedir = "/var/www/%s_%s_%s/www" % (repo, branch, build) - # Copying the database script to the server. - script_dir = os.path.dirname(os.path.realpath(__file__)) - if put(script_dir + '/../util/mysqlpreparenoimport_wp.sh', '/home/jenkins', mode=0755).failed: - raise SystemExit("Could not copy the database script to the application server, aborting because we won't be able to make a database") - else: - print "===> Database preparation script mysqlpreparenoimport_wp.sh copied to %s:/home/jenkins/mysqlpreparenoimport_wp.sh" % (env.host) - sudo("/home/jenkins/mysqlpreparenoimport_wp.sh %s %s %s %s %s %s" % (repo, newpass, sitedir, branch, profile, url)) + # We can default these to None, mysql_new_database() will sort itself out + list_of_app_servers = None + db_host = None + + # For clusters we need to do some extra things + if cluster or autoscale: + # This is the Database host that we need to insert into Drupal settings.php. It is different from the main db host because it might be a floating IP + db_host = config.get('WPDBHost', 'dbhost') + # Convert a list of apps back into a string, to pass to the MySQL new database function for setting appropriate GRANTs to the database + list_of_app_servers = env.roledefs['app_all'] + + if cluster and config.has_section('AppIPs'): + list_of_app_servers = env.roledefs['app_ip_all'] + + # Prepare the database + # We'll get back db_name, db_username, db_password and db_host from this call as a list in new_database + new_database = common.MySQL.mysql_new_database(alias, buildtype, rds, db_name, db_host, db_username, mysql_version, db_password, mysql_config, list_of_app_servers) + + print "===> Waiting 10 seconds to let MySQL internals catch up" + time.sleep(10) + + # Copy wp-config.php into place + if run("stat /var/www/live.%s.%s/wp-config.php.%s" % (repo, branch, branch)).return_code == 0: + sudo("cp /var/www/live.%s.%s/wp-config.php.%s /var/www/live.%s.%s/wp-config.php" % (repo, branch, branch, repo, branch) + else + print "No wp-config.php.%s file, continuing..." % branch + fi - webserver = "nginx" + # wp-cli site install. + sudo("wp --path=/var/www/live.%s.%s --allow-root core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s" % (repo, branch, new_database[0], new_database[1], new_database[2], new_database[3])) + sudo("wp --path=/var/www/live.%s.%s --allow-root core install --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (repo, branch, new_database[0], new_database[2]) print "===> Setting up an %s vhost" % webserver - # Copy Nginx vhost to server(s) + # Copy vhost to server(s) print "===> Placing new copies of dummy vhosts for %s before proceeding" % webserver script_dir = os.path.dirname(os.path.realpath(__file__)) if put(script_dir + '/../util/vhosts/%s/wp-*' % webserver, '/etc/%s/sites-available' % webserver, mode=0755, use_sudo=True).failed: diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 49cf8175..375816fa 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -30,7 +30,7 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserverport='8080', php_ini_file=None): +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserverport='8080', php_ini_file=None, cluster=False, autoscale=False, rds=False)): # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): @@ -86,7 +86,8 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi print "===> Looks like the site %s doesn't exist. We'll try and install it..." % url try: common.Utils.clone_repo(repo, repourl, branch, build, None, ssh_key) - InitialBuild.initial_build(repo, url, branch, build, profile, webserverport) + InitialBuild.initial_build(repo, url, branch, build, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster=False, autoscale=False, rds=False): + # Unset CLI PHP version if we need to if php_ini_file: run("export PHPRC=''") From c7ef1c7359a045670a2f54a468b7400085a40fcf Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 11:42:04 +0200 Subject: [PATCH 04/37] typo --- wordpress/fabfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 375816fa..3bf81624 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -30,7 +30,7 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserverport='8080', php_ini_file=None, cluster=False, autoscale=False, rds=False)): +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserverport='8080', php_ini_file=None, cluster=False, autoscale=False, rds=False): # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): From 500d870b7c48c1286bb84d1380d84144788974e1 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 11:49:00 +0200 Subject: [PATCH 05/37] fixing arg error --- wordpress/fabfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 3bf81624..287b3967 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -86,7 +86,7 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi print "===> Looks like the site %s doesn't exist. We'll try and install it..." % url try: common.Utils.clone_repo(repo, repourl, branch, build, None, ssh_key) - InitialBuild.initial_build(repo, url, branch, build, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster=False, autoscale=False, rds=False): + InitialBuild.initial_build(repo, url, branch, build, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster, autoscale, rds): # Unset CLI PHP version if we need to if php_ini_file: From e402d1e36cea8ea892a6fe968afd7dcbdb79bc26 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 11:50:15 +0200 Subject: [PATCH 06/37] wild semi-colon --- wordpress/fabfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 287b3967..059d5017 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -86,7 +86,7 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi print "===> Looks like the site %s doesn't exist. We'll try and install it..." % url try: common.Utils.clone_repo(repo, repourl, branch, build, None, ssh_key) - InitialBuild.initial_build(repo, url, branch, build, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster, autoscale, rds): + InitialBuild.initial_build(repo, url, branch, build, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster, autoscale, rds) # Unset CLI PHP version if we need to if php_ini_file: From a4acb079145e97a0c79decf694138f4100e626a3 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 11:51:49 +0200 Subject: [PATCH 07/37] fixing else condition on wp-config.php --- wordpress/InitialBuild.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 15c0e158..fbc8b408 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -48,9 +48,9 @@ def initial_build(repo, url, branch, build, profile, webserver, webserverport, c # Copy wp-config.php into place if run("stat /var/www/live.%s.%s/wp-config.php.%s" % (repo, branch, branch)).return_code == 0: sudo("cp /var/www/live.%s.%s/wp-config.php.%s /var/www/live.%s.%s/wp-config.php" % (repo, branch, branch, repo, branch) - else + else: print "No wp-config.php.%s file, continuing..." % branch - fi + # wp-cli site install. sudo("wp --path=/var/www/live.%s.%s --allow-root core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s" % (repo, branch, new_database[0], new_database[1], new_database[2], new_database[3])) From e137b07a640625bc880b91c3921d97e36b6f6024 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 11:53:11 +0200 Subject: [PATCH 08/37] one more time --- wordpress/InitialBuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index fbc8b408..aa0d7a65 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -47,7 +47,7 @@ def initial_build(repo, url, branch, build, profile, webserver, webserverport, c # Copy wp-config.php into place if run("stat /var/www/live.%s.%s/wp-config.php.%s" % (repo, branch, branch)).return_code == 0: - sudo("cp /var/www/live.%s.%s/wp-config.php.%s /var/www/live.%s.%s/wp-config.php" % (repo, branch, branch, repo, branch) + sudo("cp /var/www/live.%s.%s/wp-config.php.%s /var/www/live.%s.%s/wp-config.php" % (repo, branch, branch, repo, branch) else: print "No wp-config.php.%s file, continuing..." % branch From c33bf4164b0a9c7de14ecbd60b98310c9ab830dd Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 12:00:06 +0200 Subject: [PATCH 09/37] parenthese --- wordpress/InitialBuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index aa0d7a65..6a984c0a 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -47,7 +47,7 @@ def initial_build(repo, url, branch, build, profile, webserver, webserverport, c # Copy wp-config.php into place if run("stat /var/www/live.%s.%s/wp-config.php.%s" % (repo, branch, branch)).return_code == 0: - sudo("cp /var/www/live.%s.%s/wp-config.php.%s /var/www/live.%s.%s/wp-config.php" % (repo, branch, branch, repo, branch) + sudo("cp /var/www/live.%s.%s/wp-config.php.%s /var/www/live.%s.%s/wp-config.php" % (repo, branch, branch, repo, branch)) else: print "No wp-config.php.%s file, continuing..." % branch From 30128222bf19b4262ac28bdab8e9dd78efaaee0d Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 12:01:50 +0200 Subject: [PATCH 10/37] again --- wordpress/InitialBuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 6a984c0a..2fa913ed 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -54,7 +54,7 @@ def initial_build(repo, url, branch, build, profile, webserver, webserverport, c # wp-cli site install. sudo("wp --path=/var/www/live.%s.%s --allow-root core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s" % (repo, branch, new_database[0], new_database[1], new_database[2], new_database[3])) - sudo("wp --path=/var/www/live.%s.%s --allow-root core install --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (repo, branch, new_database[0], new_database[2]) + sudo("wp --path=/var/www/live.%s.%s --allow-root core install --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (repo, branch, new_database[0], new_database[2])) print "===> Setting up an %s vhost" % webserver # Copy vhost to server(s) From c835f5880c64019667ce79f7ebd2dc34a98eff91 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 14:48:44 +0200 Subject: [PATCH 11/37] add default webserver --- wordpress/fabfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 059d5017..823f8d5e 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -30,7 +30,7 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserverport='8080', php_ini_file=None, cluster=False, autoscale=False, rds=False): +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, cluster=False, autoscale=False, rds=False): # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): From 082936d1c667b5f03722e4933fc8fa8d385b75c8 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 15:18:34 +0200 Subject: [PATCH 12/37] missing var --- wordpress/fabfile.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 823f8d5e..30adff4a 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -30,7 +30,7 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, cluster=False, autoscale=False, rds=False): +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, cluster=False, autoscale=None, rds=False): # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): @@ -56,9 +56,12 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi # Can be set in the config.ini [Build] section ssh_key = common.ConfigFile.return_config_item(config, "Build", "ssh_key") notifications_email = common.ConfigFile.return_config_item(config, "Build", "notifications_email") + php_ini_file = common.ConfigFile.return_config_item(config, "Build", "php_ini_file", "string", php_ini_file) + db_name = common.ConfigFile.return_config_item(config, "Database", "db_name") + db_username = common.ConfigFile.return_config_item(config, "Database", "db_username") + db_password = common.ConfigFile.return_config_item(config, "Database", "db_password") # Need to keep potentially passed in 'url' value as default url = common.ConfigFile.return_config_item(config, "Build", "url", "string", url) - php_ini_file = common.ConfigFile.return_config_item(config, "Build", "php_ini_file", "string", php_ini_file) # Set a URL if one wasn't already provided if url is None: From 2d26efe9011a29ae4fdbb0946b05ea6f24074602 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 15:26:46 +0200 Subject: [PATCH 13/37] import mysql --- wordpress/InitialBuild.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 2fa913ed..17afe0ce 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -4,6 +4,7 @@ import string # Custom Code Enigma modules import common.Utils +import common.MySQL # Needed to get variables set in modules back into the main script from common.Utils import * From 5b208eaed6044ea25d39ca2d71fa7727a445f17e Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 15:51:43 +0200 Subject: [PATCH 14/37] replace alias by repo --- wordpress/InitialBuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 17afe0ce..d1fc8316 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -41,7 +41,7 @@ def initial_build(repo, url, branch, build, profile, webserver, webserverport, c # Prepare the database # We'll get back db_name, db_username, db_password and db_host from this call as a list in new_database - new_database = common.MySQL.mysql_new_database(alias, buildtype, rds, db_name, db_host, db_username, mysql_version, db_password, mysql_config, list_of_app_servers) + new_database = common.MySQL.mysql_new_database(repo, buildtype, rds, db_name, db_host, db_username, mysql_version, db_password, mysql_config, list_of_app_servers) print "===> Waiting 10 seconds to let MySQL internals catch up" time.sleep(10) From 8952f110560578648921898a8fd129896cac5343 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 16:06:05 +0200 Subject: [PATCH 15/37] more fixes --- wordpress/InitialBuild.py | 4 ++-- wordpress/fabfile.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index d1fc8316..de207613 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -10,7 +10,7 @@ # Stuff to do when this is the initial build @task -def initial_build(repo, url, branch, build, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster=False, autoscale=False, rds=False): +def initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster=False, autoscale=False, rds=False): print "===> This looks like the first build! We have some things to do.." print "===> Setting the live document root symlink" @@ -41,7 +41,7 @@ def initial_build(repo, url, branch, build, profile, webserver, webserverport, c # Prepare the database # We'll get back db_name, db_username, db_password and db_host from this call as a list in new_database - new_database = common.MySQL.mysql_new_database(repo, buildtype, rds, db_name, db_host, db_username, mysql_version, db_password, mysql_config, list_of_app_servers) + new_database = common.MySQL.mysql_new_database(repo, buildtype, rds, db_name, db_host, db_username, db_password, list_of_app_servers) print "===> Waiting 10 seconds to let MySQL internals catch up" time.sleep(10) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 30adff4a..4a8f41f1 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -89,7 +89,7 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi print "===> Looks like the site %s doesn't exist. We'll try and install it..." % url try: common.Utils.clone_repo(repo, repourl, branch, build, None, ssh_key) - InitialBuild.initial_build(repo, url, branch, build, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster, autoscale, rds) + InitialBuild.initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster, autoscale, rds) # Unset CLI PHP version if we need to if php_ini_file: From 8bd209c8d160546b9c3810b7ba8e7c6779b87dfa Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 16:18:02 +0200 Subject: [PATCH 16/37] fix version --- wordpress/InitialBuild.py | 4 ++-- wordpress/fabfile.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index de207613..01c09597 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -10,7 +10,7 @@ # Stuff to do when this is the initial build @task -def initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster=False, autoscale=False, rds=False): +def initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, cluster=False, autoscale=False, rds=False): print "===> This looks like the first build! We have some things to do.." print "===> Setting the live document root symlink" @@ -41,7 +41,7 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse # Prepare the database # We'll get back db_name, db_username, db_password and db_host from this call as a list in new_database - new_database = common.MySQL.mysql_new_database(repo, buildtype, rds, db_name, db_host, db_username, db_password, list_of_app_servers) + new_database = common.MySQL.mysql_new_database(repo, buildtype, rds, db_name, db_host, db_username, mysql_version, db_password, list_of_app_servers) print "===> Waiting 10 seconds to let MySQL internals catch up" time.sleep(10) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 4a8f41f1..5475c8fd 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -63,6 +63,10 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi # Need to keep potentially passed in 'url' value as default url = common.ConfigFile.return_config_item(config, "Build", "url", "string", url) + # Need to keep potentially passed in MySQL version and config path as defaults + mysql_config = common.ConfigFile.return_config_item(config, "Database", "mysql_config", "string", mysql_config) + mysql_version = common.ConfigFile.return_config_item(config, "Database", "mysql_version", "string", mysql_version) + # Set a URL if one wasn't already provided if url is None: url = "%s-%s.codeenigma.net" % (repo, branch) From ae4991cf8bd196e815316ddb78818f933fa6eb6a Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 16:21:00 +0200 Subject: [PATCH 17/37] bug --- wordpress/fabfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 5475c8fd..950260c7 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -64,7 +64,6 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi url = common.ConfigFile.return_config_item(config, "Build", "url", "string", url) # Need to keep potentially passed in MySQL version and config path as defaults - mysql_config = common.ConfigFile.return_config_item(config, "Database", "mysql_config", "string", mysql_config) mysql_version = common.ConfigFile.return_config_item(config, "Database", "mysql_version", "string", mysql_version) # Set a URL if one wasn't already provided From b503cfdce8de59b42af4e0683f2441b49309766e Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 16:22:21 +0200 Subject: [PATCH 18/37] assign --- wordpress/fabfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 950260c7..5a4a4dc6 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -30,7 +30,7 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, cluster=False, autoscale=None, rds=False): +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, cluster=False, autoscale=None, rds=False): # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): From 86b4dadda51f56489f9c03977d92cfd4bc7dc0d6 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 16:24:54 +0200 Subject: [PATCH 19/37] debug --- wordpress/InitialBuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 01c09597..665b26d1 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -28,7 +28,7 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse # We can default these to None, mysql_new_database() will sort itself out list_of_app_servers = None db_host = None - + print "cluster is: %s" % cluster # For clusters we need to do some extra things if cluster or autoscale: # This is the Database host that we need to insert into Drupal settings.php. It is different from the main db host because it might be a floating IP From ae8eb9538f8d067ed70d6060c1abdb649f9048d7 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 16:30:11 +0200 Subject: [PATCH 20/37] missing arg --- wordpress/fabfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 5a4a4dc6..0e9a16ce 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -92,7 +92,7 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi print "===> Looks like the site %s doesn't exist. We'll try and install it..." % url try: common.Utils.clone_repo(repo, repourl, branch, build, None, ssh_key) - InitialBuild.initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, cluster, autoscale, rds) + InitialBuild.initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, cluster, autoscale, rds) # Unset CLI PHP version if we need to if php_ini_file: From 4f58c1ca3c79340612c4b539da99d4f0c99927a4 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 16:41:41 +0200 Subject: [PATCH 21/37] moar --- wordpress/InitialBuild.py | 6 +++--- wordpress/fabfile.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 665b26d1..196b87b8 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -10,7 +10,7 @@ # Stuff to do when this is the initial build @task -def initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, cluster=False, autoscale=False, rds=False): +def initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, mysql_config, cluster=False, autoscale=False, rds=False): print "===> This looks like the first build! We have some things to do.." print "===> Setting the live document root symlink" @@ -31,7 +31,7 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse print "cluster is: %s" % cluster # For clusters we need to do some extra things if cluster or autoscale: - # This is the Database host that we need to insert into Drupal settings.php. It is different from the main db host because it might be a floating IP + # This is the Database host that we need to insert into wordpress config. It is different from the main db host because it might be a floating IP db_host = config.get('WPDBHost', 'dbhost') # Convert a list of apps back into a string, to pass to the MySQL new database function for setting appropriate GRANTs to the database list_of_app_servers = env.roledefs['app_all'] @@ -41,7 +41,7 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse # Prepare the database # We'll get back db_name, db_username, db_password and db_host from this call as a list in new_database - new_database = common.MySQL.mysql_new_database(repo, buildtype, rds, db_name, db_host, db_username, mysql_version, db_password, list_of_app_servers) + new_database = common.MySQL.mysql_new_database(repo, buildtype, rds, db_name, db_host, db_username, mysql_version, db_password, mysql_config, list_of_app_servers) print "===> Waiting 10 seconds to let MySQL internals catch up" time.sleep(10) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 0e9a16ce..45a275a4 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -30,7 +30,7 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, cluster=False, autoscale=None, rds=False): +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', cluster=False, autoscale=None, rds=False): # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): @@ -92,7 +92,7 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi print "===> Looks like the site %s doesn't exist. We'll try and install it..." % url try: common.Utils.clone_repo(repo, repourl, branch, build, None, ssh_key) - InitialBuild.initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, cluster, autoscale, rds) + InitialBuild.initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, mysql_config, cluster, autoscale, rds) # Unset CLI PHP version if we need to if php_ini_file: From 55a05ffb8ec9f781f4ba71966a851695963c9c18 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 5 Oct 2020 16:55:20 +0200 Subject: [PATCH 22/37] fix warn --- wordpress/InitialBuild.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 196b87b8..48de8745 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -47,10 +47,11 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse time.sleep(10) # Copy wp-config.php into place - if run("stat /var/www/live.%s.%s/wp-config.php.%s" % (repo, branch, branch)).return_code == 0: - sudo("cp /var/www/live.%s.%s/wp-config.php.%s /var/www/live.%s.%s/wp-config.php" % (repo, branch, branch, repo, branch)) - else: - print "No wp-config.php.%s file, continuing..." % branch + with settings(warn_only=True): + if run("stat /var/www/live.%s.%s/wp-config.php.%s" % (repo, branch, branch)).return_code == 0: + sudo("cp /var/www/live.%s.%s/wp-config.php.%s /var/www/live.%s.%s/wp-config.php" % (repo, branch, branch, repo, branch)) + else: + print "No wp-config.php.%s file, continuing..." % branch # wp-cli site install. From 7792e07b92c15d121ba655925b9addfdbbfa9625 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Fri, 9 Oct 2020 16:58:13 +0200 Subject: [PATCH 23/37] remove debug --- wordpress/InitialBuild.py | 1 - 1 file changed, 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 48de8745..d82697ff 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -28,7 +28,6 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse # We can default these to None, mysql_new_database() will sort itself out list_of_app_servers = None db_host = None - print "cluster is: %s" % cluster # For clusters we need to do some extra things if cluster or autoscale: # This is the Database host that we need to insert into wordpress config. It is different from the main db host because it might be a floating IP From 000ba16e11cc8234069b8d63a07ceb5c7dd2cb2b Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Wed, 30 Dec 2020 17:42:28 +0100 Subject: [PATCH 24/37] fix create db for wp clusters --- wordpress/InitialBuild.py | 3 ++- wordpress/fabfile.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index d82697ff..ae689b58 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -32,9 +32,10 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse if cluster or autoscale: # This is the Database host that we need to insert into wordpress config. It is different from the main db host because it might be a floating IP db_host = config.get('WPDBHost', 'dbhost') + print "db is %s" % (db_host) # Convert a list of apps back into a string, to pass to the MySQL new database function for setting appropriate GRANTs to the database list_of_app_servers = env.roledefs['app_all'] - + print "app list is %s" % (list_of_app_servers) if cluster and config.has_section('AppIPs'): list_of_app_servers = env.roledefs['app_ip_all'] diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 45a275a4..0bbedd0a 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -42,6 +42,9 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi env.host = entry.strip() print "===> Host is %s" % env.host break + aws_credentials = common.ConfigFile.return_config_item(config, "AWS", "aws_credentials", "string", "/home/jenkins/.aws/credentials") + aws_autoscale_group = common.ConfigFile.return_config_item(config, "AWS", "aws_autoscale_group", "string", "prod-asg-prod") + common.Utils.define_roles(config, cluster, autoscale, aws_credentials, aws_autoscale_group) # Didn't find any host in the map for this project. if env.host is None: From 9d7d3c4322f107a2669538cce291351d69b163c6 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Wed, 30 Dec 2020 18:55:05 +0100 Subject: [PATCH 25/37] enabling alternate install path --- wordpress/InitialBuild.py | 10 +++++++--- wordpress/fabfile.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index ae689b58..3e6e1c6e 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -10,7 +10,7 @@ # Stuff to do when this is the initial build @task -def initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, mysql_config, cluster=False, autoscale=False, rds=False): +def initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, mysql_config, cluster=False, autoscale=False, rds=False, install_type): print "===> This looks like the first build! We have some things to do.." print "===> Setting the live document root symlink" @@ -55,8 +55,12 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse # wp-cli site install. - sudo("wp --path=/var/www/live.%s.%s --allow-root core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s" % (repo, branch, new_database[0], new_database[1], new_database[2], new_database[3])) - sudo("wp --path=/var/www/live.%s.%s --allow-root core install --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (repo, branch, new_database[0], new_database[2])) + if install_type == "www": + install_path = "/var/www/live.%s.%s/www" % (repo, branch) + else: + install_path = "/var/www/live.%s.%s" % (repo, branch) + sudo("wp --path=%s --allow-root core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s" % (install_path, new_database[0], new_database[1], new_database[2], new_database[3])) + sudo("wp --path=%s --allow-root core install --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (install_path, new_database[0], new_database[2])) print "===> Setting up an %s vhost" % webserver # Copy vhost to server(s) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 0bbedd0a..afa2a945 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -30,7 +30,7 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', cluster=False, autoscale=None, rds=False): +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', cluster=False, autoscale=None, rds=False, install_type): # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): @@ -95,7 +95,7 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi print "===> Looks like the site %s doesn't exist. We'll try and install it..." % url try: common.Utils.clone_repo(repo, repourl, branch, build, None, ssh_key) - InitialBuild.initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, mysql_config, cluster, autoscale, rds) + InitialBuild.initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, mysql_config, cluster, autoscale, rds, install_type) # Unset CLI PHP version if we need to if php_ini_file: From ac113266d735c8c67ba980dcb01f3c0d97471de5 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Wed, 30 Dec 2020 19:12:01 +0100 Subject: [PATCH 26/37] tweak --- wordpress/InitialBuild.py | 2 +- wordpress/fabfile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 3e6e1c6e..de9de0b1 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -10,7 +10,7 @@ # Stuff to do when this is the initial build @task -def initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, mysql_config, cluster=False, autoscale=False, rds=False, install_type): +def initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, mysql_config, install_type, cluster=False, autoscale=False, rds=False): print "===> This looks like the first build! We have some things to do.." print "===> Setting the live document root symlink" diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index afa2a945..511a804d 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -95,7 +95,7 @@ def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profi print "===> Looks like the site %s doesn't exist. We'll try and install it..." % url try: common.Utils.clone_repo(repo, repourl, branch, build, None, ssh_key) - InitialBuild.initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, mysql_config, cluster, autoscale, rds, install_type) + InitialBuild.initial_build(repo, url, branch, build, buildtype, profile, webserver, webserverport, config, db_name, db_username, db_password, mysql_version, mysql_config, install_type, cluster, autoscale, rds) # Unset CLI PHP version if we need to if php_ini_file: From ab8693e325e1bbdb794009c2857294a60186c39d Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Wed, 30 Dec 2020 19:18:37 +0100 Subject: [PATCH 27/37] forgot a default value --- wordpress/fabfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 511a804d..f16ba13e 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -30,7 +30,7 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', cluster=False, autoscale=None, rds=False, install_type): +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', install_type='', cluster=False, autoscale=None, rds=False, install_type): # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): From 06f4625314a736a74e72722a2a6317e1f864ef22 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Wed, 30 Dec 2020 19:19:47 +0100 Subject: [PATCH 28/37] duh --- wordpress/fabfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index f16ba13e..bbab4f7e 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -30,7 +30,7 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', install_type='', cluster=False, autoscale=None, rds=False, install_type): +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', install_type='', cluster=False, autoscale=None, rds=False: # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): From eeba0db0f151d1c225733a3c7459850eada164e5 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Wed, 30 Dec 2020 19:20:38 +0100 Subject: [PATCH 29/37] duuh --- wordpress/fabfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index bbab4f7e..b01cf94e 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -30,7 +30,7 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', install_type='', cluster=False, autoscale=None, rds=False: +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', install_type='', cluster=False, autoscale=None, rds=False): # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): From f5a45b3d36ee41c48f8d111bfb65f2d10cd950da Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Thu, 31 Dec 2020 17:44:48 +0100 Subject: [PATCH 30/37] tweak buildtype config file --- wordpress/fabfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index b01cf94e..f6f126cc 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -23,7 +23,7 @@ env.shell = '/bin/bash -c' # Read the config.ini file from repo, if it exists -config = common.ConfigFile.read_config_file() +config = common.ConfigFile.buildtype_config_file(buildtype, config_filename, fullpath=config_fullpath) ###### From 453c5b6edb4856ae1781a700f258a2f74eb87bb7 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Thu, 31 Dec 2020 18:05:23 +0100 Subject: [PATCH 31/37] moving get config to main function --- wordpress/fabfile.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index f6f126cc..c4efde00 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -22,8 +22,7 @@ # pesky 'stdin is not a tty' messages when using sudo env.shell = '/bin/bash -c' -# Read the config.ini file from repo, if it exists -config = common.ConfigFile.buildtype_config_file(buildtype, config_filename, fullpath=config_fullpath) + ###### @@ -31,6 +30,10 @@ ##### @task def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', install_type='', cluster=False, autoscale=None, rds=False): + +# Read the config.ini file from repo, if it exists +config = common.ConfigFile.buildtype_config_file(buildtype, config_filename, fullpath=config_fullpath) + # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical if config.has_section(buildtype): From a95eed9dfae13d006d59c2bc7285f0636a1180ce Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Thu, 31 Dec 2020 18:06:38 +0100 Subject: [PATCH 32/37] indentation --- wordpress/fabfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index c4efde00..3d58dd9d 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -31,8 +31,8 @@ @task def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', install_type='', cluster=False, autoscale=None, rds=False): -# Read the config.ini file from repo, if it exists -config = common.ConfigFile.buildtype_config_file(buildtype, config_filename, fullpath=config_fullpath) + # Read the config.ini file from repo, if it exists + config = common.ConfigFile.buildtype_config_file(buildtype, config_filename, fullpath=config_fullpath) # We need to iterate through the options in the map and find the right host based on # whether the repo name matches any of the options, as they may not be exactly identical From 00b7e4dc6c40c722c7b94beb99ec26d9e29b75f9 Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Thu, 31 Dec 2020 18:09:01 +0100 Subject: [PATCH 33/37] adding config variable --- wordpress/fabfile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wordpress/fabfile.py b/wordpress/fabfile.py index 3d58dd9d..d1a2c409 100644 --- a/wordpress/fabfile.py +++ b/wordpress/fabfile.py @@ -29,7 +29,12 @@ # New 'main()' task which should replace the deployment.sh wrapper, and support repo -> host mapping ##### @task -def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', install_type='', cluster=False, autoscale=None, rds=False): +def main(repo, repourl, build, branch, buildtype, url=None, keepbuilds=20, profile="minimal", webserver='nginx', webserverport='8080', php_ini_file=None, mysql_version=5.5, mysql_config='/etc/mysql/debian.cnf', config_filename='config.ini', config_fullpath=False, install_type='', cluster=False, autoscale=None, rds=False): + + if config_fullpath == "False": + config_fullpath = False + if config_fullpath == "True": + config_fullpath = True # Read the config.ini file from repo, if it exists config = common.ConfigFile.buildtype_config_file(buildtype, config_filename, fullpath=config_fullpath) From d7569d821233c235d34551ed30f13f66480c22bb Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Thu, 31 Dec 2020 18:11:48 +0100 Subject: [PATCH 34/37] add url to initial build wp command --- wordpress/InitialBuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index de9de0b1..6fe8b084 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -60,7 +60,7 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse else: install_path = "/var/www/live.%s.%s" % (repo, branch) sudo("wp --path=%s --allow-root core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s" % (install_path, new_database[0], new_database[1], new_database[2], new_database[3])) - sudo("wp --path=%s --allow-root core install --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (install_path, new_database[0], new_database[2])) + sudo("wp --path=%s --allow-root core install --url %s --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (install_path, url, new_database[0], new_database[2])) print "===> Setting up an %s vhost" % webserver # Copy vhost to server(s) From e8dd0d06073103d7aa2d83967ead0b2423e6873a Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Thu, 31 Dec 2020 18:16:12 +0100 Subject: [PATCH 35/37] adding quotes to try and fix positional arg error --- wordpress/InitialBuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 6fe8b084..8fa9cb14 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -60,7 +60,7 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse else: install_path = "/var/www/live.%s.%s" % (repo, branch) sudo("wp --path=%s --allow-root core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s" % (install_path, new_database[0], new_database[1], new_database[2], new_database[3])) - sudo("wp --path=%s --allow-root core install --url %s --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (install_path, url, new_database[0], new_database[2])) + sudo("wp --path=%s --allow-root core install --url '%s' --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (install_path, url, new_database[0], new_database[2])) print "===> Setting up an %s vhost" % webserver # Copy vhost to server(s) From fb0cdeeeab20906a56285b08a77dfa405122c87e Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Thu, 31 Dec 2020 18:19:49 +0100 Subject: [PATCH 36/37] quotes tweak --- wordpress/InitialBuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 8fa9cb14..30a65a49 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -60,7 +60,7 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse else: install_path = "/var/www/live.%s.%s" % (repo, branch) sudo("wp --path=%s --allow-root core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s" % (install_path, new_database[0], new_database[1], new_database[2], new_database[3])) - sudo("wp --path=%s --allow-root core install --url '%s' --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (install_path, url, new_database[0], new_database[2])) + sudo("wp --path=%s --allow-root core install --url \"%s\" --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (install_path, url, new_database[0], new_database[2])) print "===> Setting up an %s vhost" % webserver # Copy vhost to server(s) From dc699922e7b32ab72eaa2822f4f6c33bebb53daf Mon Sep 17 00:00:00 2001 From: Matthieu Decorniquet Date: Mon, 4 Jan 2021 15:52:01 +0100 Subject: [PATCH 37/37] fix parameter assignement --- wordpress/InitialBuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/InitialBuild.py b/wordpress/InitialBuild.py index 30a65a49..85f6d0fa 100644 --- a/wordpress/InitialBuild.py +++ b/wordpress/InitialBuild.py @@ -60,7 +60,7 @@ def initial_build(repo, url, branch, build, buildtype, profile, webserver, webse else: install_path = "/var/www/live.%s.%s" % (repo, branch) sudo("wp --path=%s --allow-root core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s" % (install_path, new_database[0], new_database[1], new_database[2], new_database[3])) - sudo("wp --path=%s --allow-root core install --url \"%s\" --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (install_path, url, new_database[0], new_database[2])) + sudo("wp --path=%s --allow-root core install --url=%s --title=%s --admin_user=codeenigma --admin_email=sysadm@codeenigma.com --admin_password=%s" % (install_path, url, new_database[0], new_database[2])) print "===> Setting up an %s vhost" % webserver # Copy vhost to server(s)