Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
---
- name: Delete Nutanix Files File Server
hosts: localhost
connection: local
gather_facts: no
vars_files:
- ./login.yml
- ./login-ad.yml
vars:
fs_name: "test-fs-01"
tasks:
- name: Nutanix Files - Get File Server Info
uri:
url: "https://{{ prism_address }}:9440/PrismGateway/services/rest/v1/vfilers/?filterCriteria=Name&searchString={{ fs_name }}"
method: GET
user: "{{ prism_username }}"
password: "{{ prism_password }}"
force_basic_auth: yes
validate_certs: "{{ validate_tls_certs }}"
status_code: 200
register: nutanix_file_server
- name: Get File Server UUID
set_fact:
fs_uuid: "{{ nutanix_file_server.json.entities[0].uuid }}"
- name: Nutanix Files - Delete FSVM DNS Records
uri:
url: "https://{{ prism_address }}:9440/PrismGateway/services/rest/v1/vfilers/{{ fs_uuid }}/removeDns"
method: POST
user: "{{ prism_username }}"
password: "{{ prism_password }}"
body_format: json
force_basic_auth: yes
validate_certs: "{{ validate_tls_certs }}"
body:
dnsOpType: "MS_DNS"
dnsUserName: "{{ fs_admin_ad_user_name }}"
dnsPassword: "{{ fs_admin_ad_user_pass }}"
status_code: 200
ignore_errors: yes
register: nutanix_task
- name: Check Nutanix Task
uri:
url: "https://{{ prism_address }}:9440/api/nutanix/v2.0/tasks/{{ nutanix_task.json.taskUuid }}"
method: GET
user: "{{ prism_username }}"
password: "{{ prism_password }}"
force_basic_auth: yes
validate_certs: "{{ validate_tls_certs }}"
status_code: 200
register: nutanix_task_info
until: nutanix_task_info.json.progress_status == "Succeeded"
delay: 5
retries: 36
when: nutanix_task.status == 200
- name: Nutanix Files - Leave AD Domain
uri:
url: "https://{{ prism_address }}:9440/PrismGateway/services/rest/v1/vfilers/{{ fs_uuid }}/unjoinDomain"
method: POST
user: "{{ prism_username }}"
password: "{{ prism_password }}"
body_format: json
force_basic_auth: yes
validate_certs: "{{ validate_tls_certs }}"
body:
windowsAdUsername: "{{ fs_admin_ad_user_name }}"
windowsAdPassword: "{{ fs_admin_ad_user_pass }}"
status_code: 200
ignore_errors: yes
register: nutanix_task
- name: Check Nutanix Task
uri:
url: "https://{{ prism_address }}:9440/api/nutanix/v2.0/tasks/{{ nutanix_task.json.taskUuid }}"
method: GET
user: "{{ prism_username }}"
password: "{{ prism_password }}"
force_basic_auth: yes
validate_certs: "{{ validate_tls_certs }}"
status_code: 200
register: nutanix_task_info
until: nutanix_task_info.json.progress_status == "Succeeded"
delay: 5
retries: 36
when: nutanix_task.status == 200
- name: Nutanix Files - Delete File Server
uri:
url: "https://{{ prism_address }}:9440/PrismGateway/services/rest/v1/vfilers/{{ fs_uuid }}?deletePdAndSnapshots=true&deleteContainer=true"
method: DELETE
user: "{{ prism_username }}"
password: "{{ prism_password }}"
force_basic_auth: yes
validate_certs: "{{ validate_tls_certs }}"
status_code: 200
register: nutanix_task
- name: Check Nutanix Task
uri:
url: "https://{{ prism_address }}:9440/api/nutanix/v2.0/tasks/{{ nutanix_task.json.taskUuid }}"
method: GET
user: "{{ prism_username }}"
password: "{{ prism_password }}"
force_basic_auth: yes
validate_certs: "{{ validate_tls_certs }}"
status_code: 200
register: nutanix_task_info
until: nutanix_task_info.json.progress_status == "Succeeded"
delay: 5
retries: 36
@gowatana

This comment has been minimized.

Copy link
Owner Author

@gowatana gowatana commented Aug 9, 2021

下記の投稿むけ。

Nutanix CE に Nutanix Files を展開する。(Ansible 編)
https://blog.ntnx.jp/entry/2021/08/08/172226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment