Skip to content

Commit 701d95e

Browse files
committed
feat(infra): Ansible tasks are Functions, a notify CALLS its handlers
kubespray's 1,425 tasks and 65 handlers were text inside YAML files: a search for "Containerd | restart containerd" found no node, and nothing said which task triggers which handler. Each task and handler of an Ansible file is now a Function, named by its `name:` (else its module), {source: ansible, kind, module}, which its file DEFINES -- a playbook's pre_tasks / tasks / post_tasks / handlers, a role's tasks/ and handlers/ files, and the files those include; a block's block / rescue / always tasks, never the block itself. A notify CALLS {via: notify, line} every handler of that name or listen topic in the task's own role (the directory before its tasks/, so nested roles stay apart), else in its file. A top-level YAML list is not Ansible by itself: JSON patches, image maps and service lists are lists too, and would have made some 3,000 false tasks in five other repositories. A file counts when it is a playbook, a role's tasks or handlers file, or included by one (to a fixpoint). Quoted names have their YAML escapes decoded. A notify joins two files, so a change to Ansible content takes the full rebuild (closure_ansible_decline); without it, renaming a listen topic or adding a notifying task left the incremental graph different from a full index. Measured on 17 infrastructure repositories: 1,490 of 1,490 tasks and handlers (file, line, kind, name, module) and 276 of 276 notify edges against an independent reading, all in kubespray; nothing in the other 16; the P7.1 include edges unchanged (211 of 211); deterministic over three runs; the incremental re-index equals a full index for handler and task file edits, a deleted handler file and a playbook edit. The only other change: as every function joins the similarity corpus, four SEMANTICALLY_RELATED scores in kubespray's Python module moved and one pair was added. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 1669626 commit 701d95e

6 files changed

Lines changed: 925 additions & 45 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ The install script placed beside the binary is **reported, not deleted** — uni
260260
- `USAGE` with `via: terraform` — a Terraform / OpenTofu reference (`var.X`, `local.X`, `module.X`, `data.T.N`, `T.N`) from the top-level block holding it to the block of its module — the `.tf` / `.tofu` files of its directory — that declares it (a `locals` entry: its `locals` block); an entry of the block's `depends_on` list is a `DEPENDS_ON` instead. The edge keeps `ref` (`var`, `local`, `module`, `data`, `resource`) and `line`; a name only mentioned in string text is no reference. A module call with a local source (`module "net" { source = "./modules/net" }`) `IMPORTS` (`local_name`: the module's name) the `Folder` of that directory (the root directory: the `Project`), and `module.net.id` (also `module.net[0].id`, `module.net[*].id`) `USAGE`s (`ref: output`) the `output "id"` there, beside `module.net`
261261
- `OVERRIDE` with `via: tfvars` — a `.tfvars` assignment to a variable the module of its own directory declares, from the file's `Variable` to that `variable` block (the edge keeps `line`); a `.tfvars` file whose own directory declares none of its names sets the nearest ancestor module's that does, the edge marked `inferred` (such a file is applied by a `-var-file` the repository does not state)
262262
- Terragrunt (`via: terragrunt`) — a unit (`terragrunt.hcl`), evaluated in its own context: an `include` `IMPORTS` (`local_name`) the file its `path` names; a `read_terragrunt_config` `IMPORTS` (`read`: the file holding the call) the file it names, from the block holding the call or, for a call in an included file, from the unit's `include` block that brings it in; a `dependency` `DEPENDS_ON` the other unit; a local `terraform` `source` `IMPORTS` its `Folder`. Paths may use `find_in_parent_folders`, `dirname` and `get_terragrunt_dir`; anything else is unknown and links nothing
263-
- Ansible (`via: ansible`) — a playbook or task file (a YAML file whose top level is a sequence) `IMPORTS` (`local_name`: the directive) what its directives name: `import_playbook` a playbook, `include_tasks` / `import_tasks` / `include` a task file (from its directory, else its role's `tasks/`), `roles:` items and `include_role` / `import_role` a role's `Folder` (`roles/<name>` at or above its directory). A templated target links nothing
263+
- Ansible (`via: ansible`) — a playbook or task file (a YAML file whose top level is a sequence) `IMPORTS` (`local_name`: the directive) what its directives name: `import_playbook` a playbook, `include_tasks` / `import_tasks` / `include` a task file (from its directory, else its role's `tasks/`), `roles:` items and `include_role` / `import_role` a role's `Folder` (`roles/<name>` at or above its directory). A templated target links nothing. Each task and handler is a `Function` (named by its `name:`, else its module; `source: ansible`, `kind`, `module`) that its file `DEFINES` — in a playbook's plays, a role's `tasks/` and `handlers/` files, and the files those include; a block's tasks, not the block. A `notify` `CALLS` (`via: notify`) each handler of that name or `listen` topic in the task's own role (else its file)
264264
- `EMITS`, `LISTENS_ON` (channels)
265265
- `DATA_FLOWS` with arg-to-param mapping + field access chains
266266
- `SIMILAR_TO` (MinHash + LSH near-clone detection, Jaccard scored)

0 commit comments

Comments
 (0)