DEV Community

Cover image for I built a tiny zsh plugin to make Ansible tag selection less annoying
Alexis Zamanidis
Alexis Zamanidis

Posted on

I built a tiny zsh plugin to make Ansible tag selection less annoying

I’ve been working with Ansible for a while now, and one of the small things that keeps bothering me is tag management.

zsh-ansible-fzf interactive demo

You know the workflow:

ansible-playbook -t <TAB>
Enter fullscreen mode Exit fullscreen mode

Then you start typing tag names manually, trying to remember whether the tag was zsh, nvim, docker, base, or something else. If your playbooks are a bit larger, it gets repetitive fast.

I wanted something simpler.

So I built a tiny zsh plugin called zsh-ansible-fzf.

It reads tags from your Ansible playbooks and turns them into shell completions. That means instead of remembering tag names or digging through YAML files, I can just type a few letters and let zsh help me finish the job.

What it does

The plugin looks for tags in your playbooks and offers them as completions for commands like:

ansible-playbook -t <TAB>
ansible-playbook --tags <TAB>
ansible-playbook --skip-tags <TAB>
Enter fullscreen mode Exit fullscreen mode

It also supports prefix filtering, so if I type:

ansible-playbook -t zs<TAB>
Enter fullscreen mode Exit fullscreen mode

it narrows the list to relevant tags, and I can keep going from there.

It also works nicely with fzf-tab if you already use it, which makes the selection feel even smoother.

Why I like it

Honestly, this is one of those tools that feels small, but it saves time in a very real way.

A lot of the time, Ansible workflows are not about “big architecture” or complex automation. They’re about everyday commands that get repeated again and again:

  • run only a subset of tasks
  • test one feature
  • skip a heavy role
  • validate a configuration change

When you have a long list of tags, typing them out manually is just friction. This plugin removes that friction.

It’s not a huge project, and it doesn’t try to reinvent anything. It just makes a common task feel a little less annoying.

Example

A playbook might define tags like this:

- hosts: all
  tags: [zsh, nvim, docker]
  tasks:
    - name: Install zsh
      apt:
        name: zsh
Enter fullscreen mode Exit fullscreen mode

Then I can do:

ansible-playbook -t zsh,<TAB>
Enter fullscreen mode Exit fullscreen mode

and keep building my tag list without needing to remember everything by heart.

zsh-ansible-fzf demo

The plugin even avoids already-selected tags and can add a trailing comma so you can continue selecting more tags quickly.

Installation

The setup is straightforward if you use Oh My Zsh.

You add the plugin to your plugins list before fzf-tab:

plugins=(... zsh-ansible-fzf fzf-tab)
Enter fullscreen mode Exit fullscreen mode

Then reload your shell:

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

There’s also an install script included in the project if you want the easier path.

Extra configuration

The plugin is pretty lightweight, but it also has a few useful settings.

For example, you can define a fallback directory:

export ZSH_ANSIBLE_FZF_FALLBACK_DIR="$HOME/ansible"
Enter fullscreen mode Exit fullscreen mode

Or add tags that should always be available:

export ZSH_ANSIBLE_FZF_SPECIAL_TAGS="all tagged untagged always never"
Enter fullscreen mode Exit fullscreen mode

And if you don’t like the trailing comma behavior:

export ZSH_ANSIBLE_FZF_COMMA_SUFFIX=0
Enter fullscreen mode Exit fullscreen mode

The main takeaway

I’m a big believer in tiny tools that improve a developer’s daily flow.

This plugin isn’t trying to solve a massive problem. It just makes one part of the Ansible workflow smoother and less error-prone.

And honestly, that’s often where the best shell tools come from.

If you spend a lot of time in zsh and Ansible, this is a really nice little productivity boost.

You can check it out here:

https://github.com/alexiszamanidis/zsh-ansible-fzf

If you use Ansible from the terminal, I’d be curious to know what sort of shell shortcuts or plugins you already rely on.

Top comments (0)