mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 14:44:29 -04:00
split plugin dirs, created new cleaner import path for plugin config in settings.py
This commit is contained in:
parent
1a58967e8c
commit
a9a97c013d
39 changed files with 469 additions and 199 deletions
|
@ -1,59 +1,59 @@
|
|||
import os
|
||||
# import os
|
||||
|
||||
from pathlib import Path
|
||||
# from pathlib import Path
|
||||
|
||||
from benedict import benedict
|
||||
from rich.pretty import pprint
|
||||
# from benedict import benedict
|
||||
# from rich.pretty import pprint
|
||||
|
||||
from ansible_runner import Runner, RunnerConfig
|
||||
# from ansible_runner import Runner, RunnerConfig
|
||||
|
||||
GLOBAL_CACHE = {}
|
||||
# GLOBAL_CACHE = {}
|
||||
|
||||
|
||||
def run_playbook(playbook_path, data_dir, quiet=False, **kwargs):
|
||||
ANSIBLE_TMP_DIR = str(Path(data_dir) / "tmp" / "ansible")
|
||||
os.environ['ANSIBLE_INVENTORY_UNPARSED_WARNING'] = 'False'
|
||||
os.environ['ANSIBLE_LOCALHOST_WARNING'] = 'False'
|
||||
os.environ["ANSIBLE_HOME"] = ANSIBLE_TMP_DIR
|
||||
# os.environ["ANSIBLE_COLLECTIONS_PATH"] = str(Path(data_dir).parent / 'archivebox')
|
||||
os.environ["ANSIBLE_ROLES_PATH"] = (
|
||||
'/Volumes/NVME/Users/squash/Code/archiveboxes/archivebox7/archivebox/builtin_plugins/ansible/roles'
|
||||
)
|
||||
# def run_playbook(playbook_path, data_dir, quiet=False, **kwargs):
|
||||
# ANSIBLE_TMP_DIR = str(Path(data_dir) / "tmp" / "ansible")
|
||||
# os.environ['ANSIBLE_INVENTORY_UNPARSED_WARNING'] = 'False'
|
||||
# os.environ['ANSIBLE_LOCALHOST_WARNING'] = 'False'
|
||||
# os.environ["ANSIBLE_HOME"] = ANSIBLE_TMP_DIR
|
||||
# # os.environ["ANSIBLE_COLLECTIONS_PATH"] = str(Path(data_dir).parent / 'archivebox')
|
||||
# os.environ["ANSIBLE_ROLES_PATH"] = (
|
||||
# './roles'
|
||||
# )
|
||||
|
||||
rc = RunnerConfig(
|
||||
private_data_dir=ANSIBLE_TMP_DIR,
|
||||
playbook=str(playbook_path),
|
||||
rotate_artifacts=50000,
|
||||
host_pattern="localhost",
|
||||
extravars={
|
||||
"DATA_DIR": str(data_dir),
|
||||
**kwargs,
|
||||
},
|
||||
quiet=quiet,
|
||||
)
|
||||
rc.prepare()
|
||||
r = Runner(config=rc)
|
||||
r.set_fact_cache('localhost', GLOBAL_CACHE)
|
||||
r.run()
|
||||
last_run_facts = r.get_fact_cache('localhost')
|
||||
GLOBAL_CACHE.update(filtered_facts(last_run_facts))
|
||||
return benedict({
|
||||
key: val
|
||||
for key, val in last_run_facts.items()
|
||||
if not (key.startswith('ansible_') or key in ('gather_subset', 'module_setup'))
|
||||
})
|
||||
# rc = RunnerConfig(
|
||||
# private_data_dir=ANSIBLE_TMP_DIR,
|
||||
# playbook=str(playbook_path),
|
||||
# rotate_artifacts=50000,
|
||||
# host_pattern="localhost",
|
||||
# extravars={
|
||||
# "DATA_DIR": str(data_dir),
|
||||
# **kwargs,
|
||||
# },
|
||||
# quiet=quiet,
|
||||
# )
|
||||
# rc.prepare()
|
||||
# r = Runner(config=rc)
|
||||
# r.set_fact_cache('localhost', GLOBAL_CACHE)
|
||||
# r.run()
|
||||
# last_run_facts = r.get_fact_cache('localhost')
|
||||
# GLOBAL_CACHE.update(filtered_facts(last_run_facts))
|
||||
# return benedict({
|
||||
# key: val
|
||||
# for key, val in last_run_facts.items()
|
||||
# if not (key.startswith('ansible_') or key in ('gather_subset', 'module_setup'))
|
||||
# })
|
||||
|
||||
def filtered_facts(facts):
|
||||
return benedict({
|
||||
key: val
|
||||
for key, val in facts.items()
|
||||
if not (key.startswith('ansible_') or key in ('gather_subset', 'module_setup'))
|
||||
})
|
||||
# def filtered_facts(facts):
|
||||
# return benedict({
|
||||
# key: val
|
||||
# for key, val in facts.items()
|
||||
# if not (key.startswith('ansible_') or key in ('gather_subset', 'module_setup'))
|
||||
# })
|
||||
|
||||
def print_globals():
|
||||
pprint(filtered_facts(GLOBAL_CACHE), expand_all=True)
|
||||
# def print_globals():
|
||||
# pprint(filtered_facts(GLOBAL_CACHE), expand_all=True)
|
||||
|
||||
|
||||
|
||||
# YTDLP_OUTPUT = run_playbook('extract.yml', {'url': 'https://www.youtube.com/watch?v=cK4REjqGc9w&t=27s'})
|
||||
# pprint(YTDLP_OUTPUT)
|
||||
# # YTDLP_OUTPUT = run_playbook('extract.yml', {'url': 'https://www.youtube.com/watch?v=cK4REjqGc9w&t=27s'})
|
||||
# # pprint(YTDLP_OUTPUT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue