mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07: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
|
@ -53,7 +53,12 @@ options:
|
|||
- Specifies whether or not the configuration is
|
||||
present in the current devices active running configuration.
|
||||
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:
|
||||
- ncclient (>=v0.5.2)
|
||||
notes:
|
||||
|
@ -79,12 +84,14 @@ EXAMPLES = """
|
|||
- name: deactivate the motd banner
|
||||
junos_banner:
|
||||
banner: motd
|
||||
state: suspend
|
||||
state: present
|
||||
active: False
|
||||
|
||||
- name: activate the motd banner
|
||||
junos_banner:
|
||||
banner: motd
|
||||
state: active
|
||||
state: present
|
||||
active: True
|
||||
|
||||
- name: Configure banner from file
|
||||
junos_banner:
|
||||
|
@ -133,7 +140,8 @@ def main():
|
|||
argument_spec = dict(
|
||||
banner=dict(required=True, choices=['login', 'motd']),
|
||||
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)
|
||||
|
@ -156,10 +164,9 @@ def main():
|
|||
|
||||
param_to_xpath_map = collections.OrderedDict()
|
||||
|
||||
param_to_xpath_map.update({
|
||||
'text': {'xpath': 'message' if module.params['banner'] == 'login' else 'announcement',
|
||||
'leaf_only': True}
|
||||
})
|
||||
param_to_xpath_map.update([
|
||||
('text', {'xpath': 'message' if module.params['banner'] == 'login' else 'announcement', 'leaf_only': True})
|
||||
])
|
||||
|
||||
validate_param_values(module, param_to_xpath_map)
|
||||
|
||||
|
|
|
@ -43,10 +43,7 @@ options:
|
|||
- Description of Interface.
|
||||
enabled:
|
||||
description:
|
||||
- Configure operational status of the interface link.
|
||||
If value is I(yes/true), interface is configured in up state.
|
||||
For I(no/false) interface is configured in down state.
|
||||
default: yes
|
||||
- Interface link status.
|
||||
speed:
|
||||
description:
|
||||
- Interface link speed.
|
||||
|
@ -73,9 +70,15 @@ options:
|
|||
default: no
|
||||
state:
|
||||
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
|
||||
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:
|
||||
- ncclient (>=v0.5.2)
|
||||
notes:
|
||||
|
@ -97,24 +100,24 @@ EXAMPLES = """
|
|||
- name: make interface down
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
state: present
|
||||
enabled: False
|
||||
state: down
|
||||
|
||||
- name: make interface up
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
state: present
|
||||
enabled: True
|
||||
state: up
|
||||
|
||||
- name: Deactivate interface config
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
state: suspend
|
||||
state: present
|
||||
active: False
|
||||
|
||||
- name: Activate interface config
|
||||
net_interface:
|
||||
name: ge-0/0/1
|
||||
state: active
|
||||
state: present
|
||||
active: True
|
||||
|
||||
- name: Configure interface speed, mtu, duplex
|
||||
junos_interface:
|
||||
|
@ -123,7 +126,6 @@ EXAMPLES = """
|
|||
speed: 1g
|
||||
mtu: 256
|
||||
duplex: full
|
||||
enabled: True
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
|
@ -172,7 +174,7 @@ def main():
|
|||
argument_spec = dict(
|
||||
name=dict(required=True),
|
||||
description=dict(),
|
||||
enabled=dict(default=True, type='bool'),
|
||||
enabled=dict(),
|
||||
speed=dict(),
|
||||
mtu=dict(type='int'),
|
||||
duplex=dict(choices=['full', 'half', 'auto']),
|
||||
|
@ -181,7 +183,8 @@ def main():
|
|||
collection=dict(),
|
||||
purge=dict(default=False, type='bool'),
|
||||
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)
|
||||
|
@ -200,18 +203,26 @@ def main():
|
|||
top = 'interfaces/interface'
|
||||
|
||||
param_to_xpath_map = collections.OrderedDict()
|
||||
param_to_xpath_map.update({
|
||||
'name': {'xpath': 'name', 'is_key': True},
|
||||
'description': 'description',
|
||||
'speed': 'speed',
|
||||
'mtu': 'mtu',
|
||||
'enabled': {'xpath': 'disable', 'tag_only': True},
|
||||
'duplex': 'link-mode'
|
||||
})
|
||||
param_to_xpath_map.update([
|
||||
('name', {'xpath': 'name', 'is_key': True}),
|
||||
('description', 'description'),
|
||||
('speed', 'speed'),
|
||||
('mtu', 'mtu'),
|
||||
('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 = {
|
||||
'link-mode': {'full': 'full-duplex', 'half': 'half-duplex', 'auto': 'automatic'},
|
||||
'disable': {True: False, False: True}
|
||||
'link-mode': {'full': 'full-duplex', 'half': 'half-duplex', 'auto': 'automatic'}
|
||||
}
|
||||
|
||||
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
|
||||
in the device active configuration
|
||||
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:
|
||||
- ncclient (>=v0.5.2)
|
||||
notes:
|
||||
|
@ -137,8 +142,8 @@ def main():
|
|||
domain_name=dict(),
|
||||
domain_search=dict(type='list'),
|
||||
name_servers=dict(type='list'),
|
||||
|
||||
state=dict(choices=['present', 'absent', 'active', 'suspend'], default='present')
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
active=dict(default=True, type='bool')
|
||||
)
|
||||
|
||||
argument_spec.update(junos_argument_spec)
|
||||
|
@ -164,12 +169,12 @@ def main():
|
|||
top = 'system'
|
||||
|
||||
param_to_xpath_map = collections.OrderedDict()
|
||||
param_to_xpath_map.update({
|
||||
'hostname': {'xpath': 'host-name', 'leaf_only': True},
|
||||
'domain_name': {'xpath': 'domain-name', 'leaf_only': True},
|
||||
'domain_search': {'xpath': 'domain-search', 'leaf_only': True, 'value_req': True},
|
||||
'name_servers': {'xpath': 'name-server/name', 'is_key': True}
|
||||
})
|
||||
param_to_xpath_map.update([
|
||||
('hostname', {'xpath': 'host-name', 'leaf_only': True}),
|
||||
('domain_name', {'xpath': 'domain-name', 'leaf_only': True}),
|
||||
('domain_search', {'xpath': 'domain-search', 'leaf_only': True, 'value_req': True}),
|
||||
('name_servers', {'xpath': 'name-server/name', 'is_key': True})
|
||||
])
|
||||
|
||||
validate_param_values(module, param_to_xpath_map)
|
||||
|
||||
|
|
|
@ -59,7 +59,12 @@ options:
|
|||
description:
|
||||
- State of the VLAN configuration.
|
||||
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:
|
||||
- ncclient (>=v0.5.2)
|
||||
notes:
|
||||
|
@ -82,12 +87,14 @@ EXAMPLES = """
|
|||
- name: deactive VLAN configuration
|
||||
junos_vlan:
|
||||
vlan_name: test
|
||||
state: suspend
|
||||
state: present
|
||||
active: False
|
||||
|
||||
- name: activate VLAN configuration
|
||||
junos_vlan:
|
||||
vlan_name: test
|
||||
state: active
|
||||
state: present
|
||||
active: True
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
|
@ -134,8 +141,8 @@ def main():
|
|||
interfaces=dict(),
|
||||
collection=dict(),
|
||||
purge=dict(default=False, type='bool'),
|
||||
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)
|
||||
|
@ -154,11 +161,11 @@ def main():
|
|||
top = 'vlans/vlan'
|
||||
|
||||
param_to_xpath_map = collections.OrderedDict()
|
||||
param_to_xpath_map.update({
|
||||
'name': {'xpath': 'name', 'is_key': True},
|
||||
'vlan_id': 'vlan-id',
|
||||
'description': 'description'
|
||||
})
|
||||
param_to_xpath_map.update([
|
||||
('name', {'xpath': 'name', 'is_key': True}),
|
||||
('vlan_id', 'vlan-id'),
|
||||
('description', 'description')
|
||||
])
|
||||
|
||||
validate_param_values(module, param_to_xpath_map)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue