@ -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 : tru e
required : fals e
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 : tru e
required : fals e
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_m odule( argument_spec = argument_spec ,
module = NetworkM odule( 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 . con nection. con figure ( commands , comment = comment )
module . con fig( 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 ( )