mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add active param to junos declarative modules (#26222)
* active/deactivate configuration capability * integration test refactor
This commit is contained in:
parent
15e78d1073
commit
911a7e085e
13 changed files with 561 additions and 331 deletions
|
@ -57,7 +57,7 @@ ARGS_DEFAULT_VALUE = {
|
||||||
OPERATION_LOOK_UP = {
|
OPERATION_LOOK_UP = {
|
||||||
'absent': 'delete',
|
'absent': 'delete',
|
||||||
'active': 'active',
|
'active': 'active',
|
||||||
'suspend': 'inactive'
|
'deactivate': 'inactive'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -289,18 +289,19 @@ def map_obj_to_ele(module, want, top, value_map=None):
|
||||||
ele = SubElement(ele, item)
|
ele = SubElement(ele, item)
|
||||||
container = ele
|
container = ele
|
||||||
state = module.params.get('state')
|
state = module.params.get('state')
|
||||||
|
active = module.params.get('active')
|
||||||
|
if active:
|
||||||
|
oper = 'active'
|
||||||
|
else:
|
||||||
|
oper = 'inactive'
|
||||||
|
|
||||||
# build xml subtree
|
# build xml subtree
|
||||||
for obj in want:
|
for obj in want:
|
||||||
oper = None
|
|
||||||
if container.tag != top_ele[-1]:
|
if container.tag != top_ele[-1]:
|
||||||
node = SubElement(container, top_ele[-1])
|
node = SubElement(container, top_ele[-1])
|
||||||
else:
|
else:
|
||||||
node = container
|
node = container
|
||||||
|
|
||||||
if state and state != 'present':
|
|
||||||
oper = OPERATION_LOOK_UP.get(state)
|
|
||||||
|
|
||||||
for xpath, attributes in obj.items():
|
for xpath, attributes in obj.items():
|
||||||
for attr in attributes:
|
for attr in attributes:
|
||||||
tag_only = attr.get('tag_only', False)
|
tag_only = attr.get('tag_only', False)
|
||||||
|
@ -309,16 +310,20 @@ def map_obj_to_ele(module, want, top, value_map=None):
|
||||||
is_key = attr.get('is_key', False)
|
is_key = attr.get('is_key', False)
|
||||||
value = attr.get('value')
|
value = attr.get('value')
|
||||||
|
|
||||||
# operation (delete/active/inactive) is added as element attribute
|
# operation 'delete' is added as element attribute
|
||||||
# only if it is key or tag only or leaf only node
|
# only if it is key or leaf only node
|
||||||
if oper and not (is_key or tag_only or leaf_only):
|
if state == 'absent' and not (is_key or leaf_only):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# for tag only node if value is false continue to next attr
|
||||||
|
if tag_only and not value:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# convert param value to device specific value
|
# convert param value to device specific value
|
||||||
if value_map and xpath in value_map:
|
if value_map and xpath in value_map:
|
||||||
value = value_map[xpath].get(value)
|
value = value_map[xpath].get(value)
|
||||||
|
|
||||||
if value or tag_only or (leaf_only and value):
|
if value or tag_only or leaf_only:
|
||||||
ele = node
|
ele = node
|
||||||
tags = xpath.split('/')
|
tags = xpath.split('/')
|
||||||
if value:
|
if value:
|
||||||
|
@ -328,22 +333,39 @@ def map_obj_to_ele(module, want, top, value_map=None):
|
||||||
ele = SubElement(ele, item)
|
ele = SubElement(ele, item)
|
||||||
|
|
||||||
if tag_only:
|
if tag_only:
|
||||||
if not value:
|
if state == 'present':
|
||||||
ele.set('delete', 'delete')
|
if not value:
|
||||||
|
# if value of tag_only node is false, delete the node
|
||||||
|
ele.set('delete', 'delete')
|
||||||
|
|
||||||
elif leaf_only:
|
elif leaf_only:
|
||||||
if oper:
|
if state == 'present':
|
||||||
ele.set(oper, oper)
|
ele.set(oper, oper)
|
||||||
|
ele.text = value
|
||||||
|
else:
|
||||||
|
ele.set('delete', 'delete')
|
||||||
|
# Add value of leaf node if required while deleting.
|
||||||
|
# in some cases if value is present while deleting, it
|
||||||
|
# can result in error, hence the check
|
||||||
if is_value:
|
if is_value:
|
||||||
ele.text = value
|
ele.text = value
|
||||||
else:
|
|
||||||
ele.text = value
|
|
||||||
else:
|
else:
|
||||||
ele.text = value
|
ele.text = value
|
||||||
|
|
||||||
if HAS_LXML:
|
if HAS_LXML:
|
||||||
par = ele.getparent()
|
par = ele.getparent()
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg='lxml is not installed.')
|
module.fail_json(msg='lxml is not installed.')
|
||||||
if is_key and oper and not par.attrib.get(oper):
|
|
||||||
par.set(oper, oper)
|
if state == 'present':
|
||||||
|
# set replace attribute at parent node
|
||||||
|
if not par.attrib.get('replace'):
|
||||||
|
par.set('replace', 'replace')
|
||||||
|
|
||||||
|
# set active/inactive at parent node
|
||||||
|
if not par.attrib.get(oper):
|
||||||
|
par.set(oper, oper)
|
||||||
|
else:
|
||||||
|
par.set('delete', 'delete')
|
||||||
|
|
||||||
return root
|
return root
|
||||||
|
|
|
@ -53,7 +53,12 @@ options:
|
||||||
- Specifies whether or not the configuration is
|
- Specifies whether or not the configuration is
|
||||||
present in the current devices active running configuration.
|
present in the current devices active running configuration.
|
||||||
default: present
|
default: present
|
||||||
choices: ['present', 'absent', 'active', 'suspend']
|
choices: ['present', 'absent']
|
||||||
|
active:
|
||||||
|
description:
|
||||||
|
- Specifies whether or not the configuration is active or deactivated
|
||||||
|
default: True
|
||||||
|
choices: [True, False]
|
||||||
requirements:
|
requirements:
|
||||||
- ncclient (>=v0.5.2)
|
- ncclient (>=v0.5.2)
|
||||||
notes:
|
notes:
|
||||||
|
@ -79,12 +84,14 @@ EXAMPLES = """
|
||||||
- name: deactivate the motd banner
|
- name: deactivate the motd banner
|
||||||
junos_banner:
|
junos_banner:
|
||||||
banner: motd
|
banner: motd
|
||||||
state: suspend
|
state: present
|
||||||
|
active: False
|
||||||
|
|
||||||
- name: activate the motd banner
|
- name: activate the motd banner
|
||||||
junos_banner:
|
junos_banner:
|
||||||
banner: motd
|
banner: motd
|
||||||
state: active
|
state: present
|
||||||
|
active: True
|
||||||
|
|
||||||
- name: Configure banner from file
|
- name: Configure banner from file
|
||||||
junos_banner:
|
junos_banner:
|
||||||
|
@ -133,7 +140,8 @@ def main():
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
banner=dict(required=True, choices=['login', 'motd']),
|
banner=dict(required=True, choices=['login', 'motd']),
|
||||||
text=dict(),
|
text=dict(),
|
||||||
state=dict(default='present', choices=['present', 'absent', 'active', 'suspend'])
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
|
active=dict(default=True, type='bool')
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(junos_argument_spec)
|
argument_spec.update(junos_argument_spec)
|
||||||
|
@ -156,10 +164,9 @@ def main():
|
||||||
|
|
||||||
param_to_xpath_map = collections.OrderedDict()
|
param_to_xpath_map = collections.OrderedDict()
|
||||||
|
|
||||||
param_to_xpath_map.update({
|
param_to_xpath_map.update([
|
||||||
'text': {'xpath': 'message' if module.params['banner'] == 'login' else 'announcement',
|
('text', {'xpath': 'message' if module.params['banner'] == 'login' else 'announcement', 'leaf_only': True})
|
||||||
'leaf_only': True}
|
])
|
||||||
})
|
|
||||||
|
|
||||||
validate_param_values(module, param_to_xpath_map)
|
validate_param_values(module, param_to_xpath_map)
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,7 @@ options:
|
||||||
- Description of Interface.
|
- Description of Interface.
|
||||||
enabled:
|
enabled:
|
||||||
description:
|
description:
|
||||||
- Configure operational status of the interface link.
|
- Interface link status.
|
||||||
If value is I(yes/true), interface is configured in up state.
|
|
||||||
For I(no/false) interface is configured in down state.
|
|
||||||
default: yes
|
|
||||||
speed:
|
speed:
|
||||||
description:
|
description:
|
||||||
- Interface link speed.
|
- Interface link speed.
|
||||||
|
@ -73,9 +70,15 @@ options:
|
||||||
default: no
|
default: no
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- State of the Interface configuration.
|
- State of the Interface configuration, C(up) means present and
|
||||||
|
operationally up and C(down) means present and operationally C(down)
|
||||||
default: present
|
default: present
|
||||||
choices: ['present', 'absent', 'active', 'suspend']
|
choices: ['present', 'absent', 'up', 'down']
|
||||||
|
active:
|
||||||
|
description:
|
||||||
|
- Specifies whether or not the configuration is active or deactivated
|
||||||
|
default: True
|
||||||
|
choices: [True, False]
|
||||||
requirements:
|
requirements:
|
||||||
- ncclient (>=v0.5.2)
|
- ncclient (>=v0.5.2)
|
||||||
notes:
|
notes:
|
||||||
|
@ -97,24 +100,24 @@ EXAMPLES = """
|
||||||
- name: make interface down
|
- name: make interface down
|
||||||
junos_interface:
|
junos_interface:
|
||||||
name: ge-0/0/1
|
name: ge-0/0/1
|
||||||
state: present
|
state: down
|
||||||
enabled: False
|
|
||||||
|
|
||||||
- name: make interface up
|
- name: make interface up
|
||||||
junos_interface:
|
junos_interface:
|
||||||
name: ge-0/0/1
|
name: ge-0/0/1
|
||||||
state: present
|
state: up
|
||||||
enabled: True
|
|
||||||
|
|
||||||
- name: Deactivate interface config
|
- name: Deactivate interface config
|
||||||
junos_interface:
|
junos_interface:
|
||||||
name: ge-0/0/1
|
name: ge-0/0/1
|
||||||
state: suspend
|
state: present
|
||||||
|
active: False
|
||||||
|
|
||||||
- name: Activate interface config
|
- name: Activate interface config
|
||||||
net_interface:
|
net_interface:
|
||||||
name: ge-0/0/1
|
name: ge-0/0/1
|
||||||
state: active
|
state: present
|
||||||
|
active: True
|
||||||
|
|
||||||
- name: Configure interface speed, mtu, duplex
|
- name: Configure interface speed, mtu, duplex
|
||||||
junos_interface:
|
junos_interface:
|
||||||
|
@ -123,7 +126,6 @@ EXAMPLES = """
|
||||||
speed: 1g
|
speed: 1g
|
||||||
mtu: 256
|
mtu: 256
|
||||||
duplex: full
|
duplex: full
|
||||||
enabled: True
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -172,7 +174,7 @@ def main():
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
name=dict(required=True),
|
name=dict(required=True),
|
||||||
description=dict(),
|
description=dict(),
|
||||||
enabled=dict(default=True, type='bool'),
|
enabled=dict(),
|
||||||
speed=dict(),
|
speed=dict(),
|
||||||
mtu=dict(type='int'),
|
mtu=dict(type='int'),
|
||||||
duplex=dict(choices=['full', 'half', 'auto']),
|
duplex=dict(choices=['full', 'half', 'auto']),
|
||||||
|
@ -181,7 +183,8 @@ def main():
|
||||||
collection=dict(),
|
collection=dict(),
|
||||||
purge=dict(default=False, type='bool'),
|
purge=dict(default=False, type='bool'),
|
||||||
state=dict(default='present',
|
state=dict(default='present',
|
||||||
choices=['present', 'absent', 'active', 'suspend'])
|
choices=['present', 'absent', 'up', 'down']),
|
||||||
|
active=dict(default=True, type='bool')
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(junos_argument_spec)
|
argument_spec.update(junos_argument_spec)
|
||||||
|
@ -200,18 +203,26 @@ def main():
|
||||||
top = 'interfaces/interface'
|
top = 'interfaces/interface'
|
||||||
|
|
||||||
param_to_xpath_map = collections.OrderedDict()
|
param_to_xpath_map = collections.OrderedDict()
|
||||||
param_to_xpath_map.update({
|
param_to_xpath_map.update([
|
||||||
'name': {'xpath': 'name', 'is_key': True},
|
('name', {'xpath': 'name', 'is_key': True}),
|
||||||
'description': 'description',
|
('description', 'description'),
|
||||||
'speed': 'speed',
|
('speed', 'speed'),
|
||||||
'mtu': 'mtu',
|
('mtu', 'mtu'),
|
||||||
'enabled': {'xpath': 'disable', 'tag_only': True},
|
('duplex', 'link-mode'),
|
||||||
'duplex': 'link-mode'
|
('disable', {'xpath': 'disable', 'tag_only': True})
|
||||||
})
|
])
|
||||||
|
|
||||||
|
state = module.params.get('state')
|
||||||
|
module.params['disable'] = True if state == 'down' else False
|
||||||
|
|
||||||
|
if state in ('present', 'up', 'down'):
|
||||||
|
module.params['state'] = 'present'
|
||||||
|
|
||||||
|
else:
|
||||||
|
module.params['disable'] = True
|
||||||
|
|
||||||
choice_to_value_map = {
|
choice_to_value_map = {
|
||||||
'link-mode': {'full': 'full-duplex', 'half': 'half-duplex', 'auto': 'automatic'},
|
'link-mode': {'full': 'full-duplex', 'half': 'half-duplex', 'auto': 'automatic'}
|
||||||
'disable': {True: False, False: True}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_param_values(module, param_to_xpath_map)
|
validate_param_values(module, param_to_xpath_map)
|
||||||
|
|
|
@ -65,7 +65,12 @@ options:
|
||||||
configuration and when set to I(absent) the values should not be
|
configuration and when set to I(absent) the values should not be
|
||||||
in the device active configuration
|
in the device active configuration
|
||||||
default: present
|
default: present
|
||||||
choices: ['present', 'absent', 'active', 'suspend']
|
choices: ['present', 'absent']
|
||||||
|
active:
|
||||||
|
description:
|
||||||
|
- Specifies whether or not the configuration is active or deactivated
|
||||||
|
default: True
|
||||||
|
choices: [True, False]
|
||||||
requirements:
|
requirements:
|
||||||
- ncclient (>=v0.5.2)
|
- ncclient (>=v0.5.2)
|
||||||
notes:
|
notes:
|
||||||
|
@ -137,8 +142,8 @@ def main():
|
||||||
domain_name=dict(),
|
domain_name=dict(),
|
||||||
domain_search=dict(type='list'),
|
domain_search=dict(type='list'),
|
||||||
name_servers=dict(type='list'),
|
name_servers=dict(type='list'),
|
||||||
|
state=dict(choices=['present', 'absent'], default='present'),
|
||||||
state=dict(choices=['present', 'absent', 'active', 'suspend'], default='present')
|
active=dict(default=True, type='bool')
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(junos_argument_spec)
|
argument_spec.update(junos_argument_spec)
|
||||||
|
@ -164,12 +169,12 @@ def main():
|
||||||
top = 'system'
|
top = 'system'
|
||||||
|
|
||||||
param_to_xpath_map = collections.OrderedDict()
|
param_to_xpath_map = collections.OrderedDict()
|
||||||
param_to_xpath_map.update({
|
param_to_xpath_map.update([
|
||||||
'hostname': {'xpath': 'host-name', 'leaf_only': True},
|
('hostname', {'xpath': 'host-name', 'leaf_only': True}),
|
||||||
'domain_name': {'xpath': 'domain-name', 'leaf_only': True},
|
('domain_name', {'xpath': 'domain-name', 'leaf_only': True}),
|
||||||
'domain_search': {'xpath': 'domain-search', 'leaf_only': True, 'value_req': True},
|
('domain_search', {'xpath': 'domain-search', 'leaf_only': True, 'value_req': True}),
|
||||||
'name_servers': {'xpath': 'name-server/name', 'is_key': True}
|
('name_servers', {'xpath': 'name-server/name', 'is_key': True})
|
||||||
})
|
])
|
||||||
|
|
||||||
validate_param_values(module, param_to_xpath_map)
|
validate_param_values(module, param_to_xpath_map)
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,12 @@ options:
|
||||||
description:
|
description:
|
||||||
- State of the VLAN configuration.
|
- State of the VLAN configuration.
|
||||||
default: present
|
default: present
|
||||||
choices: ['present', 'absent', 'active', 'suspend']
|
choices: ['present', 'absent']
|
||||||
|
active:
|
||||||
|
description:
|
||||||
|
- Specifies whether or not the configuration is active or deactivated
|
||||||
|
default: True
|
||||||
|
choices: [True, False]
|
||||||
requirements:
|
requirements:
|
||||||
- ncclient (>=v0.5.2)
|
- ncclient (>=v0.5.2)
|
||||||
notes:
|
notes:
|
||||||
|
@ -82,12 +87,14 @@ EXAMPLES = """
|
||||||
- name: deactive VLAN configuration
|
- name: deactive VLAN configuration
|
||||||
junos_vlan:
|
junos_vlan:
|
||||||
vlan_name: test
|
vlan_name: test
|
||||||
state: suspend
|
state: present
|
||||||
|
active: False
|
||||||
|
|
||||||
- name: activate VLAN configuration
|
- name: activate VLAN configuration
|
||||||
junos_vlan:
|
junos_vlan:
|
||||||
vlan_name: test
|
vlan_name: test
|
||||||
state: active
|
state: present
|
||||||
|
active: True
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -134,8 +141,8 @@ def main():
|
||||||
interfaces=dict(),
|
interfaces=dict(),
|
||||||
collection=dict(),
|
collection=dict(),
|
||||||
purge=dict(default=False, type='bool'),
|
purge=dict(default=False, type='bool'),
|
||||||
state=dict(default='present',
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
choices=['present', 'absent', 'active', 'suspend'])
|
active=dict(default=True, type='bool')
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(junos_argument_spec)
|
argument_spec.update(junos_argument_spec)
|
||||||
|
@ -154,11 +161,11 @@ def main():
|
||||||
top = 'vlans/vlan'
|
top = 'vlans/vlan'
|
||||||
|
|
||||||
param_to_xpath_map = collections.OrderedDict()
|
param_to_xpath_map = collections.OrderedDict()
|
||||||
param_to_xpath_map.update({
|
param_to_xpath_map.update([
|
||||||
'name': {'xpath': 'name', 'is_key': True},
|
('name', {'xpath': 'name', 'is_key': True}),
|
||||||
'vlan_id': 'vlan-id',
|
('vlan_id', 'vlan-id'),
|
||||||
'description': 'description'
|
('description', 'description')
|
||||||
})
|
])
|
||||||
|
|
||||||
validate_param_values(module, param_to_xpath_map)
|
validate_param_values(module, param_to_xpath_map)
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<message>this is my login banner</message>' in result.rpc"
|
- "'<message>this is my login banner</message>' in config.xml"
|
||||||
|
|
||||||
- name: Create login banner (idempotent)
|
- name: Create login banner (idempotent)
|
||||||
junos_banner:
|
junos_banner:
|
||||||
|
@ -36,27 +42,41 @@
|
||||||
junos_banner:
|
junos_banner:
|
||||||
banner: login
|
banner: login
|
||||||
text: this is my login banner
|
text: this is my login banner
|
||||||
state: suspend
|
state: present
|
||||||
|
active: False
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<message inactive=\"inactive\" />' in result.rpc"
|
- "'<message inactive=\"inactive\">this is my login banner</message>' in config.xml"
|
||||||
|
|
||||||
- name: Activate login banner
|
- name: Activate login banner
|
||||||
junos_banner:
|
junos_banner:
|
||||||
banner: login
|
banner: login
|
||||||
text: this is my login banner
|
text: this is my login banner
|
||||||
state: active
|
state: present
|
||||||
|
active: True
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<message active=\"active\" />' in result.rpc"
|
- "'<message>this is my login banner</message>' in config.xml"
|
||||||
|
|
||||||
- name: delete login banner
|
- name: delete login banner
|
||||||
junos_banner:
|
junos_banner:
|
||||||
|
@ -65,10 +85,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<message delete=\"delete\" />' in result.rpc"
|
- "'<message>this is my login banner</message>' not in config.xml"
|
||||||
|
|
||||||
- name: setup - remove motd banner
|
- name: setup - remove motd banner
|
||||||
junos_banner:
|
junos_banner:
|
||||||
|
@ -84,13 +110,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug:
|
- name: Get running configuration
|
||||||
msg: "{{ result }}"
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<announcement>this is my motd banner</announcement>' in result.rpc"
|
- "'<announcement>this is my motd banner</announcement>' in config.xml"
|
||||||
|
|
||||||
- name: Create motd banner (idempotent)
|
- name: Create motd banner (idempotent)
|
||||||
junos_banner:
|
junos_banner:
|
||||||
|
@ -107,26 +136,42 @@
|
||||||
- name: Deactivate motd banner
|
- name: Deactivate motd banner
|
||||||
junos_banner:
|
junos_banner:
|
||||||
banner: motd
|
banner: motd
|
||||||
state: suspend
|
text: this is my motd banner
|
||||||
|
state: present
|
||||||
|
active: False
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<announcement inactive=\"inactive\" />' in result.rpc"
|
- "'<announcement inactive=\"inactive\">this is my motd banner</announcement>' in config.xml"
|
||||||
|
|
||||||
- name: Activate motd banner
|
- name: Activate motd banner
|
||||||
junos_banner:
|
junos_banner:
|
||||||
banner: motd
|
banner: motd
|
||||||
state: active
|
text: this is my motd banner
|
||||||
|
state: present
|
||||||
|
active: True
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<announcement active=\"active\" />' in result.rpc"
|
- "'<announcement>this is my motd banner</announcement>' in config.xml"
|
||||||
|
|
||||||
- name: delete motd banner
|
- name: delete motd banner
|
||||||
junos_banner:
|
junos_banner:
|
||||||
|
@ -135,7 +180,13 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<announcement delete=\"delete\" />' in result.rpc"
|
- "'<announcement>this is my motd banner</announcement>' not in config.xml"
|
||||||
|
|
|
@ -16,14 +16,17 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug:
|
- name: Get running configuration
|
||||||
msg: "{{ result }}"
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||||
- "'<description>test-interface</description>' in result.rpc"
|
- "'<description>test-interface</description>' in config.xml"
|
||||||
|
|
||||||
- name: Create interface (idempotent)
|
- name: Create interface (idempotent)
|
||||||
junos_interface:
|
junos_interface:
|
||||||
|
@ -41,29 +44,43 @@
|
||||||
junos_interface:
|
junos_interface:
|
||||||
name: ge-0/0/1
|
name: ge-0/0/1
|
||||||
description: test-interface
|
description: test-interface
|
||||||
state: suspend
|
state: present
|
||||||
|
active: False
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<interface inactive=\"inactive\">' in result.rpc"
|
- "'<interface inactive=\"inactive\">' in config.xml"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||||
|
|
||||||
- name: Activate interface configuration
|
- name: Activate interface configuration
|
||||||
junos_interface:
|
junos_interface:
|
||||||
name: ge-0/0/1
|
name: ge-0/0/1
|
||||||
description: test-interface
|
description: test-interface
|
||||||
state: active
|
state: present
|
||||||
|
active: True
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<interface active=\"active\">' in result.rpc"
|
- "'<interface>' in config.xml"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||||
|
|
||||||
- name: Configure interface attributes
|
- name: Configure interface attributes
|
||||||
junos_interface:
|
junos_interface:
|
||||||
|
@ -76,44 +93,60 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||||
- "'<link-mode>full-duplex</link-mode>' in result.rpc"
|
- "'<link-mode>full-duplex</link-mode>' in config.xml"
|
||||||
- "'<mtu>256</mtu>' in result.rpc"
|
- "'<mtu>256</mtu>' in config.xml"
|
||||||
- "'<speed>1g</speed>' in result.rpc"
|
- "'<speed>1g</speed>' in config.xml"
|
||||||
- "'<description>test-interface</description>' in result.rpc"
|
- "'<description>test-interface</description>' in config.xml"
|
||||||
|
|
||||||
- name: Disable interface
|
- name: Disable interface
|
||||||
junos_interface:
|
junos_interface:
|
||||||
name: ge-0/0/1
|
name: ge-0/0/1
|
||||||
description: test-interface
|
description: test-interface
|
||||||
state: present
|
state: down
|
||||||
enabled: False
|
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<disable />' in result.rpc"
|
- "'<disable/>' in config.xml"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||||
|
|
||||||
- name: Enable interface
|
- name: Enable interface
|
||||||
junos_interface:
|
junos_interface:
|
||||||
name: ge-0/0/1
|
name: ge-0/0/1
|
||||||
description: test-interface
|
description: test-interface
|
||||||
state: present
|
state: up
|
||||||
enabled: True
|
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<disable delete=\"delete\" />' in result.rpc"
|
- "'<disable/>' not in config.xml"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||||
|
|
||||||
- name: Delete interface
|
- name: Delete interface
|
||||||
junos_interface:
|
junos_interface:
|
||||||
|
@ -123,8 +156,19 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<interface delete=\"delete\">' in result.rpc"
|
- "'<name>ge-0/0/1</name>' not in config.xml"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
|
||||||
|
|
|
@ -14,10 +14,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<host-name>vsrx01</host-name>' in result.rpc"
|
- "'<host-name>vsrx01</host-name>' in config.xml"
|
||||||
|
|
||||||
- name: Set hostname (idempotent)
|
- name: Set hostname (idempotent)
|
||||||
junos_system:
|
junos_system:
|
||||||
|
@ -33,26 +39,40 @@
|
||||||
- name: Deactivate hostname configuration
|
- name: Deactivate hostname configuration
|
||||||
junos_system:
|
junos_system:
|
||||||
hostname: vsrx01
|
hostname: vsrx01
|
||||||
state: suspend
|
state: present
|
||||||
|
active: False
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<host-name inactive=\"inactive\" />' in result.rpc"
|
- "'<host-name inactive=\"inactive\">' in config.xml"
|
||||||
|
|
||||||
- name: Activate hostname configuration
|
- name: Activate hostname configuration
|
||||||
junos_system:
|
junos_system:
|
||||||
hostname: vsrx01
|
hostname: vsrx01
|
||||||
state: active
|
state: present
|
||||||
|
active: True
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<host-name active=\"active\" />' in result.rpc"
|
- "'<host-name>vsrx01</host-name>' in config.xml"
|
||||||
|
|
||||||
- name: Delete hostname configuration
|
- name: Delete hostname configuration
|
||||||
junos_system:
|
junos_system:
|
||||||
|
@ -64,7 +84,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<host-name delete=\"delete\" />' in result.rpc"
|
- "'<host-name>vsrx01</host-name>' in config.xml"
|
||||||
|
|
||||||
- name: Teardown - set hostname
|
- name: Teardown - set hostname
|
||||||
junos_system:
|
junos_system:
|
||||||
|
@ -85,10 +105,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-name>ansible.com</domain-name>' in result.rpc"
|
- "'<domain-name>ansible.com</domain-name>' in config.xml"
|
||||||
|
|
||||||
- name: Set domain name (idempotent)
|
- name: Set domain name (idempotent)
|
||||||
junos_system:
|
junos_system:
|
||||||
|
@ -104,26 +130,40 @@
|
||||||
- name: Deactivate domain name
|
- name: Deactivate domain name
|
||||||
junos_system:
|
junos_system:
|
||||||
domain_name: ansible.com
|
domain_name: ansible.com
|
||||||
state: suspend
|
state: present
|
||||||
|
active: False
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-name inactive=\"inactive\" />' in result.rpc"
|
- "'<domain-name inactive=\"inactive\">' in config.xml"
|
||||||
|
|
||||||
- name: Activate domain name
|
- name: Activate domain name
|
||||||
junos_system:
|
junos_system:
|
||||||
domain_name: ansible.com
|
domain_name: ansible.com
|
||||||
state: active
|
state: present
|
||||||
|
active: True
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-name active=\"active\" />' in result.rpc"
|
- "'<domain-name>ansible.com</domain-name>' in config.xml"
|
||||||
|
|
||||||
- name: Delete domain name
|
- name: Delete domain name
|
||||||
junos_system:
|
junos_system:
|
||||||
|
@ -132,10 +172,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-name delete=\"delete\" />' in result.rpc"
|
- "'<domain-name>ansible.com</domain-name>' not in config.xml"
|
||||||
|
|
||||||
- name: Teardown - set domain name
|
- name: Teardown - set domain name
|
||||||
junos_system:
|
junos_system:
|
||||||
|
@ -161,13 +207,19 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-search>test.com</domain-search>' in result.rpc"
|
- "'<domain-search>test.com</domain-search>' in config.xml"
|
||||||
- "'<domain-search>sample.com</domain-search>' in result.rpc"
|
- "'<domain-search>sample.com</domain-search>' in config.xml"
|
||||||
|
|
||||||
- name: Set domain search
|
- name: Set domain search (idempotency)
|
||||||
junos_system:
|
junos_system:
|
||||||
domain_search:
|
domain_search:
|
||||||
- test.com
|
- test.com
|
||||||
|
@ -185,30 +237,44 @@
|
||||||
domain_search:
|
domain_search:
|
||||||
- test.com
|
- test.com
|
||||||
- sample.com
|
- sample.com
|
||||||
state: suspend
|
state: present
|
||||||
|
active: False
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-search inactive=\"inactive\">test.com</domain-search>' in result.rpc"
|
- "'<domain-search inactive=\"inactive\">test.com</domain-search>' in config.xml"
|
||||||
- "'<domain-search inactive=\"inactive\">sample.com</domain-search>' in result.rpc"
|
- "'<domain-search inactive=\"inactive\">sample.com</domain-search>' in config.xml"
|
||||||
|
|
||||||
- name: Activate domain search
|
- name: Activate domain search
|
||||||
junos_system:
|
junos_system:
|
||||||
domain_search:
|
domain_search:
|
||||||
- test.com
|
- test.com
|
||||||
- sample.com
|
- sample.com
|
||||||
state: active
|
state: present
|
||||||
|
active: True
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-search active=\"active\">test.com</domain-search>' in result.rpc"
|
- "'<domain-search>test.com</domain-search>' in config.xml"
|
||||||
- "'<domain-search active=\"active\">sample.com</domain-search>' in result.rpc"
|
- "'<domain-search>sample.com</domain-search>' in config.xml"
|
||||||
|
|
||||||
- name: Delete domain search
|
- name: Delete domain search
|
||||||
junos_system:
|
junos_system:
|
||||||
|
@ -219,11 +285,17 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-search delete=\"delete\">test.com</domain-search>' in result.rpc"
|
- "'<domain-search>test.com</domain-search>' not in config.xml"
|
||||||
- "'<domain-search delete=\"delete\">sample.com</domain-search>' in result.rpc"
|
- "'<domain-search>sample.com</domain-search>' not in config.xml"
|
||||||
|
|
||||||
- name: Setup - delete name servers
|
- name: Setup - delete name servers
|
||||||
junos_system:
|
junos_system:
|
||||||
|
@ -243,11 +315,17 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name-server><name>8.8.8.8</name></name-server>' in result.rpc"
|
- "'<name>8.8.8.8</name>' in config.xml"
|
||||||
- "'<name-server><name>8.8.4.4</name></name-server>' in result.rpc"
|
- "'<name>8.8.4.4</name>' in config.xml"
|
||||||
|
|
||||||
- name: Set name servers (idempotent)
|
- name: Set name servers (idempotent)
|
||||||
junos_system:
|
junos_system:
|
||||||
|
@ -267,30 +345,43 @@
|
||||||
name_servers:
|
name_servers:
|
||||||
- 8.8.8.8
|
- 8.8.8.8
|
||||||
- 8.8.4.4
|
- 8.8.4.4
|
||||||
state: suspend
|
state: present
|
||||||
|
active: False
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name-server inactive=\"inactive\"><name>8.8.8.8</name></name-server>' in result.rpc"
|
- "'<name-server inactive=\"inactive\">' in config.xml"
|
||||||
- "'<name-server inactive=\"inactive\"><name>8.8.4.4</name></name-server>' in result.rpc"
|
|
||||||
|
|
||||||
- name: Activate name servers
|
- name: Activate name servers
|
||||||
junos_system:
|
junos_system:
|
||||||
name_servers:
|
name_servers:
|
||||||
- 8.8.8.8
|
- 8.8.8.8
|
||||||
- 8.8.4.4
|
- 8.8.4.4
|
||||||
state: active
|
state: present
|
||||||
|
active: True
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name-server active=\"active\"><name>8.8.8.8</name></name-server>' in result.rpc"
|
- "'<name>8.8.8.8</name>' in config.xml"
|
||||||
- "'<name-server active=\"active\"><name>8.8.4.4</name></name-server>' in result.rpc"
|
- "'<name>8.8.4.4</name>' in config.xml"
|
||||||
|
|
||||||
- name: Delete name servers
|
- name: Delete name servers
|
||||||
junos_system:
|
junos_system:
|
||||||
|
@ -301,8 +392,14 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name-server delete=\"delete\"><name>8.8.8.8</name></name-server>' in result.rpc"
|
- "'<name>8.8.8.8</name>' not in config.xml"
|
||||||
- "'<name-server delete=\"delete\"><name>8.8.4.4</name></name-server>' in result.rpc"
|
- "'<name>8.8.4.4</name>' not in config.xml"
|
||||||
|
|
|
@ -18,14 +18,17 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug:
|
- name: Get running configuration
|
||||||
msg: "{{ result }}"
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name>test-vlan</name>' in result.rpc"
|
- "'<name>test-vlan</name>' in config.xml"
|
||||||
- "'<vlan-id>100</vlan-id>' in result.rpc"
|
- "'<vlan-id>100</vlan-id>' in config.xml"
|
||||||
|
|
||||||
- name: Create vlan again (idempotent)
|
- name: Create vlan again (idempotent)
|
||||||
junos_vlan:
|
junos_vlan:
|
||||||
|
@ -44,29 +47,42 @@
|
||||||
junos_vlan:
|
junos_vlan:
|
||||||
vlan_id: 100
|
vlan_id: 100
|
||||||
name: test-vlan
|
name: test-vlan
|
||||||
state: suspend
|
state: present
|
||||||
|
active: False
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<vlan inactive=\"inactive\">' in result.rpc"
|
- "'<vlan inactive=\"inactive\">' in config.xml"
|
||||||
- "'<name>test-vlan</name>' in result.rpc"
|
- "'<name>test-vlan</name>' in config.xml"
|
||||||
|
|
||||||
- name: Activate vlan
|
- name: Activate vlan
|
||||||
junos_vlan:
|
junos_vlan:
|
||||||
vlan_id: 100
|
vlan_id: 100
|
||||||
name: test-vlan
|
name: test-vlan
|
||||||
state: active
|
state: present
|
||||||
|
active: True
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<vlan active=\"active\">' in result.rpc"
|
- "'<name>test-vlan</name>' in config.xml"
|
||||||
- "'<name>test-vlan</name>' in result.rpc"
|
|
||||||
|
|
||||||
- name: Delete vlan
|
- name: Delete vlan
|
||||||
junos_vlan:
|
junos_vlan:
|
||||||
|
@ -76,8 +92,13 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<vlan delete=\"delete\">' in result.rpc"
|
- "'<name>test-vlan</name>' not in config.xml"
|
||||||
- "'<name>test-vlan</name>' in result.rpc"
|
|
||||||
|
|
|
@ -15,10 +15,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<message>this is my login banner</message>' in result.rpc"
|
- "'<message>this is my login banner</message>' in config.xml"
|
||||||
|
|
||||||
- name: Create login banner (idempotent)
|
- name: Create login banner (idempotent)
|
||||||
net_banner:
|
net_banner:
|
||||||
|
@ -39,10 +45,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<message delete=\"delete\" />' in result.rpc"
|
- "'<message>this is my login banner</message>' not in config.xml"
|
||||||
|
|
||||||
- name: setup - remove motd banner
|
- name: setup - remove motd banner
|
||||||
net_banner:
|
net_banner:
|
||||||
|
@ -58,13 +70,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug:
|
- name: Get running configuration
|
||||||
msg: "{{ result }}"
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<announcement>this is my motd banner</announcement>' in result.rpc"
|
- "'<announcement>this is my motd banner</announcement>' in config.xml"
|
||||||
|
|
||||||
- name: Create motd banner (idempotent)
|
- name: Create motd banner (idempotent)
|
||||||
net_banner:
|
net_banner:
|
||||||
|
@ -85,7 +100,13 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<announcement delete=\"delete\" />' in result.rpc"
|
- "'<announcement>this is my motd banner</announcement>' not in config.xml"
|
||||||
|
|
|
@ -16,14 +16,17 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug:
|
- name: Get running configuration
|
||||||
msg: "{{ result }}"
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||||
- "'<description>test-interface</description>' in result.rpc"
|
- "'<description>test-interface</description>' in config.xml"
|
||||||
|
|
||||||
- name: Create interface (idempotent)
|
- name: Create interface (idempotent)
|
||||||
net_interface:
|
net_interface:
|
||||||
|
@ -48,44 +51,60 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||||
- "'<link-mode>full-duplex</link-mode>' in result.rpc"
|
- "'<link-mode>full-duplex</link-mode>' in config.xml"
|
||||||
- "'<mtu>256</mtu>' in result.rpc"
|
- "'<mtu>256</mtu>' in config.xml"
|
||||||
- "'<speed>1g</speed>' in result.rpc"
|
- "'<speed>1g</speed>' in config.xml"
|
||||||
- "'<description>test-interface</description>' in result.rpc"
|
- "'<description>test-interface</description>' in config.xml"
|
||||||
|
|
||||||
- name: Disable interface
|
- name: Disable interface
|
||||||
net_interface:
|
net_interface:
|
||||||
name: ge-0/0/1
|
name: ge-0/0/1
|
||||||
description: test-interface
|
description: test-interface
|
||||||
state: present
|
state: down
|
||||||
enabled: False
|
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<disable />' in result.rpc"
|
- "'<disable/>' in config.xml"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||||
|
|
||||||
- name: Enable interface
|
- name: Enable interface
|
||||||
net_interface:
|
net_interface:
|
||||||
name: ge-0/0/1
|
name: ge-0/0/1
|
||||||
description: test-interface
|
description: test-interface
|
||||||
state: present
|
state: up
|
||||||
enabled: True
|
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<disable delete=\"delete\" />' in result.rpc"
|
- "'<disable/>' not in config.xml"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||||
|
|
||||||
- name: Delete interface
|
- name: Delete interface
|
||||||
net_interface:
|
net_interface:
|
||||||
|
@ -95,8 +114,13 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<interface delete=\"delete\">' in result.rpc"
|
- "'<name>ge-0/0/1</name>' not in config.xml"
|
||||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
|
||||||
|
|
|
@ -14,10 +14,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<host-name>vsrx01</host-name>' in result.rpc"
|
- "'<host-name>vsrx01</host-name>' in config.xml"
|
||||||
|
|
||||||
- name: Set hostname (idempotent)
|
- name: Set hostname (idempotent)
|
||||||
net_system:
|
net_system:
|
||||||
|
@ -30,30 +36,6 @@
|
||||||
that:
|
that:
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
|
|
||||||
- name: Deactivate hostname configuration
|
|
||||||
net_system:
|
|
||||||
hostname: vsrx01
|
|
||||||
state: suspend
|
|
||||||
provider: "{{ netconf }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result.changed == true"
|
|
||||||
- "'<host-name inactive=\"inactive\" />' in result.rpc"
|
|
||||||
|
|
||||||
- name: Activate hostname configuration
|
|
||||||
net_system:
|
|
||||||
hostname: vsrx01
|
|
||||||
state: active
|
|
||||||
provider: "{{ netconf }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result.changed == true"
|
|
||||||
- "'<host-name active=\"active\" />' in result.rpc"
|
|
||||||
|
|
||||||
- name: Delete hostname configuration
|
- name: Delete hostname configuration
|
||||||
net_system:
|
net_system:
|
||||||
hostname: vsrx01
|
hostname: vsrx01
|
||||||
|
@ -61,10 +43,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<host-name delete=\"delete\" />' in result.rpc"
|
- "'<host-name>vsrx01</host-name>' not in config.xml"
|
||||||
|
|
||||||
- name: Teardown - set hostname
|
- name: Teardown - set hostname
|
||||||
net_system:
|
net_system:
|
||||||
|
@ -85,10 +73,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-name>ansible.com</domain-name>' in result.rpc"
|
- "'<domain-name>ansible.com</domain-name>' in config.xml"
|
||||||
|
|
||||||
- name: Set domain name (idempotent)
|
- name: Set domain name (idempotent)
|
||||||
net_system:
|
net_system:
|
||||||
|
@ -101,30 +95,6 @@
|
||||||
that:
|
that:
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
|
|
||||||
- name: Deactivate domain name
|
|
||||||
net_system:
|
|
||||||
domain_name: ansible.com
|
|
||||||
state: suspend
|
|
||||||
provider: "{{ netconf }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result.changed == true"
|
|
||||||
- "'<domain-name inactive=\"inactive\" />' in result.rpc"
|
|
||||||
|
|
||||||
- name: Activate domain name
|
|
||||||
net_system:
|
|
||||||
domain_name: ansible.com
|
|
||||||
state: active
|
|
||||||
provider: "{{ netconf }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result.changed == true"
|
|
||||||
- "'<domain-name active=\"active\" />' in result.rpc"
|
|
||||||
|
|
||||||
- name: Delete domain name
|
- name: Delete domain name
|
||||||
net_system:
|
net_system:
|
||||||
domain_name: ansible.com
|
domain_name: ansible.com
|
||||||
|
@ -132,10 +102,16 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-name delete=\"delete\" />' in result.rpc"
|
- "'<domain-name>ansible.com</domain-name>' not in config.xml"
|
||||||
|
|
||||||
- name: Teardown - set domain name
|
- name: Teardown - set domain name
|
||||||
net_system:
|
net_system:
|
||||||
|
@ -161,11 +137,17 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-search>test.com</domain-search>' in result.rpc"
|
- "'<domain-search>test.com</domain-search>' in config.xml"
|
||||||
- "'<domain-search>sample.com</domain-search>' in result.rpc"
|
- "'<domain-search>sample.com</domain-search>' in config.xml"
|
||||||
|
|
||||||
- name: Set domain search
|
- name: Set domain search
|
||||||
net_system:
|
net_system:
|
||||||
|
@ -180,36 +162,6 @@
|
||||||
that:
|
that:
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
|
|
||||||
- name: Deactivate domain search
|
|
||||||
net_system:
|
|
||||||
domain_search:
|
|
||||||
- test.com
|
|
||||||
- sample.com
|
|
||||||
state: suspend
|
|
||||||
provider: "{{ netconf }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result.changed == true"
|
|
||||||
- "'<domain-search inactive=\"inactive\">test.com</domain-search>' in result.rpc"
|
|
||||||
- "'<domain-search inactive=\"inactive\">sample.com</domain-search>' in result.rpc"
|
|
||||||
|
|
||||||
- name: Activate domain search
|
|
||||||
net_system:
|
|
||||||
domain_search:
|
|
||||||
- test.com
|
|
||||||
- sample.com
|
|
||||||
state: active
|
|
||||||
provider: "{{ netconf }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result.changed == true"
|
|
||||||
- "'<domain-search active=\"active\">test.com</domain-search>' in result.rpc"
|
|
||||||
- "'<domain-search active=\"active\">sample.com</domain-search>' in result.rpc"
|
|
||||||
|
|
||||||
- name: Delete domain search
|
- name: Delete domain search
|
||||||
net_system:
|
net_system:
|
||||||
domain_search:
|
domain_search:
|
||||||
|
@ -219,11 +171,17 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<domain-search delete=\"delete\">test.com</domain-search>' in result.rpc"
|
- "'<domain-search>test.com</domain-search>' not in config.xml"
|
||||||
- "'<domain-search delete=\"delete\">sample.com</domain-search>' in result.rpc"
|
- "'<domain-search>sample.com</domain-search>' not in config.xml"
|
||||||
|
|
||||||
- name: Setup - delete name servers
|
- name: Setup - delete name servers
|
||||||
net_system:
|
net_system:
|
||||||
|
@ -243,11 +201,17 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name-server><name>8.8.8.8</name></name-server>' in result.rpc"
|
- "'<name>8.8.8.8</name>' in config.xml"
|
||||||
- "'<name-server><name>8.8.4.4</name></name-server>' in result.rpc"
|
- "'<name>8.8.4.4</name>' in config.xml"
|
||||||
|
|
||||||
- name: Set name servers (idempotent)
|
- name: Set name servers (idempotent)
|
||||||
net_system:
|
net_system:
|
||||||
|
@ -262,36 +226,6 @@
|
||||||
that:
|
that:
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
|
|
||||||
- name: Deactivate name servers
|
|
||||||
net_system:
|
|
||||||
name_servers:
|
|
||||||
- 8.8.8.8
|
|
||||||
- 8.8.4.4
|
|
||||||
state: suspend
|
|
||||||
provider: "{{ netconf }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result.changed == true"
|
|
||||||
- "'<name-server inactive=\"inactive\"><name>8.8.8.8</name></name-server>' in result.rpc"
|
|
||||||
- "'<name-server inactive=\"inactive\"><name>8.8.4.4</name></name-server>' in result.rpc"
|
|
||||||
|
|
||||||
- name: Activate name servers
|
|
||||||
net_system:
|
|
||||||
name_servers:
|
|
||||||
- 8.8.8.8
|
|
||||||
- 8.8.4.4
|
|
||||||
state: active
|
|
||||||
provider: "{{ netconf }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result.changed == true"
|
|
||||||
- "'<name-server active=\"active\"><name>8.8.8.8</name></name-server>' in result.rpc"
|
|
||||||
- "'<name-server active=\"active\"><name>8.8.4.4</name></name-server>' in result.rpc"
|
|
||||||
|
|
||||||
- name: Delete name servers
|
- name: Delete name servers
|
||||||
net_system:
|
net_system:
|
||||||
name_servers:
|
name_servers:
|
||||||
|
@ -301,8 +235,14 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name-server delete=\"delete\"><name>8.8.8.8</name></name-server>' in result.rpc"
|
- "'<name>8.8.8.8</name>' not in config.xml"
|
||||||
- "'<name-server delete=\"delete\"><name>8.8.4.4</name></name-server>' in result.rpc"
|
- "'<name>8.8.4.4</name>' not in config.xml"
|
||||||
|
|
|
@ -16,14 +16,17 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug:
|
- name: Get running configuration
|
||||||
msg: "{{ result }}"
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<name>test-vlan</name>' in result.rpc"
|
- "'<name>test-vlan</name>' in config.xml"
|
||||||
- "'<vlan-id>100</vlan-id>' in result.rpc"
|
- "'<vlan-id>100</vlan-id>' in config.xml"
|
||||||
|
|
||||||
- name: Create vlan again (idempotent)
|
- name: Create vlan again (idempotent)
|
||||||
net_vlan:
|
net_vlan:
|
||||||
|
@ -37,34 +40,6 @@
|
||||||
that:
|
that:
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
|
|
||||||
- name: Deactivate vlan
|
|
||||||
net_vlan:
|
|
||||||
vlan_id: 100
|
|
||||||
name: test-vlan
|
|
||||||
state: suspend
|
|
||||||
provider: "{{ netconf }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result.changed == true"
|
|
||||||
- "'<vlan inactive=\"inactive\">' in result.rpc"
|
|
||||||
- "'<name>test-vlan</name>' in result.rpc"
|
|
||||||
|
|
||||||
- name: Activate vlan
|
|
||||||
net_vlan:
|
|
||||||
vlan_id: 100
|
|
||||||
name: test-vlan
|
|
||||||
state: active
|
|
||||||
provider: "{{ netconf }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result.changed == true"
|
|
||||||
- "'<vlan active=\"active\">' in result.rpc"
|
|
||||||
- "'<name>test-vlan</name>' in result.rpc"
|
|
||||||
|
|
||||||
- name: Delete vlan
|
- name: Delete vlan
|
||||||
net_vlan:
|
net_vlan:
|
||||||
vlan_id: 100
|
vlan_id: 100
|
||||||
|
@ -73,8 +48,13 @@
|
||||||
provider: "{{ netconf }}"
|
provider: "{{ netconf }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
- name: Get running configuration
|
||||||
|
junos_rpc:
|
||||||
|
rpc: get-configuration
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
register: config
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'<vlan delete=\"delete\">' in result.rpc"
|
- "'<name>test-vlan</name>' not in config.xml"
|
||||||
- "'<name>test-vlan</name>' in result.rpc"
|
|
||||||
|
|
Loading…
Reference in a new issue