Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Blog for V4 modules #539

Open
wants to merge 4 commits into
base: release/2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions examples/Volume_groups_v2/volume_groups_disks_v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
# Summary:
# This playbook will do:
# 1. Create disks
# 2. Create disk from previously created vdisk
# 3. Delete disk

- name: Volume groups disks playbook
hosts: localhost
gather_facts: false
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <pc_ip>
nutanix_username: <user>
nutanix_password: <pass>
validate_certs: false
tasks:
- name: Setting Variables
ansible.builtin.set_fact:
vg1_uuid: "d1b1b3b1-1b1b-1b1b-1b1b-1b1b1b1b1b1b1"
disk1_uuid: "12345678-1b1b-1b1b-1b1b-1b1b1b1b1b1b1"
storage_container:
name: "default"
uuid: "00000000-0000-0000-0000-000000000000"

- name: Create disks
nutanix.ncp.ntnx_volume_groups_disks_v2:
state: "present"
volume_group_ext_id: "{{ vg1_uuid }}"
disk_size_bytes: 21474836480
disk_data_source_reference:
entity_type: "STORAGE_CONTAINER"
ext_id: "{{ storage_container.uuid }}"
register: result
ignore_errors: true

- name: Create disk from previously created vdisk
nutanix.ncp.ntnx_volume_groups_disks_v2:
state: "present"
volume_group_ext_id: "{{ vg1_uuid }}"
index: 2
description: "ansible-created-disk-updated"
disk_storage_features:
flash_mode:
is_enabled: true
disk_data_source_reference:
entity_type: "VOLUME_DISK"

Check warning on line 47 in examples/Volume_groups_v2/volume_groups_disks_v2.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{disk1_uuid}} -> {{ disk1_uuid }}
ext_id: "{{disk1_uuid}}"
register: result
ignore_errors: true

- name: Delete disk
nutanix.ncp.ntnx_volume_groups_disks_v2:
state: absent
volume_group_ext_id: "{{ vg1_uuid }}"
ext_id: "{{ result.ext_id }}"
register: result
47 changes: 47 additions & 0 deletions examples/Volume_groups_v2/volume_groups_iscsi_clients_v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
# Summary:
# This playbook will do:
# 1. Attach iscsi client to VG using initiator name
# 2. List all clients attached to VG
# 3. Fetch specific client
# 4. Detach client from VG

- name: Volume groups iscsi clients playbook
hosts: localhost
gather_facts: false
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <pc_ip>
nutanix_username: <user>
nutanix_password: <pass>
validate_certs: false
tasks:
- name: Setting Variables
ansible.builtin.set_fact:
vg1_uuid: "d1b1b3b1-1b1b-1b1b-1b1b-1b1b1b1b1b1b1"
iscsi_client_name: "test-iscsi-client"
iscsi_client_uuid: "12345678-1b1b-1b1b-1b1b-1b1b1b1b1b1b1"

- name: Attach iscsi client to VG using initiator name
nutanix.ncp.ntnx_volume_groups_iscsi_clients_v2:
volume_group_ext_id: "{{ vg1_uuid }}"
iscsi_initiator_name: "{{ iscsi_client_name }}"
num_virtual_targets: 32
register: result

- name: List all clients attached to VG
nutanix.ncp.ntnx_volume_groups_iscsi_clients_info_v2:
volume_group_ext_id: "{{ vg1_uuid }}"
register: result

- name: Fetch specific client
nutanix.ncp.ntnx_volume_groups_iscsi_clients_info_v2:
ext_id: "{{ iscsi_client_uuid }}"
register: result

- name: Detach client from VG
nutanix.ncp.ntnx_volume_groups_iscsi_clients_v2:
volume_group_ext_id: "{{ vg1_uuid }}"
ext_id: "{{ iscsi_client_uuid }}"
state: absent
register: result
60 changes: 60 additions & 0 deletions examples/Volume_groups_v2/volume_groups_v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
# Summary:
# This playbook will do:
# 1. Create Volume group
# 2. Fetch above created VG
# 3. Fetch all VGs using filters
# 4. Delete Volume group

- name: Volume groups playbook
hosts: localhost
gather_facts: false
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <pc_ip>
nutanix_username: <user>
nutanix_password: <pass>
validate_certs: false
tasks:
- name: Setting Variables
ansible.builtin.set_fact:
name: "vg1"

Check failure on line 21 in examples/Volume_groups_v2/volume_groups_v2.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

var-naming[no-reserved]

Variables names must not be Ansible reserved names. (name) (set_fact: name)
cluster_reference: "00057b8b-1b1b-1b1b-1b1b-1b1b1b1b1b1b1"
vg1_uuid: "d1b1b3b1-1b1b-1b1b-1b1b-1b1b1b1b1b1b"

- name: Create Volume group
nutanix.ncp.ntnx_volume_groups_v2:
name: "{{ name }}"
description: "Volume group description"
should_load_balance_vm_attachments: true
sharing_status: "SHARED"
target_prefix: "vg1"
cluster_reference: "{{ cluster_reference }}"
usage_type: "USER"
storage_features:
flash_mode:
is_enabled: true
iscsi_features:
target_secret: "Secret1234567"
enabled_authentications: "CHAP"
register: result
ignore_errors: true

- name: Fetch above created VG
nutanix.ncp.ntnx_volume_groups_info_v2:
ext_id: "{{ vg1_uuid }}"
register: result
ignore_errors: true

- name: Fetch all VGs using filters
nutanix.ncp.ntnx_volume_groups_info_v2:
filter: "startswith(name, '{{name}}')"

Check warning on line 51 in examples/Volume_groups_v2/volume_groups_v2.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: startswith(name, '{{name}}') -> startswith(name, '{{ name }}')
register: result
ignore_errors: true

- name: Delete Volume group
nutanix.ncp.ntnx_volume_groups_v2:
state: absent
ext_id: "{{ vg1_uuid }}"
register: result
ignore_errors: true
35 changes: 35 additions & 0 deletions examples/Volume_groups_v2/volume_groups_vms_v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# Summary:
# This playbook will do:
# 1. Attach VM to Volume Group
# 2. Detach VM from Volume Group

- name: Volume groups vms playbook
hosts: localhost
gather_facts: false
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <pc_ip>
nutanix_username: <user>
nutanix_password: <pass>
validate_certs: false
tasks:
- name: Setting Variables
ansible.builtin.set_fact:
vg1_uuid: "f4b1b3b4-4b1b-4b1b-4b1b-4b1b4b1b4b1b"
vm1_uuid: "a1b2c3d4-e5f6-7g8h-9i0j-k1l2m3n4o5p6"

- name: Attach VM1 to VG
nutanix.ncp.ntnx_volume_groups_vms_v2:
state: present
volume_group_ext_id: "{{ vg1_uuid }}"
ext_id: "{{ vm1_uuid }}"
index: 1
register: result

- name: Detach VM1 from VG
nutanix.ncp.ntnx_volume_groups_vms_v2:
state: absent
volume_group_ext_id: "{{ vg1_uuid }}"
ext_id: "{{ vm1_uuid }}"
register: result
61 changes: 61 additions & 0 deletions examples/categories_v2/categories_v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
# Summary:
# This playbook will do:
# 1. Create a category key & value
# 2. Update the category value and description
# 3. List all categories
# 4. Fetch category using ext id & expand detailedAssociations
# 5. Delete Created category

- name: Categories playbook
hosts: localhost
gather_facts: false
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <pc_ip>
nutanix_username: <user>
nutanix_password: <pass>
validate_certs: false
tasks:
- name: Setting Variables
ansible.builtin.set_fact:
key1: "ansible_category_key"
value1: "ansible_category_value"
value2: "ansible_category_value_updated"
category_ext_id: "11223344-1234-1111-2222-6788222f17b8"

- name: Create category key & value
nutanix.ncp.ntnx_categories_v2:
key: "{{key1}}"

Check warning on line 29 in examples/categories_v2/categories_v2.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{key1}} -> {{ key1 }}

Check warning on line 29 in examples/categories_v2/categories_v2.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{value1}} -> {{ value1 }}
value: "{{value1}}"
description: "ansible test"
register: output
ignore_errors: true

- name: Update category value and description
nutanix.ncp.ntnx_categories_v2:
ext_id: "{{category_ext_id}}"

Check warning on line 37 in examples/categories_v2/categories_v2.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{category_ext_id}} -> {{ category_ext_id }}

Check warning on line 37 in examples/categories_v2/categories_v2.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{key1}} -> {{ key1 }}

Check warning on line 37 in examples/categories_v2/categories_v2.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{value2}} -> {{ value2 }}
key: "{{key1}}"
value: "{{value2}}"
description: "ansible test New value"
register: result
ignore_errors: true

- name: List all categories
nutanix.ncp.ntnx_categories_info_v2:
register: result
ignore_errors: true

- name: Fetch category using ext id & expand detailedAssociations
nutanix.ncp.ntnx_categories_info_v2:
ext_id: "{{category_ext_id}}"

Check warning on line 51 in examples/categories_v2/categories_v2.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{category_ext_id}} -> {{ category_ext_id }}
expand: detailedAssociations
register: result
ignore_errors: true

- name: Delete Created category
nutanix.ncp.ntnx_categories_v2:
ext_id: "{{category_ext_id}}"

Check warning on line 58 in examples/categories_v2/categories_v2.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{category_ext_id}} -> {{ category_ext_id }}
state: absent
register: result
ignore_errors: true
Loading
Loading