mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
merge with dev
This commit is contained in:
@@ -1,4 +1,51 @@
|
|||||||
#!py
|
#!py
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
def status():
|
def status():
|
||||||
return __salt__['cmd.run']('/usr/sbin/so-status')
|
return __salt__['cmd.run']('/usr/sbin/so-status')
|
||||||
|
|
||||||
|
|
||||||
|
def mysql_conn(retry):
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
try:
|
||||||
|
from MySQLdb import _mysql
|
||||||
|
except ImportError as e:
|
||||||
|
log.error(e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
mainint = __salt__['pillar.get']('sensor:mainint', __salt__['pillar.get']('manager:mainint'))
|
||||||
|
mainip = __salt__['grains.get']('ip_interfaces').get(mainint)[0]
|
||||||
|
|
||||||
|
mysql_up = False
|
||||||
|
for i in range(0, retry):
|
||||||
|
log.debug(f'Connection attempt {i+1}')
|
||||||
|
try:
|
||||||
|
db = _mysql.connect(
|
||||||
|
host=mainip,
|
||||||
|
user='root',
|
||||||
|
passwd=__salt__['pillar.get']('secrets:mysql')
|
||||||
|
)
|
||||||
|
log.debug(f'Connected to MySQL server on {mainip} after {i} attempts.')
|
||||||
|
|
||||||
|
db.query("""SELECT 1;""")
|
||||||
|
log.debug(f'Successfully completed query against MySQL server on {mainip}')
|
||||||
|
|
||||||
|
db.close()
|
||||||
|
mysql_up = True
|
||||||
|
break
|
||||||
|
except _mysql.OperationalError as e:
|
||||||
|
log.debug(e)
|
||||||
|
except Exception as e:
|
||||||
|
log.error('Unexpected error occured.')
|
||||||
|
log.error(e)
|
||||||
|
break
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
|
if not mysql_up:
|
||||||
|
log.error(f'Could not connect to MySQL server on {mainip} after {retry} attempts.')
|
||||||
|
|
||||||
|
return mysql_up
|
||||||
@@ -94,9 +94,14 @@ so-mysql:
|
|||||||
- /opt/so/conf/mysql/etc
|
- /opt/so/conf/mysql/etc
|
||||||
cmd.run:
|
cmd.run:
|
||||||
- name: until nc -z {{ MAINIP }} 3306; do sleep 1; done
|
- name: until nc -z {{ MAINIP }} 3306; do sleep 1; done
|
||||||
- timeout: 900
|
- timeout: 600
|
||||||
- onchanges:
|
- onchanges:
|
||||||
- docker_container: so-mysql
|
- docker_container: so-mysql
|
||||||
|
module.run:
|
||||||
|
- so.mysql_conn:
|
||||||
|
- retry: 300
|
||||||
|
- onchanges:
|
||||||
|
- cmd: so-mysql
|
||||||
|
|
||||||
append_so-mysql_so-status.conf:
|
append_so-mysql_so-status.conf:
|
||||||
file.append:
|
file.append:
|
||||||
|
|||||||
@@ -1729,6 +1729,7 @@ salt_checkin() {
|
|||||||
{
|
{
|
||||||
salt-call state.apply ca;
|
salt-call state.apply ca;
|
||||||
salt-call state.apply ssl;
|
salt-call state.apply ssl;
|
||||||
|
salt-call saltutil.sync_modules;
|
||||||
} >> "$setup_log" 2>&1
|
} >> "$setup_log" 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user