#Ansible project structure feedback

1 messages · Page 1 of 1 (latest)

thorn tusk
#

Hi,

I know there's many ways to use ansible in a project but i'd like to get some feedback about how do you all structure your project/files for ONTAP ?
We currently use netapp in a multi-tenant env and we are going to use ansible to replace WFA.

wild sequoia
#

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

foggy vale
#

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! 🙂

thorn tusk
thorn tusk
#

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