Recently, I have been asked many times how Ansible can help maintain a naming convention when creating volumes, so today I will show a quick example of variable building.

Let’s say I want my volume name to be <vserver>_<aggr>_<volume name>, and I have the following variables set in a playbook.

vserver: vserver1
aggr: aggr1
vol: vol1

I can join the variables to create the desired volume name using the name parameter of the na_ontap_volume module.

name: “{{ vserver }}_{{ aggr }}_{{ vol }}”

Now any time I use a playbook with these entries, my volume will always be named along the lines of my naming convention.  Anything in my “” contained in {{}} will replace with a variable, and anything outside the {{}}s will be a literal string.

Try out your own combinations and see how you can build up any naming convention you use.  As usual join me on Slack if you have any questions about this or any other Ansible issues to discuss.

About David Blackwell

David is a twenty year IT veteran who has been an admin for just about every aspect of a DataCenter at one time or another. When not working, or tinkering with new software at home, David spends most of his free time with his six year old son and his lovely wife.

Pin It on Pinterest