Preloader
Others
  • Estimated reading time: 1 Minute

How to edit the Ansible Vault using Nano

How to edit the Ansible Vault using Nano

In the last few weeks, I've been using Ansible to automate a few tasks on a couple of servers and found the tool extremely useful. One of the tasks required the implementation of the Ansible Vault since it was necessary to create some files on the servers that contained some credentials. Since storing secrets in plain text files poses a significant security risk, Ansible Vault is used to secure sensitive data within an Ansible project. 

Ansible Vault allows you to encrypt stuff like:

  • Whole files (like group_vars/all.yml)
  • Specific variables inside YAML
  • Even binary files (like private keys)

This way, you can safely commit them to version control (e.g., GitHub, GitLab) without exposing secrets.

Editing an Ansible Vault file with nano

By default, Ansible Vault uses vim or vi as the editor when you run commands like:

ansible-vault create secrets.yml

ansible-vault edit secrets.yml

However, you don't have to stick with Vim to modify those files. Ansible uses whatever you have set in the $EDITOR environment variable, so, for example, if you want to use Nano as your editor when using ansible-vault, you may instruct Ansible to do so during its usage with:

env EDITOR=nano ansible-vault edit secrets.yaml

This will work only with the current commands since we override the editor only in this instruction. If you want to make it permanent, add it to ~/.bashrc or ~/.zshrc (depending on your favorite shell), for example, for bash:

echo 'export EDITOR=nano' >> ~/.bashrc'

source ~/.bashrc

In this way, nano will be used whenever you run ansible-vault:

ansible-vault edit secrets.yml

Happy coding ❤️!

Related articles
Effective Shared Scheduling: Managing Permissions and Updates
27 Oct, 2026
  • Estimated reading time: 4 Minutes
Dedicated Mobile Proxy: When It's Worth It (2026)
27 Oct, 2026
  • Estimated reading time: 5 Minutes
Why Should You Choose Custom Software for Your Business?
27 Oct, 2026
  • Estimated reading time: 4 Minutes
TokenPulse Opens Singapore APAC Operating Hub
27 Oct, 2026
  • Estimated reading time: 5 Minutes
SaaS Marketing Strategies to Strengthen Your Pipeline in 2027
27 Oct, 2026
  • Estimated reading time: 8 Minutes
Best IPTV Subscription UK 2026: Complete Guide to Quality Streaming
27 Oct, 2026
  • Estimated reading time: 12 Minutes
Weekly trending
Effective Shared Scheduling: Managing Permissions and Updates
27 Oct, 2026
  • Estimated reading time: 4 Minutes
Dedicated Mobile Proxy: When It's Worth It (2026)
27 Oct, 2026
  • Estimated reading time: 5 Minutes
Why Should You Choose Custom Software for Your Business?
27 Oct, 2026
  • Estimated reading time: 4 Minutes
TokenPulse Opens Singapore APAC Operating Hub
27 Oct, 2026
  • Estimated reading time: 5 Minutes
SaaS Marketing Strategies to Strengthen Your Pipeline in 2027
27 Oct, 2026
  • Estimated reading time: 8 Minutes
Our Sponsors

Our blog is proudly supported by industry-leading sponsors.