Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Ansible Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-ansible-knowledge-patch)
---
name: ansible-knowledge-patch
description: Ansible Core
version: "2.21.7"
license: MIT
metadata:
author: Nevaberry
---
# Ansible Core Knowledge Patch
Load this skill when migrating Ansible playbooks, templates, plugins, modules,
connections, Galaxy workflows, or test environments. Use the topic references
for complete guidance and the version-specific scope of each change.
## Reference index
| Reference | Topics |
| --- | --- |
| [Templating, values, and conditionals](references/templating.md) | Trust, conditional errors, null and omitted values, undefined markers, mutation, JSON, vaulted YAML, managed text |
| [Connections and privilege escalation](references/connections-and-privilege.md) | SSH, PSRP, Windows output, local escalation, sudo, persistent connections, terminal access, tracebacks |
| [Modules, facts, results, and Windows](references/modules-facts-and-windows.md) | Facts, result fields, packages, repositories, file handling, user accounts, PowerShell |
| [Playbooks, CLI, inventory, and Galaxy](references/playbooks-cli-and-inventory.md) | Task syntax, play argument validation, registration, role loading, inventory, collection and role installation |
| [Plugins and extensions](references/plugins-and-extensions.md) | Removed APIs, vars and lookup plugins, action plugins, pipelining, callbacks, plugin configuration and secrets |
| [Testing, runtime support, and security](references/testing-runtime-and-security.md) | Runtime requirements, maintenance, integration and sanity tests, managed remotes, URL masking, password hashing |
## Breaking changes and deprecations
### Runtime prerequisites
2.19 requires Jinja2 3.1 or later on the controller and enforces the PowerShell
5.1 minimum at runtime. 2.20 adds Python 3.14 support and raises the minimums
to Python 3.12 on controllers and Python 3.9 on targets. The 2.21 line requires
setuptools 77.0.3 or later.
### Template trust and conditional types
2.19 evaluates template strings only when tagged as trusted. Plugins must apply
or preserve trust; `allow_unsafe_lookups` is ignored. Rewrite nested templates
as single expressions. Remove delimiters from conditions unless a whole-value
template resolves to a trusted literal expression string.
Non-boolean conditions are errors by default in 2.19.
`ALLOW_BROKEN_CONDITIONALS` downgrades those errors to deprecation warnings
and treats literal null or empty-string conditions as true.
### Null, omitted, and undefined values
A single native expression can produce `None` in 2.19;
`DEFAULT_NULL_REPRESENTATION` is ignored. From 2.19.1, null nodes within a
multi-node template render as empty text, and a module argument declared as
`str` receives an empty string for `None`.
2.19 removes `omit` from parent containers as soon as they are templated.
Reapply it at the task argument:
```yaml
mode: "{{ item.mode | default(omit) }}"
```
Plugins calling `Templar.template()` must catch `AnsibleValueOmittedError`
when the entire result is omitted. Serialization fails if unresolved `omit`
sentinels remain. `DEFAULT_UNDEFINED_VAR_BEHAVIOR` is ignored; the templating
reference covers undefined propagation and custom plugin marker handling.
### Removed connection and extension interfaces
In 2.20, replace `DEFAULT_TRANSPORT=smart` with an explicit transport such as
`ssh`, and remove `PARAMIKO_HOST_KEY_AUTO_ADD` and `PARAMIKO_LOOK_FOR_KEYS`.
By 2.21.2, the Paramiko plugin and `ansible.module_utils.compat.paramiko` have
been removed; `connection: smart` and `connection: persistent` no longer
fall back to Paramiko.
2.20 removes the legacy `get_host_vars` and `get_group_vars` fallback.
In custom vars plugins, inherit from `BaseVarsPlugin` and implement
`get_vars`. Use the `vars` and `varnames` lookups for playbook access, as the
internal variable cache is scheduled for removal in 2.24.
Remove the `required` argument to `get_bin_path`, imports of `safe_eval` from
module utilities, the `auto_legacy` interpreter modes, and the `git` module's
`gpg_whitelist` alias. See the plugins reference for module utility migrations.
### Task syntax and managed text
2.19 deprecates empty task `args:`, combining `key=value` arguments with
`args` on the same task, and mapping-valued `action`. Explicit command
arguments can use `ansible.builtin.command: {cmd: /usr/bin/true}`.
Set a regular `ansible_managed` variable in inventory or play variables to
migrate off deprecated `DEFAULT_MANAGED_STR`. It controls the text used by
both the template action and lookup.
### Fact injection and repository migration
2.20 deprecates the true default for `INJECT_FACTS_AS_VARS` and schedules a
switch to false by 2.24. Migrate `ansible_os_family` to
`ansible_facts['os_family']`.
`apt_key` and `apt_repository` are deprecated in favor of `deb822_repository`,
which accepts `include` and `exclude`. In 2.20, remove `install_repoquery`
from `dnf` and `dnf5` tasks and `keepcache` from `yum_repository` tasks.
### Vaulted YAML and explicit failure
`to_yaml` and `to_nice_yaml` again decrypt vaulted values when rendering by
default, so output can contain plaintext secrets. Use `vault_behavior` to
control rendering.
Use `fail_json()` in modules or return `failed: true` from actions to report
failure explicitly. Inferring failure from a nonzero `rc` when `failed` is
absent is scheduled for deprecation in 2.22.
### Strategy and callback deprecations
2.19 deprecates strategy plugins outside `ansible.builtin`, ends their
backward-compatibility guarantees, and plans to remove support in a future
release. The `tree` and `oneline` callback documentation marks both plugins
as deprecated.
## Frequently used features and behavior
### Register projections and current results
In 2.21, `register` can map variable names to Jinja expressions. Projections
can reference other projections in the same task regardless of declaration order.
```yaml
- ansible.builtin.command: /usr/bin/uptime
register:
uptime_line: _task.result.stdout
```
Use `_task.result` in `register` or a task conditional such as `failed_when`.
In loops it refers to the latest completed item; `_task.loop_result` exposes
accumulated results. `_task.polymorphic_result` switches from the latest item
to the final aggregate once the loop completes.
### Conditional and role-loading failures
Errors evaluating task conditions such as `when`, `until`, or `failed_when`
produce descriptive task failures, preserve the task result, and can be handled
with `ignore_errors`. A failure in `break_when` also preserves the loop
structure and completed item results.
A templated `ignore_errors` or `ignore_unreachable` that evaluates to true
for any loop item applies to the whole task. Invalid `ignore_errors` values
are treated as false.
`include_role` has a `rescuable` option to choose between task failure and a
syntax error for role-loading failures. Missing `tasks_from` reports a task
failure that can be handled in the play.
### Play argument validation: tech preview
2.20 adds the tech-preview play keyword `validate_argspec`. It accepts a spec
name or `true` to use the play's name. Starting in 2.20.5, the validation task
receives the `always` tag only when the play has no tags. The playbooks reference
contains the paired play and argument specification example.
### SSH authentication and PSRP settings
2.19 defaults to `SSH_ASKPASS` for passwords and still allows selecting
`sshpass` explicitly. The controller can start or reuse an agent and load key
contents from `ansible_ssh_private_key`, using
`ansible_ssh_private_key_passphrase` for encrypted keys.
`psrp` defaults to `host` as the Kerberos SPN service component. Set
`ansible_psrp_negotiate_service: WSMAN` in host variables when the target
requires the previous SPN. A PSRP read timeout marks the host unreachable,
so `ignore_unreachable` applies.
### Module options and file handling
2.19 adds `auto_install_module_deps` to `apt` and `dnf5`. In 2.20, set
`install_python_debian: true` on `deb822_repository` to install
`python3-debian` when missing.
Set `armor: false` on `ansible.builtin.slurp` to read a text file without
Base64 encoding and use the returned content directly. `file` and `stat`
report `disk_usage_bytes` for disk space used by the file.
In 2.20, `blockinfile` and `lineinfile` accept an explicit file encoding,
such as `encoding: windows-1252`. `replace` matches decoded Unicode text;
review patterns that depended on byte matching.
### Galaxy installation compatibility
`ansible-galaxy install` and `ansible-galaxy collection install` or `download`
exclude collection versions whose `requires_ansible` is incompatible with the running
core by default. Set `COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH` to `ignore`
to allow those versions. 2.20 removes the v2 Galaxy server API; collection
servers must support v3.
The playbooks reference includes collection name and path checks, truncated
download retries, and collection and role installation path validation.
### Secret masking and test diagnostics
In 2.21.5, `ansible-test sanity --test validate-modules` accepts `secret` in
plugin option documentation. Masking the option value in output takes effect
in ansible-core 2.22 and later.
In 2.21.2, a deadline configured with `ansible-test env --timeout` causes
thread stacks to be dumped as the deadline approaches. The testing reference
also covers managed remotes, target filtering, URL credential masking, and
system password hashing fixes.