Add conf rollback with Git
This commit is contained in:
@@ -11,9 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
#### Added
|
#### Added
|
||||||
|
|
||||||
- [STACK] Nginx server_names_hash_bucket_size automated fix
|
- [STACK] Nginx server_names_hash_bucket_size automated fix
|
||||||
- [STACK] Nginx configuration rollback in case of failure after `wo stack upgrade --nginx
|
- [STACK] Nginx configuration rollback in case of failure after `wo stack upgrade --nginx`
|
||||||
- [STACK] Nginx ultimate bad bots blocker with `wo stack install --ngxblocker`
|
- [STACK] Nginx ultimate bad bots blocker with `wo stack install --ngxblocker`
|
||||||
- [STACK] Added support for custom Nginx compiled from source
|
- [STACK] Added support for custom Nginx compiled from source
|
||||||
|
- [STACK] Rollback configuration with Git in case of failure during service reload/restart
|
||||||
|
|
||||||
#### Changed
|
#### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -1452,10 +1452,12 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
# check DNS records before issuing cert
|
# check DNS records before issuing cert
|
||||||
if not acmedata['dns'] is True:
|
if not acmedata['dns'] is True:
|
||||||
if not pargs.force:
|
if not pargs.force:
|
||||||
if not WOAcme.check_dns(self, acme_domains):
|
if not WOAcme.check_dns(self,
|
||||||
|
acme_domains):
|
||||||
Log.error(
|
Log.error(
|
||||||
self,
|
self,
|
||||||
"Aborting SSL certificate issuance")
|
"Aborting SSL "
|
||||||
|
"certificate issuance")
|
||||||
if WOAcme.setupletsencrypt(
|
if WOAcme.setupletsencrypt(
|
||||||
self, acme_domains, acmedata):
|
self, acme_domains, acmedata):
|
||||||
WOAcme.deploycert(self, wo_domain)
|
WOAcme.deploycert(self, wo_domain)
|
||||||
|
|||||||
@@ -1624,4 +1624,4 @@ def setupngxblocker(self, domain, block=True):
|
|||||||
self, '/var/www/{0}/conf/nginx/ngxblocker.disabled'
|
self, '/var/www/{0}/conf/nginx/ngxblocker.disabled'
|
||||||
.format(domain), '/var/www/{0}/conf/nginx/ngxblocker'
|
.format(domain), '/var/www/{0}/conf/nginx/ngxblocker'
|
||||||
.format(domain))
|
.format(domain))
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import string
|
|||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from wo.cli.plugins.site_functions import *
|
from wo.cli.plugins.site_functions import *
|
||||||
from wo.cli.plugins.stack_services import WOStackStatusController
|
from wo.cli.plugins.stack_services import WOStackStatusController
|
||||||
from wo.core.apt_repo import WORepo
|
from wo.core.apt_repo import WORepo
|
||||||
@@ -19,12 +18,12 @@ from wo.core.fileutils import WOFileUtils
|
|||||||
from wo.core.git import WOGit
|
from wo.core.git import WOGit
|
||||||
from wo.core.logging import Log
|
from wo.core.logging import Log
|
||||||
from wo.core.mysql import WOMysql
|
from wo.core.mysql import WOMysql
|
||||||
|
from wo.core.nginxhashbucket import hashbucket
|
||||||
from wo.core.services import WOService
|
from wo.core.services import WOService
|
||||||
from wo.core.shellexec import CommandExecutionError, WOShellExec
|
from wo.core.shellexec import CommandExecutionError, WOShellExec
|
||||||
from wo.core.sslutils import SSL
|
from wo.core.sslutils import SSL
|
||||||
from wo.core.template import WOTemplate
|
from wo.core.template import WOTemplate
|
||||||
from wo.core.variables import WOVar
|
from wo.core.variables import WOVar
|
||||||
from wo.core.nginxhashbucket import hashbucket
|
|
||||||
|
|
||||||
|
|
||||||
def pre_pref(self, apt_packages):
|
def pre_pref(self, apt_packages):
|
||||||
@@ -471,12 +470,8 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
|||||||
'> /dev/null 2>&1',
|
'> /dev/null 2>&1',
|
||||||
comment='Cloudflare IP refresh cronjob '
|
comment='Cloudflare IP refresh cronjob '
|
||||||
'added by WordOps')
|
'added by WordOps')
|
||||||
WOGit.add(self,
|
|
||||||
["/etc/nginx"], msg="Adding Nginx into Git")
|
|
||||||
|
|
||||||
# Nginx Configation into GIT
|
# Nginx Configation into GIT
|
||||||
WOGit.add(self,
|
|
||||||
["/etc/nginx"], msg="Adding Nginx into Git")
|
|
||||||
if not WOService.restart_service(self, 'nginx'):
|
if not WOService.restart_service(self, 'nginx'):
|
||||||
try:
|
try:
|
||||||
hashbucket(self)
|
hashbucket(self)
|
||||||
@@ -492,6 +487,8 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
|||||||
self, "There is an error in Nginx configuration.\n"
|
self, "There is an error in Nginx configuration.\n"
|
||||||
"Use the command nginx -t to identify "
|
"Use the command nginx -t to identify "
|
||||||
"the cause of this issue", False)
|
"the cause of this issue", False)
|
||||||
|
else:
|
||||||
|
WOGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git")
|
||||||
|
|
||||||
if set(WOVar.wo_php).issubset(set(apt_packages)):
|
if set(WOVar.wo_php).issubset(set(apt_packages)):
|
||||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||||
@@ -623,8 +620,11 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
|||||||
'www-data',
|
'www-data',
|
||||||
'www-data', recursive=True)
|
'www-data', recursive=True)
|
||||||
|
|
||||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
# check service restart or rollback configuration
|
||||||
WOService.restart_service(self, 'php7.2-fpm')
|
if not WOService.restart_service(self, 'php7.2-fpm'):
|
||||||
|
WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP")
|
||||||
|
else:
|
||||||
|
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||||
|
|
||||||
# PHP7.3 configuration
|
# PHP7.3 configuration
|
||||||
if set(WOVar.wo_php73).issubset(set(apt_packages)):
|
if set(WOVar.wo_php73).issubset(set(apt_packages)):
|
||||||
@@ -756,9 +756,11 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
|||||||
.format(ngxroot),
|
.format(ngxroot),
|
||||||
'www-data',
|
'www-data',
|
||||||
'www-data', recursive=True)
|
'www-data', recursive=True)
|
||||||
|
# check service restart or rollback configuration
|
||||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
if not WOService.restart_service(self, 'php7.3-fpm'):
|
||||||
WOService.restart_service(self, 'php7.3-fpm')
|
WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP")
|
||||||
|
else:
|
||||||
|
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||||
|
|
||||||
# create mysql config if it doesn't exist
|
# create mysql config if it doesn't exist
|
||||||
if "mariadb-server" in apt_packages:
|
if "mariadb-server" in apt_packages:
|
||||||
@@ -837,9 +839,12 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
|||||||
'fail2ban-forbidden.mustache',
|
'fail2ban-forbidden.mustache',
|
||||||
data, overwrite=False)
|
data, overwrite=False)
|
||||||
|
|
||||||
WOGit.add(self, ["/etc/fail2ban"],
|
if not WOService.reload_service(self, 'fail2ban'):
|
||||||
msg="Adding Fail2ban into Git")
|
WOGit.rollback(
|
||||||
WOService.reload_service(self, 'fail2ban')
|
self, ['/etc/fail2ban'], msg="Rollback f2b config")
|
||||||
|
else:
|
||||||
|
WOGit.add(self, ["/etc/fail2ban"],
|
||||||
|
msg="Adding Fail2ban into Git")
|
||||||
|
|
||||||
# Proftpd configuration
|
# Proftpd configuration
|
||||||
if "proftpd-basic" in apt_packages:
|
if "proftpd-basic" in apt_packages:
|
||||||
@@ -899,9 +904,12 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
|||||||
f2bproftpd.write("\n\n[proftpd]\nenabled = true\n")
|
f2bproftpd.write("\n\n[proftpd]\nenabled = true\n")
|
||||||
WOService.reload_service(self, 'fail2ban')
|
WOService.reload_service(self, 'fail2ban')
|
||||||
|
|
||||||
WOGit.add(self, ["/etc/proftpd"],
|
if not WOService.reload_service(self, 'proftpd'):
|
||||||
msg="Adding ProFTPd into Git")
|
WOGit.rollback(self, ["/etc/proftpd"],
|
||||||
WOService.reload_service(self, 'proftpd')
|
msg="Rollback ProFTPd")
|
||||||
|
else:
|
||||||
|
WOGit.add(self, ["/etc/proftpd"],
|
||||||
|
msg="Adding ProFTPd into Git")
|
||||||
|
|
||||||
if "ufw" in apt_packages:
|
if "ufw" in apt_packages:
|
||||||
# check if ufw is already enabled
|
# check if ufw is already enabled
|
||||||
@@ -999,9 +1007,10 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
|||||||
WOFileUtils.chown(self, '/etc/redis/redis.conf',
|
WOFileUtils.chown(self, '/etc/redis/redis.conf',
|
||||||
'redis', 'redis', recursive=False)
|
'redis', 'redis', recursive=False)
|
||||||
Log.valide(self, "Tuning Redis configuration")
|
Log.valide(self, "Tuning Redis configuration")
|
||||||
WOGit.add(self, ["/etc/redis"],
|
if not WOService.restart_service(self, 'redis-server'):
|
||||||
msg="Adding Redis into Git")
|
WOGit.rollback(self, ["/etc/redis"], msg="Rollback Redis")
|
||||||
WOService.restart_service(self, 'redis-server')
|
else:
|
||||||
|
WOGit.add(self, ["/etc/redis"], msg="Adding Redis into Git")
|
||||||
|
|
||||||
# ClamAV configuration
|
# ClamAV configuration
|
||||||
if set(WOVar.wo_clamav).issubset(set(apt_packages)):
|
if set(WOVar.wo_clamav).issubset(set(apt_packages)):
|
||||||
|
|||||||
Reference in New Issue
Block a user