Skip to content

Commit 150851c

Browse files
committed
feat(infra): an Ansible kube / k8s task DEPLOYS the template it applies
kubespray applies its cluster add-ons with its own `kube` module: a task runs kubectl apply on a manifest the play rendered from a template a few tasks earlier. Both tasks were Functions and the template a File, with nothing between them: no query reached the manifest a task applies. A kube (kubespray's library module) or k8s (kubernetes.core / community.kubernetes) task now DEPLOYS {via: ansible, module, line} the repository file its play rendered the applied manifest from: a template task's src (the role's templates/, else the task file's directory) or a copy task's (its files/; never a remote_src copy, which reads the host). The applied filename is traced through the play: a renderer whose dest is the very string; {{ item.item.K }} over "{{ R.results }}" -> each item of the renderer registering R; {{ item.K }} -> each of the task's own items through the renderer of that dest; a literal filename a looped renderer renders to; a k8s template: argument. A loop list is a literal, a set_fact of the file, or a list of the role's defaults / vars main file. Templates are found before copies to the same dest. remote_src is read the way Ansible's boolean() reads it (y / yes / on / 1 / true / t, any case): `remote_src: true` is a YAML boolean, not a string, and a string-only read had kept every remote copy as a renderer. The lists in a role's defaults / vars reach past the task file, so a change to one takes the full rebuild (closure_ansible_decline); without it, a list that names another template kept the edge to the old one. A file holding Ansible tasks that the repair would re-walk as a dependent -- a template it applies was deleted -- also takes the full rebuild (closure_ansible_dependent_decline): the repair walks it without its role's defaults, handlers and other task files, and drew none of its list-fed edges. Measured on 17 infrastructure repositories: 164 of 164 applied files (52 of kubespray's 62 kube / k8s tasks, 158 templates) against an independent reading, all in kubespray; nothing in the other 16; the rest of the graph unchanged (+164 DEPLOYS only); deterministic over three runs; the incremental re-index equals a full index for a template body edit, a deleted template (with and without a same-named fallback beside the task file), a task list edit, a copied manifest edit, a defaults list edit and a deleted vars file. Of the 10 tasks left out, 4 act on an object by name, one builds its definition with a template lookup, one applies a remote_src copy, and 4 name their file through a filter, a variable or two joined results lists. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 5ca4326 commit 150851c

6 files changed

Lines changed: 951 additions & 24 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ The install script placed beside the binary is **reported, not deleted**: uninst
341341
- `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`
342342
- `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)
343343
- 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
344-
- 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)
344+
- 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). A `kube` (kubespray's module) or `kubernetes.core.k8s` task `DEPLOYS` (`via: ansible`, `module`) the repository file its play rendered the applied manifest from: the `template` (in the role's `templates/`) or `copy` (its `files/`) task whose `dest` is the task's `filename`, item by item through `register` / `with_items` / `loop` lists the play states (a literal list, a `set_fact`, the role's `defaults` / `vars`), or a `k8s` `template:` argument
345345
- `EMITS`, `LISTENS_ON` (channels)
346346
- `DATA_FLOWS` with arg-to-param mapping + field access chains
347347
- `SIMILAR_TO` (MinHash + LSH near-clone detection, Jaccard scored)

0 commit comments

Comments
 (0)