vagrant-ansible-tags

A Vagrant plugin that adds --tags and --skip-tags options to vagrant provision and vagrant up, so you can pass Ansible tags directly on the command line — no Vagrantfile changes required.

Installation

vagrant plugin install vagrant-ansible-tags

Usage

vagrant provision

# Single tag
vagrant provision server01.example.com --tags firewall

# Multiple tags (comma-separated, no spaces)
vagrant provision server01.example.com --tags firewall,ssh,users

# Skip tags
vagrant provision server01.example.com --skip-tags debug

# Combine both
vagrant provision server01.example.com --tags firewall,ssh --skip-tags debug

# Works alongside other provision options
vagrant provision server01.example.com --tags firewall --provision-with ansible

vagrant up

# Boot and provision with specific tags
vagrant up server01.example.com --tags firewall

# Multiple tags (comma-separated, no spaces)
vagrant up server01.example.com --tags firewall,ssh,users

# Skip tags
vagrant up server01.example.com --skip-tags debug

# Combine both
vagrant up server01.example.com --tags firewall,ssh --skip-tags debug

# Works alongside other up options
vagrant up server01.example.com --tags firewall --provider xenserver

How it works

The plugin does two things:

  1. Extends the provision and up commands to accept --tags and --skip-tags arguments.
  2. Injects the tags into any ansible or ansible_local provisioner configs at runtime via a Vagrant action hook — before the provisioner runs, not at Vagrantfile load time.

This means no Vagrantfile modifications are needed. The plugin works with any provider (XenServer, VirtualBox, VMware, etc.).

Compatibility

  • Vagrant 2.x
  • Ansible provisioner (ansible and ansible_local)

License

MIT