Hereunder I delete the LSW, SG and a Firewall policy with Ansible Playbook.
Note: the LSW is a member in the SG , and the SG is a member in the FWP , so it has to be done in this order: delete the FW policy then the SG then the LSW
root@dcex1510ctrl001:~# cat ansible/hosts/hostsNsx.ini
[nsxtdev]
dcea-ptdnsxmgrvip.test.local
root@dcex1510ctrl001:~# cat ansible/playbooks/nsx-delete-bridges.yaml
- hosts: nsxtdev
connection: local
gather_facts: false
vars:
host:
dev:
- https://dcea-ptdnsxmgrvip/policy/api/v1/infra/
tasks:
- name: DEV NSX-T Delete the unneeded components
uri:
url: "{{ host.dev[0] }}{{ item }}"
force_basic_auth: yes
validate_certs: no
headers:
Accept: "application/json"
Content-Type: "application/json"
user: USERNAME
password: PASSWORD
method: DELETE
status_code: "200"
body_format: json
with_items:
- domains/default/security-policies/FWP-VPC-122v
- domains/default/groups/SG-LSW-DCE-122v
- segments/LSW-DCE-122v-01
loop_control:
pause: 5
root@dcex1510ctrl001:~# ansible-playbook -i /root/ansible/hosts/hostsNsx.ini /root/ansible/playbooks/nsx-delete-bridges.yaml
No comments:
Post a Comment