Encrypt, decrypt and edit Ansible Vault secrets
right in the editor: whole vault files and inline !vault | YAML values, with the same configuration as ansible-vault,
including multiple passwords through
vault ids.
- One action for everything: Ctrl+Alt+Shift+A (⌘⌥⇧A on macOS), also in the editor context menu and in Tools
- on a selection: encrypts it, or decrypts it when it is a vault;
- on a
key: valueline: encrypts the value as an inline!vault |; - on a vault: opens it decrypted in an editor.
- Edit vaults in place: a gutter icon on every vault opens it decrypted, side by side;
the text is encrypted back when saved or when the editor is closed, keeping the vault id (like
ansible-vault edit). - Reads your ansible configuration:
ansible.cfgandANSIBLE_*variables, password files and password scripts (also*-clientscripts with vault ids, to get the passwords from a secret manager),promptpasswords saved in the IDE credential store,vault_identity_list,vault_encrypt_identity,vault_id_match. - Shows where the passwords come from: Settings > Tools > AnsiVault Configuration lists the config files searched, the vault settings found and the password source of each vault id.
- Compatible with ansible-vault: vaults written by the plugin are read by ansible and vice versa (
$ANSIBLE_VAULT;1.1and1.2, AES256).
Ansible Vault Encrypt/Decrypt works on the selection, or on the line of the caret when nothing is selected:
| Where | What it does |
|---|---|
| Selection of plain text at the start of the file | encrypts the whole file as a vault |
| Selection of plain text elsewhere | replaces it with an inline !vault | vault, indented to the selection column |
Selection of a vault (with or without its !vault | tag) |
replaces it with the decrypted text |
Caret on a key: value line |
encrypts the value as an inline vault; plain, "double" and 'single' quoted values, trailing # comments are kept |
Caret on a vault, or on its key: !vault | line |
opens the vault editor (see below) |
# before: caret on the line, Ctrl+Alt+Shift+A
db_password: s3cret # the db
# after
db_password: !vault | # the db
$ANSIBLE_VAULT;1.1;AES256
6231653639...The shortcut can be changed in Settings > Keymap (search "Ansible Vault").
Click the AnsiVault icon in the gutter of a vault (or run the action with the caret on it): the vault opens decrypted in an editor, in the right half of the current one by default (Settings > Tools > AnsiVault Configuration to open it left, above, below or in a new tab).
- the tab is named after the file and the YAML key path, e.g.
[AnsiVault] vars.yml: db.credentials.password; - a whole file vault is edited with the type of the file (YAML highlighting), an inline vault as plain text;
- saving, or closing the editor, encrypts the text back into the original file if it changed, with the same vault id and the password that opened it;
- if the vault was deleted from the original file in the meantime, the changes cannot be written back and an error is shown.
The plugin reads the vault settings of ansible. The configuration files are searched in this order:
- the file of the
ANSIBLE_CONFIGenvironment variable; - the
ansible.cfgin the project root, or else the shallowest one in the project (up to 5 levels deep, skipping hidden,node_modules,build,target,out,dist,venvdirectories), for layouts like<root>/infrastructure/ansible/ansible.cfg; ~/.ansible.cfg;/etc/ansible/ansible.cfg.
These [defaults] settings are supported, each one overridden by its ANSIBLE_* environment variable:
| Setting | Environment variable | Meaning |
|---|---|---|
vault_password_file |
ANSIBLE_VAULT_PASSWORD_FILE |
file with the vault password |
vault_identity_list |
ANSIBLE_VAULT_IDENTITY_LIST |
several passwords as label@path or label@prompt, e.g. dev@~/.vault_dev, prod@prompt |
vault_identity |
ANSIBLE_VAULT_IDENTITY |
vault id of vault_password_file and of unlabelled sources (default default) |
vault_encrypt_identity |
ANSIBLE_VAULT_ENCRYPT_IDENTITY |
vault id used to encrypt when there are several |
vault_id_match |
ANSIBLE_VAULT_ID_MATCH |
decrypt a vault only with the password of its own vault id |
Relative password file paths are resolved against the directory of the ansible.cfg that defines them, ~ against the home directory.
# ansible.cfg
[defaults]
vault_identity_list = dev@vault-pass/dev.txt, prod@prompt
vault_encrypt_identity = devPasswords. For each vault id the password is read from its file; prompt passwords (and the password asked when nothing
is configured) are requested once, in a single dialog, and saved in the IDE credential store. To decrypt, the password of the
vault's own vault id is used first, then the others are tried (only its own with vault_id_match), asking them only when
needed; to encrypt, only the password of the encrypt vault id is needed.
Password scripts. An executable password file is run, like ansible does, and its output is the password: the passwords can come from a secret manager without being stored on the computer.
- a script whose name (without extension) ends in
-clientis run asscript --vault-id <id>: one script for all the vault ids; it exits with code2when it has no password for that vault id; - any other script is run without arguments;
- the password is the whole standard output, without leading and trailing line breaks: messages go to standard error;
- the script runs in the directory of the
ansible.cfgthat defines it, with the environment of your login shell; - it is run with a cancellable progress (it can wait for you to unlock the secret manager) and stopped after 2 minutes;
- a password from a script is never saved: if the script fails, the error is shown, nothing is asked;
- scripts are run only in trusted projects.
A plain script gives the password of one vault id:
#!/bin/sh
# vault-pass/password.sh, used as: vault_password_file = vault-pass/password.sh
exec my-secret-manager get "ansible-vault" # prints the passwordA client script gives the passwords of all the vault ids:
#!/bin/sh
# vault-pass/secrets-client.sh, used as: vault_identity_list = dev@vault-pass/secrets-client.sh, prod@vault-pass/secrets-client.sh
[ "$1" = "--vault-id" ] || exit 1
exec my-secret-manager get "ansible-vault/$2" # prints the password of the vault id; exits with 2 if there is noneThe playground has a working example of both (vault-pass/stage.sh and vault-pass/secrets-client.sh).
Vault ids. Vaults encrypted with the default vault id are written as $ANSIBLE_VAULT;1.1;AES256, any other vault id as
$ANSIBLE_VAULT;1.2;AES256;<vault id>. With several vault ids the one used to encrypt comes from the project setting
(Settings > Tools > AnsiVault Configuration), else vault_encrypt_identity.
Settings > Tools > AnsiVault Configuration:
- Forget Saved Passwords: removes the passwords of the project saved in the IDE credential store; they are asked again when needed;
- Vault id used to encrypt: overrides
vault_encrypt_identityfor this project; - Where to open the vault editor: right, left, upper or bottom half of the editor, or a new tab;
- Where the vault passwords come from: a tree with the configuration files in search order (found or not, which one is used), the vault settings and where each one is defined (file or environment variable), the password source of each vault id (file, missing file, saved or to be asked) and the vault id used to encrypt. Select a vault id with a saved password and Forget Password of Selected Vault Id to forget only that one. Problems are marked with a warning.
- "No vault password could decrypt vault id ...": the password of that vault id is wrong. If it is the one saved by the plugin you are offered to forget it and type it again; if it comes from a file, check the file shown in the settings tree.
- "Multiple vault ids (...): choose the one to encrypt with": set
vault_encrypt_identity, or the vault id in the settings. - Environment variables are ignored: the IDE sees the environment it was started with. On macOS an IDE started from the Dock
does not get the variables of your shell: start it from a terminal, or put the settings in
ansible.cfg. - A password script fails in the IDE but works in a terminal: the script runs without a terminal. If it needs to unlock a secret manager, configure the manager to ask with a graphical prompt, or unlock it in a terminal first. The error notification shows the exit code and the standard error of the script.
- "Vault password scripts are not run in untrusted projects": trust the project, from the Safe Mode banner or by adding its directory in Settings > Build, Execution, Deployment > Trusted Locations.
- "... exited but its output is still open": a process the script starts in background (e.g. an agent) inherits its output;
start it with its output redirected (
> /dev/null 2>&1). - "Cannot access native keychain" on Linux: the IDE credential store needs
libsecret(e.g.sudo apt-get install libsecret-1-0 gnome-keyring); without it the passwords are kept only until the IDE is closed. - The settings tree is the place to start: it shows exactly what the plugin reads and from where.
- A password file that is itself encrypted with ansible-vault is not supported.
- Password scripts are run through the operating system: on Windows a shell script needs an interpreter associated with it.
- Ansible reads only the first configuration file found; the plugin looks for each setting in the next files too.
- Only the
AES256cipher (the one used by every ansible version since 2.0) is supported.
-
Using the IDE built-in plugin system:
Settings/Preferences > Plugins > Marketplace > Search for "ansivault" > Install
-
Using JetBrains Marketplace:
Go to JetBrains Marketplace and install it by clicking the Install to ... button in case your IDE is running.
You can also download the latest release from JetBrains Marketplace and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...
-
Manually:
Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...
IntelliJ-based IDEs 2024.3 to 2026.3 (build 243 to 263.*), verified with the IntelliJ Plugin Verifier.
./gradlew check # tests; the ansible-vault compatibility tests run when ansible-vault is installed
./gradlew buildPlugin # build/distributions/ansivault-<version>.zip
./gradlew runIde # an IDE with the plugin
./gradlew verifyPlugin # IntelliJ Plugin Verifier on the recommended IDEs
./gradlew verifyPlugin -PverifyIde=IU:2026.3 # on one IDE onlyThe playground directory is a small ansible project to try every feature of the plugin by hand,
with a checklist of what to test.
See the changelog for the changes of each version.
Plugin based on the IntelliJ Platform Plugin Template.