| 1280 | |
| 1281 | @pytest.fixture(scope="session") |
| 1282 | def salt_master_factory( |
| 1283 | salt_factories, |
| 1284 | salt_syndic_master_factory, |
| 1285 | base_env_state_tree_root_dir, |
| 1286 | base_env_pillar_tree_root_dir, |
| 1287 | prod_env_state_tree_root_dir, |
| 1288 | prod_env_pillar_tree_root_dir, |
| 1289 | ext_pillar_file_tree_root_dir, |
| 1290 | salt_api_account_factory, |
| 1291 | ): |
| 1292 | import saltfactories.daemons.master |
| 1293 | |
| 1294 | root_dir = salt_factories.get_root_dir_for_daemon( |
| 1295 | "master", factory_class=saltfactories.daemons.master.SaltMaster |
| 1296 | ) |
| 1297 | conf_dir = root_dir / "conf" |
| 1298 | conf_dir.mkdir(exist_ok=True) |
| 1299 | |
| 1300 | with salt.utils.files.fopen(os.path.join(RUNTIME_VARS.CONF_DIR, "master")) as rfh: |
| 1301 | config_defaults = yaml.deserialize(rfh.read()) |
| 1302 | |
| 1303 | tests_known_hosts_file = str(root_dir / "salt_ssh_known_hosts") |
| 1304 | with salt.utils.files.fopen(tests_known_hosts_file, "w") as known_hosts: |
| 1305 | known_hosts.write("") |
| 1306 | |
| 1307 | config_defaults["root_dir"] = str(root_dir) |
| 1308 | config_defaults["known_hosts_file"] = tests_known_hosts_file |
| 1309 | config_defaults["syndic_master"] = "localhost" |
| 1310 | config_defaults["transport"] = salt_syndic_master_factory.config["transport"] |
| 1311 | |
| 1312 | config_overrides = { |
| 1313 | "log_level_logfile": "info", |
| 1314 | "fips_mode": FIPS_TESTRUN, |
| 1315 | "publish_signing_algorithm": ( |
| 1316 | "PKCS1v15-SHA224" if FIPS_TESTRUN else "PKCS1v15-SHA1" |
| 1317 | ), |
| 1318 | } |
| 1319 | ext_pillar = [] |
| 1320 | if salt.utils.platform.is_windows(): |
| 1321 | ext_pillar.append( |
| 1322 | {"cmd_yaml": "type {}".format(os.path.join(RUNTIME_VARS.FILES, "ext.yaml"))} |
| 1323 | ) |
| 1324 | else: |
| 1325 | ext_pillar.append( |
| 1326 | {"cmd_yaml": "cat {}".format(os.path.join(RUNTIME_VARS.FILES, "ext.yaml"))} |
| 1327 | ) |
| 1328 | ext_pillar.append( |
| 1329 | { |
| 1330 | "file_tree": { |
| 1331 | "root_dir": str(ext_pillar_file_tree_root_dir), |
| 1332 | "follow_dir_links": False, |
| 1333 | "keep_newline": True, |
| 1334 | } |
| 1335 | } |
| 1336 | ) |
| 1337 | config_overrides["pillar_opts"] = True |
| 1338 | config_overrides["external_auth"] = { |
| 1339 | "auto": { |