2017-06-16 18:42:50 +02:00
|
|
|
---
|
|
|
|
- debug: msg="START junos_interface netconf/basic.yaml"
|
|
|
|
|
2017-08-14 06:47:03 +02:00
|
|
|
- name: setup remove interface
|
2017-06-16 18:42:50 +02:00
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/1
|
|
|
|
description: test-interface
|
|
|
|
state: absent
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
|
|
|
|
- name: Create interface
|
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/1
|
|
|
|
description: test-interface
|
|
|
|
state: present
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
2017-06-29 06:48:35 +02:00
|
|
|
- name: Get running configuration
|
|
|
|
junos_rpc:
|
|
|
|
rpc: get-configuration
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: config
|
2017-06-16 18:42:50 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2017-06-29 06:48:35 +02:00
|
|
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
|
|
|
- "'<description>test-interface</description>' in config.xml"
|
2017-06-16 18:42:50 +02:00
|
|
|
|
|
|
|
- name: Create interface (idempotent)
|
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/1
|
|
|
|
description: test-interface
|
|
|
|
state: present
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
|
|
|
- name: Deactivate interface configuration
|
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/1
|
|
|
|
description: test-interface
|
2017-06-29 06:48:35 +02:00
|
|
|
state: present
|
|
|
|
active: False
|
2017-06-16 18:42:50 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
2017-06-29 06:48:35 +02:00
|
|
|
- name: Get running configuration
|
|
|
|
junos_rpc:
|
|
|
|
rpc: get-configuration
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: config
|
|
|
|
|
2017-06-16 18:42:50 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2017-06-29 06:48:35 +02:00
|
|
|
- "'<interface inactive=\"inactive\">' in config.xml"
|
|
|
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
2017-06-16 18:42:50 +02:00
|
|
|
|
|
|
|
- name: Activate interface configuration
|
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/1
|
|
|
|
description: test-interface
|
2017-06-29 06:48:35 +02:00
|
|
|
state: present
|
|
|
|
active: True
|
2017-06-16 18:42:50 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
2017-06-29 06:48:35 +02:00
|
|
|
- name: Get running configuration
|
|
|
|
junos_rpc:
|
|
|
|
rpc: get-configuration
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: config
|
|
|
|
|
2017-06-16 18:42:50 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2017-06-29 06:48:35 +02:00
|
|
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
2017-06-16 18:42:50 +02:00
|
|
|
|
|
|
|
- name: Configure interface attributes
|
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/1
|
|
|
|
description: test-interface
|
|
|
|
state: present
|
|
|
|
speed: 1g
|
|
|
|
mtu: 256
|
|
|
|
duplex: full
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
2017-06-29 06:48:35 +02:00
|
|
|
- name: Get running configuration
|
|
|
|
junos_rpc:
|
|
|
|
rpc: get-configuration
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: config
|
|
|
|
|
2017-06-16 18:42:50 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2017-06-29 06:48:35 +02:00
|
|
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
|
|
|
- "'<link-mode>full-duplex</link-mode>' in config.xml"
|
|
|
|
- "'<mtu>256</mtu>' in config.xml"
|
|
|
|
- "'<speed>1g</speed>' in config.xml"
|
|
|
|
- "'<description>test-interface</description>' in config.xml"
|
2017-06-16 18:42:50 +02:00
|
|
|
|
|
|
|
- name: Disable interface
|
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/1
|
|
|
|
description: test-interface
|
2017-08-13 09:48:15 +02:00
|
|
|
enabled: False
|
2017-06-16 18:42:50 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2017-08-02 10:41:10 +02:00
|
|
|
- result.diff.prepared | search("\+ *disable")
|
2017-06-16 18:42:50 +02:00
|
|
|
|
|
|
|
- name: Enable interface
|
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/1
|
|
|
|
description: test-interface
|
2017-08-13 09:48:15 +02:00
|
|
|
enabled: True
|
2017-06-16 18:42:50 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2017-08-02 10:41:10 +02:00
|
|
|
- result.diff.prepared | search("\- *disable")
|
2017-06-16 18:42:50 +02:00
|
|
|
|
|
|
|
- name: Delete interface
|
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/1
|
|
|
|
description: test-interface
|
|
|
|
state: absent
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
2017-06-29 06:48:35 +02:00
|
|
|
- name: Get running configuration
|
|
|
|
junos_rpc:
|
|
|
|
rpc: get-configuration
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: config
|
|
|
|
|
2017-06-16 18:42:50 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2017-06-29 06:48:35 +02:00
|
|
|
- "'<name>ge-0/0/1</name>' not in config.xml"
|
2017-08-04 11:25:58 +02:00
|
|
|
|
|
|
|
- name: Aggregate setup- delete interface ge-0/0/1
|
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/1
|
|
|
|
state: absent
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Aggregate setup- delete interface ge-0/0/2
|
|
|
|
junos_interface:
|
|
|
|
name: ge-0/0/2
|
|
|
|
state: absent
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Set interface on aggregate
|
|
|
|
junos_interface:
|
|
|
|
aggregate:
|
2017-08-14 06:47:03 +02:00
|
|
|
- { name: ge-0/0/1, description: test-interface-1, speed: 1g, mtu: 512}
|
|
|
|
- { name: ge-0/0/2, description: test-interface-2, speed: 10m, mtu: 256}
|
|
|
|
duplex: full
|
2017-08-04 11:25:58 +02:00
|
|
|
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")
|
2017-08-04 15:16:57 +02:00
|
|
|
- result.diff.prepared | search("\+ *link-mode full-duplex")
|
2017-08-04 11:25:58 +02:00
|
|
|
- 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)
|
|
|
|
junos_interface:
|
|
|
|
aggregate:
|
2017-08-14 06:47:03 +02:00
|
|
|
- { name: ge-0/0/1, description: test-interface-1, speed: 1g, mtu: 512 }
|
|
|
|
- { name: ge-0/0/2, description: test-interface-2, speed: 10m, mtu: 256 }
|
|
|
|
duplex: full
|
2017-08-04 11:25:58 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
|
|
|
|
- name: Disable interface on aggregate
|
|
|
|
junos_interface:
|
|
|
|
aggregate:
|
2017-08-14 06:47:03 +02:00
|
|
|
- name: ge-0/0/1
|
|
|
|
- name: ge-0/0/2
|
|
|
|
enabled: False
|
2017-08-04 11:25:58 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- result.diff.prepared | search("\+ *disable")
|
|
|
|
|
|
|
|
- name: Enable interface on aggregate
|
|
|
|
junos_interface:
|
|
|
|
aggregate:
|
2017-08-14 06:47:03 +02:00
|
|
|
- name: ge-0/0/1
|
|
|
|
- name: ge-0/0/2
|
|
|
|
enabled: True
|
2017-08-04 11:25:58 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- result.diff.prepared | search("\- *disable")
|
|
|
|
|
|
|
|
- name: Deactivate interface configuration on aggregate
|
|
|
|
junos_interface:
|
|
|
|
aggregate:
|
2017-08-14 06:47:03 +02:00
|
|
|
- { name: ge-0/0/1, description: test-interface-1, speed: 1g, mtu: 512 }
|
|
|
|
- { name: ge-0/0/2, description: test-interface-2, speed: 10m, mtu: 256 }
|
|
|
|
duplex: full
|
|
|
|
active: False
|
2017-08-04 11:25:58 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- result.diff.prepared | search("! *inactive[:] ge-0/0/1")
|
|
|
|
- result.diff.prepared | search("! *inactive[:] ge-0/0/2")
|
|
|
|
|
|
|
|
- name: Activate interface configuration on aggregate
|
|
|
|
junos_interface:
|
|
|
|
aggregate:
|
2017-08-14 06:47:03 +02:00
|
|
|
- { name: ge-0/0/1, description: test-interface-1, speed: 1g, mtu: 512 }
|
|
|
|
- { name: ge-0/0/2, description: test-interface-2, speed: 10m, mtu: 256 }
|
|
|
|
duplex: full
|
|
|
|
active: True
|
2017-08-04 11:25:58 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- result.diff.prepared | search("! *active[:] ge-0/0/1")
|
|
|
|
- result.diff.prepared | search("! *active[:] ge-0/0/2")
|
|
|
|
|
|
|
|
- name: Delete interface on aggregate
|
|
|
|
junos_interface:
|
|
|
|
aggregate:
|
2017-08-14 06:47:03 +02:00
|
|
|
- name: ge-0/0/1
|
|
|
|
- name: ge-0/0/2
|
|
|
|
state: absent
|
2017-08-04 11:25:58 +02:00
|
|
|
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")
|
2017-08-04 15:16:57 +02:00
|
|
|
- result.diff.prepared | search("\- *link-mode full-duplex")
|
2017-08-04 11:25:58 +02:00
|
|
|
- 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")
|
|
|
|
|
2017-08-14 06:47:03 +02:00
|
|
|
- name: Delete interface on aggregate (idempotent)
|
2017-08-04 11:25:58 +02:00
|
|
|
junos_interface:
|
|
|
|
aggregate:
|
2017-08-14 06:47:03 +02:00
|
|
|
- name: ge-0/0/1
|
|
|
|
- name: ge-0/0/2
|
|
|
|
state: absent
|
2017-08-04 11:25:58 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|