A role that runs `include_tasks` in a loop over 3,000 firewall rules takes 40 minutes
AdvancedTroubleshootingVault, Performance and Execution Behaviour
Answer
Likely causes → Each loop iteration of include_tasks is processed per host: templating, a task object for each item, and a separate module run with its own SSH round trip. With thousands of items, the overhead dominates.
Fix → Push the loop down to the target:
- Template a full ruleset file (
nftables.conf, iptables-restore format) once, and apply it with a handler. - Use modules that accept lists, such as
packagewith a list of names. - If you must loop, loop over a module directly instead of over
include_tasks.
Prevent → Profile with profile_tasks, and treat any task with more than a few hundred iterations as a sign the design needs to change.
More on Vault, Performance and Execution Behaviour
`ERROR! Attempting to decrypt but no vault secrets found`Beginner`ERROR! Decryption failed (no vault secrets were found that could decrypt) on inventories/prod/group_vars/all/vault.yml`BeginnerBoth `--vault-id [email protected]` and `--vault-id prod@prompt` are passed, and prod files still fail to decryptIntermediate`Vault format unhexlify error: Odd-length string` after pasting an `encrypt_string` valueIntermediate`Problem running vault password script /home/ci/.vault_pass ([Errno 8] Exec format error). If this is not a script, remove the executable bit from the file.`AdvancedEvery change to `vault.yml` produces an unreadable diff and constant merge conflictsIntermediate