MCPcopy Create free account
hub / github.com/saltstack/salt / prepare

Method prepare

salt/cli/daemons.py:257–338  ·  view source on GitHub ↗

Run the preparation sequence required to start a salt minion. If sub-classed, don't **ever** forget to run: super(YourSubClass, self).prepare()

(self)

Source from the content-addressed store, hash-verified

255
256 # pylint: disable=no-member
257 def prepare(self):
258 """
259 Run the preparation sequence required to start a salt minion.
260
261 If sub-classed, don't **ever** forget to run:
262
263 super(YourSubClass, self).prepare()
264 """
265 super().prepare()
266 _ostruststore.apply_if_enabled(self.config)
267
268 try:
269 if self.config["verify_env"]:
270 confd = self.config.get("default_include")
271 if confd:
272 # If 'default_include' is specified in config, then use it
273 if "*" in confd:
274 # Value is of the form "minion.d/*.conf"
275 confd = os.path.dirname(confd)
276 if not os.path.isabs(confd):
277 # If configured 'default_include' is not an absolute
278 # path, consider it relative to folder of 'conf_file'
279 # (/etc/salt by default)
280 confd = os.path.join(
281 os.path.dirname(self.config["conf_file"]), confd
282 )
283 else:
284 confd = os.path.join(
285 os.path.dirname(self.config["conf_file"]), "minion.d"
286 )
287
288 v_dirs = [
289 self.config["pki_dir"],
290 self.config["cachedir"],
291 os.path.join(
292 self.config["cachedir"], "proc"
293 ), # Ensure proc dir is created before privilege drop
294 self.config["sock_dir"],
295 self.config["extension_modules"],
296 confd,
297 ]
298
299 verify_env(
300 v_dirs,
301 self.config["user"],
302 permissive=self.config["permissive_pki_access"],
303 root_dir=self.config["root_dir"],
304 pki_dir=self.config["pki_dir"],
305 )
306 except OSError as error:
307 self.environment_failure(error)
308
309 log.info('Setting up the Salt Minion "%s"', self.config["id"])
310 migrations.migrate_paths(self.config)
311
312 # Bail out if we find a process running and it matches out pidfile
313 if (HAS_PSUTIL and not self.claim_process_responsibility()) or (
314 not HAS_PSUTIL and self.check_running()

Callers 1

callMethod · 0.95

Calls 12

shutdownMethod · 0.95
verify_envFunction · 0.90
environment_failureMethod · 0.80
check_runningMethod · 0.80
action_log_infoMethod · 0.80
daemonize_if_requiredMethod · 0.80
set_pidfileMethod · 0.80
prepareMethod · 0.45
getMethod · 0.45
infoMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected