mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Junos provider readd (#21869)
* Restore `provider` to junos_* Fixes #21824 Fixes #21824 Fixes #21827 * Fix `confirm_timeout` related errors * Fix glaring issues with _junos_template
This commit is contained in:
parent
85fc930066
commit
d9d2e6deb6
5 changed files with 32 additions and 17 deletions
|
@ -205,7 +205,7 @@ def load_config(module, config, commit=False, comment=None,
|
||||||
cmd = 'commit'
|
cmd = 'commit'
|
||||||
if commit:
|
if commit:
|
||||||
cmd = 'commit confirmed'
|
cmd = 'commit confirmed'
|
||||||
if commit_timeout:
|
if confirm_timeout:
|
||||||
cmd +' %s' % confirm_timeout
|
cmd +' %s' % confirm_timeout
|
||||||
if comment:
|
if comment:
|
||||||
cmd += ' comment "%s"' % comment
|
cmd += ' comment "%s"' % comment
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'status': ['deprecated'],
|
ANSIBLE_METADATA = {
|
||||||
'supported_by': 'community',
|
'status': ['deprecated'],
|
||||||
'version': '1.0'}
|
'supported_by': 'community',
|
||||||
|
'version': '1.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = """
|
DOCUMENTATION = """
|
||||||
|
@ -108,10 +110,11 @@ EXAMPLES = """
|
||||||
src: config.j2
|
src: config.j2
|
||||||
action: overwrite
|
action: overwrite
|
||||||
"""
|
"""
|
||||||
import ansible.module_utils.junos
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import get_exception
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.network import NetworkModule, NetworkError
|
from ansible.module_utils.junos import check_args, junos_argument_spec
|
||||||
|
from ansible.module_utils.junos import get_configuration, load
|
||||||
|
from ansible.module_utils.six import text_type
|
||||||
|
|
||||||
DEFAULT_COMMENT = 'configured by junos_template'
|
DEFAULT_COMMENT = 'configured by junos_template'
|
||||||
|
|
||||||
|
@ -127,9 +130,16 @@ def main():
|
||||||
transport=dict(default='netconf', choices=['netconf'])
|
transport=dict(default='netconf', choices=['netconf'])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
argument_spec.update(junos_argument_spec)
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=argument_spec,
|
module = AnsibleModule(argument_spec=argument_spec,
|
||||||
supports_check_mode=True)
|
supports_check_mode=True)
|
||||||
|
|
||||||
|
warnings = list()
|
||||||
|
check_args(module, warnings)
|
||||||
|
|
||||||
|
result = {'changed': False, 'warnings': warnings}
|
||||||
|
|
||||||
comment = module.params['comment']
|
comment = module.params['comment']
|
||||||
confirm = module.params['confirm']
|
confirm = module.params['confirm']
|
||||||
commit = not module.check_mode
|
commit = not module.check_mode
|
||||||
|
@ -141,18 +151,16 @@ def main():
|
||||||
module.fail_json(msg="overwrite cannot be used when format is "
|
module.fail_json(msg="overwrite cannot be used when format is "
|
||||||
"set per junos-pyez documentation")
|
"set per junos-pyez documentation")
|
||||||
|
|
||||||
results = {'changed': False}
|
if module.params['backup']:
|
||||||
|
result['__backup__'] = text_type(get_configuration(module))
|
||||||
|
|
||||||
if module.praams['backup']:
|
diff = load(module, src, action=action, commit=commit, format=fmt)
|
||||||
results['__backup__'] = unicode(get_configuration(module))
|
|
||||||
|
|
||||||
diff = load(module, src, **kwargs)
|
|
||||||
if diff:
|
if diff:
|
||||||
results['changed'] = True
|
result['changed'] = True
|
||||||
if module._diff:
|
if module._diff:
|
||||||
results['diff'] = {'prepared': diff}
|
result['diff'] = {'prepared': diff}
|
||||||
|
|
||||||
module.exit_json(**results)
|
module.exit_json(**result)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -180,6 +180,8 @@ from xml.etree import ElementTree
|
||||||
from ncclient.xml_ import to_xml
|
from ncclient.xml_ import to_xml
|
||||||
|
|
||||||
from ansible.module_utils.junos import get_diff, load
|
from ansible.module_utils.junos import get_diff, load
|
||||||
|
from ansible.module_utils.junos import junos_argument_spec
|
||||||
|
from ansible.module_utils.junos import check_args as junos_check_args
|
||||||
from ansible.module_utils.junos import locked_config, load_configuration
|
from ansible.module_utils.junos import locked_config, load_configuration
|
||||||
from ansible.module_utils.junos import get_configuration
|
from ansible.module_utils.junos import get_configuration
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
@ -188,6 +190,7 @@ from ansible.module_utils.netcfg import NetworkConfig
|
||||||
DEFAULT_COMMENT = 'configured by junos_config'
|
DEFAULT_COMMENT = 'configured by junos_config'
|
||||||
|
|
||||||
def check_args(module, warnings):
|
def check_args(module, warnings):
|
||||||
|
junos_check_args(module, warnings)
|
||||||
if module.params['zeroize']:
|
if module.params['zeroize']:
|
||||||
module.fail_json(msg='argument zeroize is deprecated and no longer '
|
module.fail_json(msg='argument zeroize is deprecated and no longer '
|
||||||
'supported, use junos_command instead')
|
'supported, use junos_command instead')
|
||||||
|
@ -252,7 +255,7 @@ def load_config(module):
|
||||||
|
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'confirm': module.params['confirm'] is not None,
|
'confirm': module.params['confirm'] is not None,
|
||||||
'confirm_timeout': module.params['confirm_timeout'],
|
'confirm_timeout': module.params['confirm'],
|
||||||
'comment': module.params['comment'],
|
'comment': module.params['comment'],
|
||||||
'commit': not module.check_mode,
|
'commit': not module.check_mode,
|
||||||
}
|
}
|
||||||
|
@ -317,6 +320,8 @@ def main():
|
||||||
zeroize=dict(default=False, type='bool'),
|
zeroize=dict(default=False, type='bool'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
argument_spec.update(junos_argument_spec)
|
||||||
|
|
||||||
mutually_exclusive = [('lines', 'src', 'rollback')]
|
mutually_exclusive = [('lines', 'src', 'rollback')]
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=argument_spec,
|
module = AnsibleModule(argument_spec=argument_spec,
|
||||||
|
|
|
@ -144,6 +144,8 @@ def main():
|
||||||
state=dict(default='present', choices=['present', 'absent']),
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
argument_spec.update(junos_argument_spec)
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=argument_spec,
|
module = AnsibleModule(argument_spec=argument_spec,
|
||||||
supports_check_mode=True)
|
supports_check_mode=True)
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class ActionModule(_ActionModule):
|
||||||
|
|
||||||
if self._play_context.connection != 'local':
|
if self._play_context.connection != 'local':
|
||||||
return dict(
|
return dict(
|
||||||
fail=True,
|
failed=True,
|
||||||
msg='invalid connection specified, expected connection=local, '
|
msg='invalid connection specified, expected connection=local, '
|
||||||
'got %s' % self._play_context.connection
|
'got %s' % self._play_context.connection
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue