@@ -215,6 +215,18 @@ def _gather_buffer_space():
215
215
# Location of the files a minion should look for. Set to 'local' to never ask the master.
216
216
"file_client" : str ,
217
217
"local" : bool ,
218
+ # other non-salt hubble-specific things
219
+ "fileserver_update_frequency" : int ,
220
+ "grains_refresh_frequency" : int ,
221
+ "scheduler_sleep_frequency" : float ,
222
+ "default_include" : str ,
223
+ "logfile_maxbytes" : int ,
224
+ "logfile_backups" : int ,
225
+ "delete_inaccessible_azure_containers" : bool ,
226
+ "enable_globbing_in_nebula_masking" : bool ,
227
+ "osquery_logfile_maxbytes" : int ,
228
+ "osquery_logfile_maxbytes_toparse" : int ,
229
+ "osquery_backuplogs_count" : int ,
218
230
# When using a local file_client, this parameter is used to allow the client to connect to
219
231
# a master for remote execution.
220
232
"use_master_when_local" : bool ,
@@ -399,6 +411,10 @@ def _gather_buffer_space():
399
411
"event_match_type" : str ,
400
412
# This pidfile to write out to when a daemon starts
401
413
"pidfile" : str ,
414
+ # osquery stuff
415
+ "osquery_dbpath" : str ,
416
+ "osquerylogpath" : str ,
417
+ "osquerylog_backupdir" : str ,
402
418
# Used with the SECO range master tops system
403
419
"range_server" : str ,
404
420
# The tcp keepalive interval to set on TCP ports. This setting can be used to tune Salt
@@ -646,28 +662,30 @@ def _gather_buffer_space():
646
662
# used to mitigate a thundering-herd scenario when many minions start up
647
663
# at once and attempt to all connect immediately to the master
648
664
"random_startup_delay" : int ,
649
- # The source location for the winrepo sls files
650
- # (used by win_pkg.py, minion only)
651
- "winrepo_source_dir" : str ,
652
- "winrepo_dir" : str ,
653
- "winrepo_dir_ng" : str ,
654
- "winrepo_cachefile" : str ,
655
- # NOTE: winrepo_branch omitted here because its value could conceivably be
656
- # loaded as a non-string type, which is OK because winrepo will normalize
657
- # them to strings. But rather than include all the possible types it could
658
- # be, we'll just skip type-checking.
659
- "winrepo_cache_expire_max" : int ,
660
- "winrepo_cache_expire_min" : int ,
661
- "winrepo_remotes" : list ,
662
- "winrepo_remotes_ng" : list ,
663
- "winrepo_ssl_verify" : bool ,
664
- "winrepo_user" : str ,
665
- "winrepo_password" : str ,
666
- "winrepo_insecure_auth" : bool ,
667
- "winrepo_privkey" : str ,
668
- "winrepo_pubkey" : str ,
669
- "winrepo_passphrase" : str ,
670
- "winrepo_refspecs" : list ,
665
+
666
+ # TO REMOVE: see below # # The source location for the winrepo sls files
667
+ # TO REMOVE: see below # # (used by win_pkg.py, minion only)
668
+ # TO REMOVE: see below # "winrepo_source_dir": str,
669
+ # TO REMOVE: see below # "winrepo_dir": str,
670
+ # TO REMOVE: see below # "winrepo_dir_ng": str,
671
+ # TO REMOVE: see below # "winrepo_cachefile": str,
672
+ # TO REMOVE: see below # # NOTE: winrepo_branch omitted here because its value could conceivably be
673
+ # TO REMOVE: see below # # loaded as a non-string type, which is OK because winrepo will normalize
674
+ # TO REMOVE: see below # # them to strings. But rather than include all the possible types it could
675
+ # TO REMOVE: see below # # be, we'll just skip type-checking.
676
+ # TO REMOVE: see below # "winrepo_cache_expire_max": int,
677
+ # TO REMOVE: see below # "winrepo_cache_expire_min": int,
678
+ # TO REMOVE: see below # "winrepo_remotes": list,
679
+ # TO REMOVE: see below # "winrepo_remotes_ng": list,
680
+ # TO REMOVE: see below # "winrepo_ssl_verify": bool,
681
+ # TO REMOVE: see below # "winrepo_user": str,
682
+ # TO REMOVE: see below # "winrepo_password": str,
683
+ # TO REMOVE: see below # "winrepo_insecure_auth": bool,
684
+ # TO REMOVE: see below # "winrepo_privkey": str,
685
+ # TO REMOVE: see below # "winrepo_pubkey": str,
686
+ # TO REMOVE: see below # "winrepo_passphrase": str,
687
+ # TO REMOVE: see below # "winrepo_refspecs": list,
688
+
671
689
# Set a hard limit for the amount of memory modules can consume on a minion.
672
690
"modules_max_memory" : int ,
673
691
# The number of minutes between the minion refreshing its cache of grains
@@ -822,6 +840,14 @@ def _gather_buffer_space():
822
840
"netapi_allow_raw_shell" : bool ,
823
841
}
824
842
843
+ DEFAULT_CONF_FILE_NAME = DEFAULT_LOG_FILE_NAME = 'hubble'
844
+ DEFAULT_OSQUERY_DB_PATH = os .path .join (hubblestack .syspaths .CACHE_DIR , 'osquery' )
845
+
846
+ if hubblestack .utils .platform .is_windows ():
847
+ DEFAULT_CONF_FILE_NAME = 'hubble.conf'
848
+ DEFAULT_LOG_FILE_NAME = "hubble.log"
849
+ DEFAULT_OSQUERY_DB_PATH = os .path .join (hubblestack .syspaths .ROOT_DIR , 'var' , 'hubble_osquery_db' )
850
+
825
851
# default configurations
826
852
DEFAULT_OPTS = {
827
853
"interface" : "0.0.0.0" ,
@@ -842,16 +868,16 @@ def _gather_buffer_space():
842
868
"master_sign_key_name" : "master_sign" ,
843
869
"user" : hubblestack .utils .user .get_user (),
844
870
"root_dir" : hubblestack .syspaths .ROOT_DIR ,
845
- "pki_dir" : os .path .join (hubblestack .syspaths .CONFIG_DIR , "pki" , "minion" ),
871
+ "pki_dir" : os .path .join (hubblestack .syspaths .CONFIG_DIR , "pki" ),
846
872
"id" : "" ,
847
873
"id_function" : {},
848
- "cachedir" : os .path .join (hubblestack .syspaths .CACHE_DIR , "minion" ),
874
+ "cachedir" : os .path .join (hubblestack .syspaths .CACHE_DIR ),
849
875
"append_minionid_config_dirs" : [],
850
876
"cache_jobs" : False ,
851
877
"grains_cache" : False ,
852
878
"grains_cache_expiration" : 300 ,
853
879
"grains_deep_merge" : False ,
854
- "conf_file" : os .path .join (hubblestack .syspaths .CONFIG_DIR , "minion" ),
880
+ "conf_file" : os .path .join (hubblestack .syspaths .CONFIG_DIR , DEFAULT_CONF_FILE_NAME ),
855
881
"sock_pool_size" : 1 ,
856
882
"backup_mode" : "" ,
857
883
"renderer" : "jinja|yaml" ,
@@ -873,18 +899,27 @@ def _gather_buffer_space():
873
899
"pillar_cache" : False ,
874
900
"pillar_cache_ttl" : 3600 ,
875
901
"pillar_cache_backend" : "disk" ,
876
- "extension_modules" : os .path .join (hubblestack .syspaths .CACHE_DIR , "minion" , " extmods" ),
902
+ "extension_modules" : os .path .join (hubblestack .syspaths .CACHE_DIR , "extmods" ),
877
903
"state_top" : "top.sls" ,
878
904
"state_top_saltenv" : None ,
879
905
"startup_states" : "" ,
880
906
"sls_list" : [],
881
907
"top_file" : "" ,
882
- "file_client" : "remote" ,
908
+ "file_client" : "local" ,
909
+ "fileserver_update_frequency" : 43200 , # 12 hours
910
+ "grains_refresh_frequency" : 3600 , # 1 hour
911
+ "scheduler_sleep_frequency" : 0.5 , # 500ms
912
+ "default_include" : 'hubble.d/*.conf' ,
913
+ "logfile_maxbytes" : 100000000 , # 100MB kindof
914
+ "logfile_backups" : 1 , # max rotated logs
915
+ "delete_inaccessible_azure_containers" : False ,
916
+ "enable_globbing_in_nebula_masking" : False ,
917
+ "osquery_logfile_maxbytes" : 50000000 , # 50MB kindof
918
+ "osquery_logfile_maxbytes_toparse" : 100000000 , # 100MB kindof
919
+ "osquery_backuplogs_count" : 2 ,
883
920
"local" : False ,
884
921
"use_master_when_local" : False ,
885
- "file_roots" : {
886
- "base" : [hubblestack .syspaths .BASE_FILE_ROOTS_DIR ]
887
- },
922
+ "file_roots" : { "base" : list () },
888
923
"top_file_merging_strategy" : "merge" ,
889
924
"env_order" : [],
890
925
"default_top" : "base" ,
@@ -971,8 +1006,8 @@ def _gather_buffer_space():
971
1006
"tcp_pub_port" : 4510 ,
972
1007
"tcp_pull_port" : 4511 ,
973
1008
"tcp_authentication_retries" : 5 ,
974
- "log_file" : os .path .join (hubblestack .syspaths .LOGS_DIR , "minion" ),
975
- "log_level" : "warning " ,
1009
+ "log_file" : os .path .join (hubblestack .syspaths .LOGS_DIR , DEFAULT_LOG_FILE_NAME ),
1010
+ "log_level" : "error " ,
976
1011
"log_level_logfile" : None ,
977
1012
"log_datefmt" : _DFLT_LOG_DATEFMT ,
978
1013
"log_datefmt_logfile" : _DFLT_LOG_DATEFMT_LOGFILE ,
@@ -1004,7 +1039,7 @@ def _gather_buffer_space():
1004
1039
"verify_env" : True ,
1005
1040
"grains" : {},
1006
1041
"permissive_pki_access" : False ,
1007
- "default_include" : "minion .d/*.conf" ,
1042
+ "default_include" : "hubble .d/*.conf" ,
1008
1043
"update_url" : False ,
1009
1044
"update_restart_services" : [],
1010
1045
"retry_dns" : 30 ,
@@ -1015,24 +1050,29 @@ def _gather_buffer_space():
1015
1050
"recon_randomize" : True ,
1016
1051
"return_retry_timer" : 5 ,
1017
1052
"return_retry_timer_max" : 10 ,
1018
- "winrepo_source_dir" : "salt://win/repo-ng/" ,
1019
- "winrepo_dir" : os .path .join (hubblestack .syspaths .BASE_FILE_ROOTS_DIR , "win" , "repo" ),
1020
- "winrepo_dir_ng" : os .path .join (hubblestack .syspaths .BASE_FILE_ROOTS_DIR , "win" , "repo-ng" ),
1021
- "winrepo_cachefile" : "winrepo.p" ,
1022
- "winrepo_cache_expire_max" : 21600 ,
1023
- "winrepo_cache_expire_min" : 1800 ,
1024
- "winrepo_remotes" : ["https://github.com/saltstack/salt-winrepo.git" ],
1025
- "winrepo_remotes_ng" : ["https://github.com/saltstack/salt-winrepo-ng.git" ],
1026
- "winrepo_branch" : "master" ,
1027
- "winrepo_ssl_verify" : True ,
1028
- "winrepo_user" : "" ,
1029
- "winrepo_password" : "" ,
1030
- "winrepo_insecure_auth" : False ,
1031
- "winrepo_privkey" : "" ,
1032
- "winrepo_pubkey" : "" ,
1033
- "winrepo_passphrase" : "" ,
1034
- "winrepo_refspecs" : _DFLT_REFSPECS ,
1035
- "pidfile" : os .path .join (hubblestack .syspaths .PIDFILE_DIR , "salt-minion.pid" ),
1053
+ # NOTE: keeping this here for reference; but we hoppefully won't need it
1054
+ # after the windows phase of the saltless re-work
1055
+ # "winrepo_dir": os.path.join(hubblestack.syspaths.BASE_FILE_ROOTS_DIR, "win", "repo"),
1056
+ # "winrepo_dir_ng": os.path.join(hubblestack.syspaths.BASE_FILE_ROOTS_DIR, "win", "repo-ng"),
1057
+ # "winrepo_source_dir": "salt://win/repo-ng/",
1058
+ # "winrepo_cachefile": "winrepo.p",
1059
+ # "winrepo_cache_expire_max": 21600,
1060
+ # "winrepo_cache_expire_min": 1800,
1061
+ # "winrepo_remotes": ["https://github.com/saltstack/salt-winrepo.git"],
1062
+ # "winrepo_remotes_ng": ["https://github.com/saltstack/salt-winrepo-ng.git"],
1063
+ # "winrepo_branch": "master",
1064
+ # "winrepo_ssl_verify": True,
1065
+ # "winrepo_user": "",
1066
+ # "winrepo_password": "",
1067
+ # "winrepo_insecure_auth": False,
1068
+ # "winrepo_privkey": "",
1069
+ # "winrepo_pubkey": "",
1070
+ # "winrepo_passphrase": "",
1071
+ # "winrepo_refspecs": _DFLT_REFSPECS,
1072
+ "pidfile" : os .path .join (hubblestack .syspaths .PIDFILE_DIR , "hubble.pid" ),
1073
+ "osquery_dbpath" : DEFAULT_OSQUERY_DB_PATH ,
1074
+ "osquerylogpath" : os .path .join (hubblestack .syspaths .LOGS_DIR , 'hubble_osquery' ),
1075
+ "osquerylog_backupdir" : os .path .join (hubblestack .syspaths .LOGS_DIR , 'hubble_osquery' , 'backuplogs' ),
1036
1076
"range_server" : "range:80" ,
1037
1077
"reactor_refresh_interval" : 60 ,
1038
1078
"reactor_worker_threads" : 10 ,
@@ -1293,44 +1333,19 @@ def _absolute_path(path, relative_to=None):
1293
1333
return path
1294
1334
1295
1335
1296
- def load_config (path , env_var , default_path = None , exit_on_config_errors = True ):
1336
+ def load_config (path , env_var , exit_on_config_errors = True ):
1297
1337
"""
1298
1338
Returns configuration dict from parsing either the file described by
1299
1339
``path`` or the environment variable described by ``env_var`` as YAML.
1300
1340
"""
1341
+
1342
+ path = env_path = os .environ .get (env_var , path )
1343
+ opts = {}
1344
+
1301
1345
if path is None :
1302
1346
# When the passed path is None, we just want the configuration
1303
1347
# defaults, not actually loading the whole configuration.
1304
- return {}
1305
-
1306
- if default_path is None :
1307
- # This is most likely not being used from salt, i.e., could be salt-cloud
1308
- # or salt-api which have not yet migrated to the new default_path
1309
- # argument. Let's issue a warning message that the environ vars won't
1310
- # work.
1311
- import inspect
1312
-
1313
- previous_frame = inspect .getframeinfo (inspect .currentframe ().f_back )
1314
- log .warning (
1315
- "The function '%s()' defined in '%s' is not yet using the "
1316
- "new 'default_path' argument to `hubblestack.config.load_config()`. "
1317
- "As such, the '%s' environment variable will be ignored" ,
1318
- previous_frame .function ,
1319
- previous_frame .filename ,
1320
- env_var ,
1321
- )
1322
- # In this case, maintain old behavior
1323
- default_path = DEFAULT_OPTS ["conf_file" ]
1324
-
1325
- # Default to the environment variable path, if it exists
1326
- env_path = os .environ .get (env_var , path )
1327
- if not env_path or not os .path .isfile (env_path ):
1328
- env_path = path
1329
- # If non-default path from `-c`, use that over the env variable
1330
- if path != default_path :
1331
- env_path = path
1332
-
1333
- path = env_path
1348
+ return opts
1334
1349
1335
1350
# If the configuration file is missing, attempt to copy the template,
1336
1351
# after removing the first header line.
@@ -1343,8 +1358,6 @@ def load_config(path, env_var, default_path=None, exit_on_config_errors=True):
1343
1358
ifile .readline () # skip first line
1344
1359
out .write (ifile .read ())
1345
1360
1346
- opts = {}
1347
-
1348
1361
if hubblestack .utils .validate .path .is_readable (path ):
1349
1362
try :
1350
1363
opts = _read_conf_file (path )
@@ -1479,25 +1492,33 @@ def insert_system_path(opts, paths):
1479
1492
1480
1493
1481
1494
def get_config (
1482
- path ,
1495
+ path = DEFAULT_OPTS [ 'conf_file' ] ,
1483
1496
env_var = "HUBBLE_CONFIG" ,
1484
1497
defaults = None ,
1485
1498
cache_minion_id = False ,
1486
1499
ignore_config_errors = True ,
1487
1500
minion_id = None
1488
1501
):
1489
1502
"""
1490
- Reads in the minion configuration file and sets up special options
1491
-
1492
- This is useful for Minion-side operations, such as the
1493
- :py:class:`~hubblestack.client.Caller` class, and manually running the loader
1494
- interface.
1503
+ Reads in the configuration file
1495
1504
1496
1505
.. code-block:: python
1497
1506
1498
1507
import hubblestack.config
1499
- minion_opts = hubblestack.config.get_config('/etc/salt/minion')
1508
+ __opts__ = hubblestack.config.get_config('/etc/hubble/hubble')
1509
+
1510
+
1511
+ Note that you're probably better off using the daemon loader though. It
1512
+ handles a few other things after it uses this get_config function to pull
1513
+ the configs from the file.
1514
+
1515
+ .. code-block:: python
1516
+
1517
+ import hubblestack.daemon
1518
+ __opts__ = hubblestack.daemon.load_config(['-c', '/etc/hubble/hubble'])
1519
+
1500
1520
"""
1521
+
1501
1522
if defaults is None :
1502
1523
defaults = DEFAULT_OPTS .copy ()
1503
1524
@@ -1506,13 +1527,13 @@ def get_config(
1506
1527
# Lets see is SALT_CONFIG_DIR is of any use
1507
1528
salt_config_dir = os .environ .get ("SALT_CONFIG_DIR" , None )
1508
1529
if salt_config_dir :
1509
- env_config_file_path = os .path .join (salt_config_dir , "minion " )
1530
+ env_config_file_path = os .path .join (salt_config_dir , "hubble " )
1510
1531
if salt_config_dir and os .path .isfile (env_config_file_path ):
1511
1532
# We can get a configuration file using SALT_CONFIG_DIR, let's
1512
1533
# update the environment with this information
1513
1534
os .environ [env_var ] = env_config_file_path
1514
1535
1515
- overrides = load_config (path , env_var , DEFAULT_OPTS [" conf_file" ] )
1536
+ overrides = load_config (path or DEFAULT_OPTS [' conf_file' ], env_var )
1516
1537
default_include = overrides .get ("default_include" , defaults ["default_include" ])
1517
1538
include = overrides .get ("include" , [])
1518
1539
0 commit comments