Monday, October 31, 2022

How to automate the deletion of NSX components with Ansible (2)

 Hereunder I delete several LSWs in one playbook


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/segments/
  tasks:
  - name: DEV NSX-T delete all the LSWs for the bridged LSWs
    uri:
      url: "{{ host.dev[0] }}LSW-DCE-{{ item }}b-01"
      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:
      - 121
      - 141
      - 142
   loop_control:
        pause: 2



root@dcex1510ctrl001:~# cat /root/ansible/hosts/hostsNsx.ini
[nsxtdev]
dcea-ptdnsxmgrvip

then we will execute it 

ansible-playbook -i /root/ansible/hosts/hostsNsx.ini /root/ansible/playbooks/nsx-delete-bridges.yaml

























































No comments:

Post a Comment

NSX-T (local log in) with VIDM integration

We will explain how to log in with a local account to your NSX-T which integrated with VIDM. We integrated our NSX-T into the VIDM. We had a...