Ansible: Tags are a code smell

Your own code

- name: demo another always-tagged task
msg: I am another always-tagged task
- always
- another-always

Other peoples’ roles

Tags are a smell

What to use instead of tags?

  • Use when conditionals and consider passing extra variables for conditional evaluation during ansible-playbook invocations using the ‘-e’ flag.
  • Write separate playbooks and invoke those, instead of your main playbook, when doing something simple with Ansible like reloading a service. Note that you can include specific tasks when importing an Ansible using the tasks_from argument to an include_role task.
  • Other ideas? Feel free to hit me up!




Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Greg Swallow

Greg Swallow

More from Medium

Cheat Sheet for DevOps: GitHub Actions

Using Handlers with Import and Include statements

Serverless DevOps Tools

My first adventure (and maybe yours) with Microsoft Azure certification paths