update junos_netconf module
Updates the junos_netconf module with changes to load the NetworkModule instead of the get_module factory method. This update is part of the 2.2 refactor of network modules
This commit is contained in:
parent
f5e62a0611
commit
7a234fc7cc
1 changed files with 18 additions and 8 deletions
|
@ -35,7 +35,7 @@ options:
|
||||||
- This argument specifies the port the netconf service should
|
- This argument specifies the port the netconf service should
|
||||||
listen on for SSH connections. The default port as defined
|
listen on for SSH connections. The default port as defined
|
||||||
in RFC 6242 is 830.
|
in RFC 6242 is 830.
|
||||||
required: true
|
required: false
|
||||||
default: 830
|
default: 830
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
|
@ -44,26 +44,39 @@ options:
|
||||||
I(present) the netconf service will be configured. If the
|
I(present) the netconf service will be configured. If the
|
||||||
I(state) argument is set to I(absent) the netconf service
|
I(state) argument is set to I(absent) the netconf service
|
||||||
will be removed from the configuration.
|
will be removed from the configuration.
|
||||||
required: true
|
required: false
|
||||||
default: present
|
default: present
|
||||||
choices: ['present', 'absent']
|
choices: ['present', 'absent']
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
# Note: examples below use the following provider dict to handle
|
||||||
|
# transport and authentication to the node.
|
||||||
|
vars:
|
||||||
|
netconf:
|
||||||
|
host: "{{ inventory_hostname }}"
|
||||||
|
username: ansible
|
||||||
|
password: Ansible
|
||||||
|
transport: netconf
|
||||||
|
|
||||||
- name: enable netconf service on port 830
|
- name: enable netconf service on port 830
|
||||||
junos_netconf:
|
junos_netconf:
|
||||||
listens_on: 830
|
listens_on: 830
|
||||||
state: present
|
state: present
|
||||||
|
provider: "{{ netconf }}"
|
||||||
|
|
||||||
- name: disable netconf service
|
- name: disable netconf service
|
||||||
junos_netconf:
|
junos_netconf:
|
||||||
state: absent
|
state: absent
|
||||||
|
provider: "{{ netconf }}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from ansible.module_utils.junos import NetworkModule
|
||||||
|
|
||||||
def parse_port(config):
|
def parse_port(config):
|
||||||
match = re.search(r'port (\d+)', config)
|
match = re.search(r'port (\d+)', config)
|
||||||
if match:
|
if match:
|
||||||
|
@ -88,7 +101,7 @@ def main():
|
||||||
transport=dict(default='cli', choices=['cli'])
|
transport=dict(default='cli', choices=['cli'])
|
||||||
)
|
)
|
||||||
|
|
||||||
module = get_module(argument_spec=argument_spec,
|
module = NetworkModule(argument_spec=argument_spec,
|
||||||
supports_check_mode=True)
|
supports_check_mode=True)
|
||||||
|
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
@ -109,14 +122,11 @@ def main():
|
||||||
if commands:
|
if commands:
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
comment = 'configuration updated by junos_netconf'
|
comment = 'configuration updated by junos_netconf'
|
||||||
module.connection.configure(commands, comment=comment)
|
module.config(commands, comment=comment)
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
from ansible.module_utils.shell import *
|
|
||||||
from ansible.module_utils.junos import *
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue