• Zach Biles

Variables in Ansible

This will be a short post today, feeling pretty dumb. Just learned the hard way that Ansible variable names can not start with numbers. It even says so in the first line of the documentation on variables: https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#creating-valid-variable-names


You'll get some pretty weird output if you try and start them with numbers. Basically it parses the number as an integer, which removes it from the jinja templating, so a variable like this: `1variable` would end up templated like `variable`, which of course probably doesn't exist. You might also get errors about jinja templating, and not including brackets {{ }}. Errors were pretty nondescript.


Learn from my mistakes, don't do this! Hopefully this helps someone scratching their head for an hour like I did.

Recent Posts

See All

Linux Patching with Ansible

Today I ran into an issue building a patching playbook for my Linux VMs. I have a mix of Ubuntu, and a couple of CentOS versions. I began with testing against Ubuntu and CentOS 8, and everything worke

LINKS
ABOUT

info@sisulink.com

Inside TechTank

3709 1st Ave

Hibbing, MN 55746, USA

SOCIAL
  • sisuLink on Facebook!

© 2020 sisuLink.