--- - debug: msg="START net_interface junos/basic.yaml" - name: setup - remove interface net_interface: name: ge-0/0/1 description: test-interface state: absent provider: "{{ netconf }}" - name: Create interface net_interface: name: ge-0/0/1 description: test-interface state: present provider: "{{ netconf }}" register: result - name: Get running configuration junos_rpc: rpc: get-configuration provider: "{{ netconf }}" register: config - assert: that: - "result.changed == true" - "'ge-0/0/1' in config.xml" - "'test-interface' in config.xml" - name: Create interface (idempotent) net_interface: name: ge-0/0/1 description: test-interface state: present provider: "{{ netconf }}" register: result - assert: that: - "result.changed == false" - name: Configure interface attributes net_interface: name: ge-0/0/1 description: test-interface state: present speed: 1g mtu: 256 duplex: full provider: "{{ netconf }}" register: result - name: Get running configuration junos_rpc: rpc: get-configuration provider: "{{ netconf }}" register: config - assert: that: - "result.changed == true" - "'ge-0/0/1' in config.xml" - "'full-duplex' in config.xml" - "'256' in config.xml" - "'1g' in config.xml" - "'test-interface' in config.xml" - name: Disable interface net_interface: name: ge-0/0/1 description: test-interface state: down provider: "{{ netconf }}" register: result - name: Get running configuration junos_rpc: rpc: get-configuration provider: "{{ netconf }}" register: config - assert: that: - "result.changed == true" - result.diff.prepared | search("\+ *disable") - "'ge-0/0/1' in config.xml" - name: Enable interface net_interface: name: ge-0/0/1 description: test-interface state: up provider: "{{ netconf }}" register: result - name: Get running configuration junos_rpc: rpc: get-configuration provider: "{{ netconf }}" register: config - assert: that: - "result.changed == true" - result.diff.prepared | search("\- *disable") - "'ge-0/0/1' in config.xml" - name: Delete interface net_interface: name: ge-0/0/1 description: test-interface state: absent provider: "{{ netconf }}" register: result - name: Get running configuration junos_rpc: rpc: get-configuration provider: "{{ netconf }}" register: config - assert: that: - "result.changed == true" - "'ge-0/0/1' not in config.xml" - name: Aggregate setup- delete interface ge-0/0/1 net_interface: name: ge-0/0/1 state: absent provider: "{{ netconf }}" register: result - name: Aggregate setup- delete interface ge-0/0/2 net_interface: name: ge-0/0/2 state: absent provider: "{{ netconf }}" register: result - name: Set interface on aggregate net_interface: aggregate: - { name: ge-0/0/1, description: test-interface-1, speed: 1g, duplex: full, mtu: 512} - { name: ge-0/0/2, description: test-interface-2, speed: 10m, duplex: full, mtu: 256} provider: "{{ netconf }}" register: result - assert: that: - 'result.changed == true' - result.diff.prepared | search("\+ *ge-0/0/1") - result.diff.prepared | search("\+ *description test-interface-1") - result.diff.prepared | search("\+ *speed 1g") - result.diff.prepared | search("\+ *mtu 512") - result.diff.prepared | search("\+ *link-mode full-duplex") - result.diff.prepared | search("\+ *description test-interface-2") - result.diff.prepared | search("\+ *speed 10m") - result.diff.prepared | search("\+ * mtu 256") - result.diff.prepared | search("\+ *link-mode full-duplex") - name: Set interface on aggregate (idempotent) net_interface: aggregate: - { name: ge-0/0/1, description: test-interface-1, speed: 1g, duplex: full, mtu: 512} - { name: ge-0/0/2, description: test-interface-2, speed: 10m, duplex: full, mtu: 256} provider: "{{ netconf }}" register: result - assert: that: - 'result.changed == false' - name: Disable interface on aggregate net_interface: aggregate: - { name: ge-0/0/1, description: test-interface-1, speed: 1g, duplex: full, mtu: 512, state: down} - { name: ge-0/0/2, description: test-interface-2, speed: 10m, duplex: full, mtu: 256, state: down} provider: "{{ netconf }}" register: result - assert: that: - 'result.changed == true' - result.diff.prepared | search("\+ *disable") - name: Enable interface on aggregate net_interface: aggregate: - { name: ge-0/0/1, description: test-interface-1, speed: 1g, duplex: full, mtu: 512, state: up} - { name: ge-0/0/2, description: test-interface-2, speed: 10m, duplex: full, mtu: 256, state: up} provider: "{{ netconf }}" register: result - assert: that: - 'result.changed == true' - result.diff.prepared | search("\- *disable") - name: Delete interface on aggregate net_interface: aggregate: - { name: ge-0/0/1, description: test-interface-1, speed: 1g, duplex: full, mtu: 512, state: absent} - { name: ge-0/0/2, description: test-interface-2, speed: 10m, duplex: full, mtu: 256, state: absent} provider: "{{ netconf }}" register: result - assert: that: - 'result.changed == true' - result.diff.prepared | search("\- *ge-0/0/1") - result.diff.prepared | search("\- *description test-interface-1") - result.diff.prepared | search("\- *speed 1g") - result.diff.prepared | search("\- *mtu 512") - result.diff.prepared | search("\- *link-mode full-duplex") - result.diff.prepared | search("\- *description test-interface-2") - result.diff.prepared | search("\- *speed 10m") - result.diff.prepared | search("\- * mtu 256") - result.diff.prepared | search("\- *link-mode full-duplex") - name: Delete interface aggregate (idempotent) net_interface: aggregate: - { name: ge-0/0/1, description: test-interface-1, speed: 1g, duplex: full, mtu: 512, state: absent} - { name: ge-0/0/2, description: test-interface-2, speed: 10m, duplex: full, mtu: 256, state: absent} provider: "{{ netconf }}" register: result - assert: that: - 'result.changed == false'