#Ansible project structure feedback
1 messages · Page 1 of 1 (latest)
I follow this, and essentially create an ansible collection for my ontap stuff. It makes development really easy as you can build vscode dev containers with all of the required modules, and if you need to call this collection from other places, you just load the collection and it should evaluate the build requirements automatically https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.5/html/developing_automation_content/installing-devtools
Chapter 3. Installing Ansible development tools | Red Hat Documentation
As I've learned it, ONTAP clusters are defined in yml/yaml var files. Not inventory because the playbooks always run on localhost performing ZAPI/Rest API calls to the cluster(s).
How it's organised depends on how you write your playbooks.
For example, I am running a playbook against a var yaml that includes all the variables of a single node of an HA pair. Then the same playbook against a var file of each node. Then when the cluster is created, I have a cluster var file to configure everything else.
Also, to clarify, are you one of the tenants? Or are you the provider? That would also be different. As the owner, you'd probably want something like a version controlled project with a subfolder of each tenant.
If you are one of the tenants, then you'd only interact with the SVM managment LIF and the reduced API-set that has.
That's my snippet. Good luck! 🙂
yup I use that too, vscode rly helps for ansible
I am the provider. Currently I've done smth to declare them still in the inventory file but you can tell ansible to still run locally even if the hostname is "cluster1" for example
I've created roles for each ontap "objects", for example vserver, aggregate etc.
in each role you have a main function that calls a specific yml in the same directory depending on the task
- roles
|- vserver
|- tasks
|- main.yml # the main function only has a line to include_role based on the include_task variable
|- create.yml
|- delete.yml
|- create-peer.yml
for example.
Then in your playbook you'd call each "object" task like this:
- name: create vserver peer
ansible.builtin.include_role:
name: vserver
vars:
include_task: create-peer
we tried to make something more general instead of a subfolder for each tenant, I think this would make things way more complicated as we have around 100 customers