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'
|
||||
if commit:
|
||||
cmd = 'commit confirmed'
|
||||
if commit_timeout:
|
||||
if confirm_timeout:
|
||||
cmd +' %s' % confirm_timeout
|
||||
if comment:
|
||||
cmd += ' comment "%s"' % comment
|
||||
|
|
|
@ -16,9 +16,11 @@
|
|||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
ANSIBLE_METADATA = {'status': ['deprecated'],
|
||||
'supported_by': 'community',
|
||||
'version': '1.0'}
|
||||
ANSIBLE_METADATA = {
|
||||
'status': ['deprecated'],
|
||||
'supported_by': 'community',
|
||||
'version': '1.0'
|
||||
}
|
||||
|
||||
|
||||
DOCUMENTATION = """
|
||||
|
@ -108,10 +110,11 @@ EXAMPLES = """
|
|||
src: config.j2
|
||||
action: overwrite
|
||||
"""
|
||||
import ansible.module_utils.junos
|
||||
|
||||
from ansible.module_utils.basic import get_exception
|
||||
from ansible.module_utils.network import NetworkModule, NetworkError
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
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'
|
||||
|
||||
|
@ -127,9 +130,16 @@ def main():
|
|||
transport=dict(default='netconf', choices=['netconf'])
|
||||
)
|
||||
|
||||
argument_spec.update(junos_argument_spec)
|
||||
|
||||
module = AnsibleModule(argument_spec=argument_spec,
|
||||
supports_check_mode=True)
|
||||
|
||||
warnings = list()
|
||||
check_args(module, warnings)
|
||||
|
||||
result = {'changed': False, 'warnings': warnings}
|
||||
|
||||
comment = module.params['comment']
|
||||
confirm = module.params['confirm']
|
||||
commit = not module.check_mode
|
||||
|
@ -141,18 +151,16 @@ def main():
|
|||
module.fail_json(msg="overwrite cannot be used when format is "
|
||||
"set per junos-pyez documentation")
|
||||
|
||||
results = {'changed': False}
|
||||
if module.params['backup']:
|
||||
result['__backup__'] = text_type(get_configuration(module))
|
||||
|
||||
if module.praams['backup']:
|
||||
results['__backup__'] = unicode(get_configuration(module))
|
||||
|
||||
diff = load(module, src, **kwargs)
|
||||
diff = load(module, src, action=action, commit=commit, format=fmt)
|
||||
if diff:
|
||||
results['changed'] = True
|
||||
result['changed'] = True
|
||||
if module._diff:
|
||||
results['diff'] = {'prepared': diff}
|
||||
result['diff'] = {'prepared': diff}
|
||||
|
||||
module.exit_json(**results)
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -180,6 +180,8 @@ from xml.etree import ElementTree
|
|||
from ncclient.xml_ import to_xml
|
||||
|
||||
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 get_configuration
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -188,6 +190,7 @@ from ansible.module_utils.netcfg import NetworkConfig
|
|||
DEFAULT_COMMENT = 'configured by junos_config'
|
||||
|
||||
def check_args(module, warnings):
|
||||
junos_check_args(module, warnings)
|
||||
if module.params['zeroize']:
|
||||
module.fail_json(msg='argument zeroize is deprecated and no longer '
|
||||
'supported, use junos_command instead')
|
||||
|
@ -252,7 +255,7 @@ def load_config(module):
|
|||
|
||||
kwargs = {
|
||||
'confirm': module.params['confirm'] is not None,
|
||||
'confirm_timeout': module.params['confirm_timeout'],
|
||||
'confirm_timeout': module.params['confirm'],
|
||||
'comment': module.params['comment'],
|
||||
'commit': not module.check_mode,
|
||||
}
|
||||
|
@ -317,6 +320,8 @@ def main():
|
|||
zeroize=dict(default=False, type='bool'),
|
||||
)
|
||||
|
||||
argument_spec.update(junos_argument_spec)
|
||||
|
||||
mutually_exclusive = [('lines', 'src', 'rollback')]
|
||||
|
||||
module = AnsibleModule(argument_spec=argument_spec,
|
||||
|
|
|
@ -144,6 +144,8 @@ def main():
|
|||
state=dict(default='present', choices=['present', 'absent']),
|
||||
)
|
||||
|
||||
argument_spec.update(junos_argument_spec)
|
||||
|
||||
module = AnsibleModule(argument_spec=argument_spec,
|
||||
supports_check_mode=True)
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class ActionModule(_ActionModule):
|
|||
|
||||
if self._play_context.connection != 'local':
|
||||
return dict(
|
||||
fail=True,
|
||||
failed=True,
|
||||
msg='invalid connection specified, expected connection=local, '
|
||||
'got %s' % self._play_context.connection
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue