@ansible-flow/assets 0.87.0 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Ansible Flow Designer files a host passes by path: the Python probe, the run events callback, the JSON schemas, the contract with Ansible Flow Server and the sample projects.
4
4
 
5
- Built from [Ansible Flow Designer](https://github.com/ChistokhinSV/ansible-flow-designer) 0.87.0
5
+ Built from [Ansible Flow Designer](https://github.com/ChistokhinSV/ansible-flow-designer) 0.88.0
6
6
  and released with it. The folders are found by path: `import { probeDir, schemaDir, contractDir, samplesDir } from '@ansible-flow/assets'`.
7
7
 
8
8
  What is in the package, which entry points are documented and what may change:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ansible-flow/assets",
3
- "version": "0.87.0",
3
+ "version": "0.88.0",
4
4
  "description": "Ansible Flow Designer files a host passes by path: the Python probe, the run events callback, the JSON schemas, the contract with Ansible Flow Server and the sample projects.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ChistokhinSV/ansible-flow-designer/blob/main/docs/packages.md",
@@ -31,9 +31,25 @@ def run_config(root: str) -> dict[str, Any]:
31
31
  """
32
32
  from ansible import constants as C
33
33
 
34
+ def paths(name: str) -> list[str]:
35
+ return [str(p) for p in (getattr(C, name, None) or [])]
36
+
34
37
  return {
35
38
  "callbacks_enabled": [str(c) for c in (C.CALLBACKS_ENABLED or [])],
36
- "callback_plugins": [str(p) for p in (C.DEFAULT_CALLBACK_PLUGIN_PATH or [])],
39
+ "callback_plugins": paths("DEFAULT_CALLBACK_PLUGIN_PATH"),
40
+ # AFD-291: a run adds the repository's library/, module_utils/ and plugin folders to these
41
+ # (generated playbooks are not next to them), and our vars plugin for the root's
42
+ # group_vars/host_vars. The variables it sets replace these values, so they are kept.
43
+ "plugin_paths": {
44
+ "library": paths("DEFAULT_MODULE_PATH"),
45
+ "module_utils": paths("DEFAULT_MODULE_UTILS_PATH"),
46
+ "action_plugins": paths("DEFAULT_ACTION_PLUGIN_PATH"),
47
+ "filter_plugins": paths("DEFAULT_FILTER_PLUGIN_PATH"),
48
+ "lookup_plugins": paths("DEFAULT_LOOKUP_PLUGIN_PATH"),
49
+ "test_plugins": paths("DEFAULT_TEST_PLUGIN_PATH"),
50
+ "vars_plugins": paths("DEFAULT_VARS_PLUGIN_PATH"),
51
+ },
52
+ "vars_enabled": [str(v) for v in (getattr(C, "VARIABLE_PLUGINS_ENABLED", None) or [])],
37
53
  }
38
54
 
39
55
 
@@ -0,0 +1,33 @@
1
+ # Ansible Flow Designer (AFD-291): group_vars/ and host_vars/ at the repository root, as if they
2
+ # were next to the playbook. Generated playbooks live in flows/<key>/generated/, so Ansible's own
3
+ # host_group_vars plugin finds the root's folders only when the inventory is there too. A run
4
+ # enables this plugin (ANSIBLE_VARS_ENABLED) and names the root in AFD_REPO_ROOT; like playbook
5
+ # group_vars, what it loads wins over the inventory's.
6
+ import os
7
+
8
+ from ansible.plugins.vars.host_group_vars import VarsModule as HostGroupVars
9
+
10
+ DOCUMENTATION = """
11
+ name: afd_repo_vars
12
+ short_description: group_vars and host_vars of the repository root
13
+ description: Loads group_vars/ and host_vars/ from the folder AFD_REPO_ROOT names.
14
+ options:
15
+ stage:
16
+ ini:
17
+ - key: stage
18
+ section: vars_afd_repo_vars
19
+ env:
20
+ - name: ANSIBLE_VARS_PLUGIN_STAGE
21
+ extends_documentation_fragment:
22
+ - vars_plugin_staging
23
+ """
24
+
25
+
26
+ class VarsModule(HostGroupVars):
27
+ REQUIRES_ENABLED = True
28
+
29
+ def get_vars(self, loader, path, entities, cache=True):
30
+ root = os.environ.get("AFD_REPO_ROOT")
31
+ if not root:
32
+ return {}
33
+ return super().get_vars(loader, root, entities, cache)