mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-21 08:23:08 +01:00
Fleet standalone - custom hostnames
This commit is contained in:
@@ -9,10 +9,6 @@ import subprocess
|
||||
def run():
|
||||
MINIONID = data['id']
|
||||
ACTION = data['data']['action']
|
||||
HOSTNAME = data['data']['hostname']
|
||||
ROLE = data['data']['role']
|
||||
ESECRET = data['data']['enroll-secret']
|
||||
MAINIP = data['data']['mainip']
|
||||
|
||||
STATICFILE = '/opt/so/saltstack/pillar/static.sls'
|
||||
SECRETSFILE = '/opt/so/saltstack/pillar/secrets.sls'
|
||||
@@ -21,6 +17,11 @@ def run():
|
||||
if ACTION == 'enablefleet':
|
||||
logging.info('so/fleet enablefleet reactor')
|
||||
|
||||
ESECRET = data['data']['enroll-secret']
|
||||
MAINIP = data['data']['mainip']
|
||||
ROLE = data['data']['role']
|
||||
HOSTNAME = data['data']['hostname']
|
||||
|
||||
# Enable Fleet
|
||||
for line in fileinput.input(STATICFILE, inplace=True):
|
||||
if ROLE == 'so-fleet':
|
||||
@@ -48,8 +49,10 @@ def run():
|
||||
logging.info('so/fleet genpackages reactor')
|
||||
|
||||
PACKAGEVERSION = data['data']['current-package-version']
|
||||
PACKAGEHOSTNAME = data['data']['package-hostname']
|
||||
MASTER = data['data']['master']
|
||||
VERSION = data['data']['version']
|
||||
ESECRET = data['data']['enroll-secret']
|
||||
|
||||
# Increment the package version by 1
|
||||
PACKAGEVERSION += 1
|
||||
@@ -57,7 +60,7 @@ def run():
|
||||
# Run Docker container that will build the packages
|
||||
gen_packages = subprocess.run(["docker", "run","--rm", "--mount", "type=bind,source=/opt/so/saltstack/salt/fleet/packages,target=/output", \
|
||||
"--mount", "type=bind,source=/etc/ssl/certs/intca.crt,target=/var/launcher/launcher.crt", f"{ MASTER }:5000/soshybridhunter/so-fleet-launcher:{ VERSION }", \
|
||||
f"{ESECRET}", f"{HOSTNAME}:8090", f"{PACKAGEVERSION}.1.1"], stdout=subprocess.PIPE, encoding='ascii')
|
||||
f"{ESECRET}", f"{PACKAGEHOSTNAME}:8090", f"{PACKAGEVERSION}.1.1"], stdout=subprocess.PIPE, encoding='ascii')
|
||||
|
||||
# Update the 'packages-built' timestamp on the webpage (stored in the static pillar)
|
||||
for line in fileinput.input(STATICFILE, inplace=True):
|
||||
@@ -70,6 +73,16 @@ def run():
|
||||
print(line)
|
||||
|
||||
# Copy over newly-built packages
|
||||
copy_packages = subprocess.run(["salt-call", "state.apply","fleet"], stdout=subprocess.PIPE, encoding='ascii')
|
||||
copy_packages = subprocess.run(["salt-call", "state.apply","fleet"], stdout=subprocess.PIPE, encoding='ascii')
|
||||
|
||||
if ACTION == 'update_custom_hostname':
|
||||
logging.info('so/fleet update_custom_hostname reactor')
|
||||
|
||||
CUSTOMHOSTNAME = data['data']['custom_hostname']
|
||||
|
||||
# Update the Fleet host in the static pillar
|
||||
for line in fileinput.input(STATICFILE, inplace=True):
|
||||
line = re.sub(r'fleet_custom_hostname: \S*', f"fleet_custom_hostname: {CUSTOMHOSTNAME}", line.rstrip())
|
||||
print(line)
|
||||
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user