Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ desktop.ini

# VC Code
.vscode
ansible_collections/ansible
ansible_collections/ansible.netcommon-8.0.1.info
ansible_collections/ansible.utils-6.0.0.info
13 changes: 10 additions & 3 deletions ansible_collections/juniper/device/meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
requires_ansible: ">=2.17.0"
plugin_routing:
plugins:
modules:
hostname:
redirect: juniper.device.junos_hostname
Expand Down Expand Up @@ -44,8 +44,15 @@ plugin_routing:
redirect: juniper.device.junos_routing_instances
routing_options:
redirect: juniper.device.junos_routing_options
routing_options:
redirect: juniper.device.junos_routing_options
scp:
redirect: juniper.device.junos_scp
deprecation:
removal_date: "2025-01-01"
warning_text: See the plugin documentation for more details
junos_scp:
deprecation:
removal_date: "2025-01-01"
warning_text: See the plugin documentation for more details
security_policies:
redirect: juniper.device.junos_security_policies
security_policies_global:
Expand Down
28 changes: 26 additions & 2 deletions ansible_collections/juniper/device/plugins/action/hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@

__metaclass__ = type

DOCUMENTATION = r"""
---
module: hostname
short_description: Action plugin for hostname operations on Juniper devices
description:
- This action plugin handles hostname operations for Juniper devices.
- It provides the necessary connection setup and module routing.
version_added: "1.0.0"
author:
- Juniper Networks
notes:
- This is an action plugin that handles hostname operations.
"""

EXAMPLES = r"""
# This action plugin is used internally by hostname modules
# No direct usage examples as this is an action plugin
"""

RETURN = r"""
# This action plugin handles hostname operations
# Return values are handled by the calling module
"""

import copy
import sys

Expand All @@ -44,7 +68,7 @@

class ActionModule(ActionNetworkModule):
def run(self, tmp=None, task_vars=None):

del tmp # tmp no longer has any effect

module_name = self._task.action.split(".")[-1]
Expand All @@ -56,7 +80,7 @@ def run(self, tmp=None, task_vars=None):
if self._play_context.connection == "local":
provider = load_provider(junos_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)
#pc.network_os = "juniper.device.junos"
# pc.network_os = "juniper.device.junos"
pc.network_os = "juniper.device.device"
pc.remote_addr = provider["host"] or self._play_context.remote_addr

Expand Down
28 changes: 26 additions & 2 deletions ansible_collections/juniper/device/plugins/action/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@

__metaclass__ = type

DOCUMENTATION = r"""
---
module: junos
short_description: Action plugin for Junos operations on Juniper devices
description:
- This action plugin handles Junos operations for Juniper devices.
- It provides the necessary connection setup and module routing.
version_added: "1.0.0"
author:
- Juniper Networks
notes:
- This is an action plugin that handles Junos operations.
"""

EXAMPLES = r"""
# This action plugin is used internally by Junos modules
# No direct usage examples as this is an action plugin
"""

RETURN = r"""
# This action plugin handles Junos operations
# Return values are handled by the calling module
"""

import copy
import sys

Expand All @@ -44,7 +68,7 @@

class ActionModule(ActionNetworkModule):
def run(self, tmp=None, task_vars=None):

del tmp # tmp no longer has any effect

module_name = self._task.action.split(".")[-1]
Expand All @@ -56,7 +80,7 @@ def run(self, tmp=None, task_vars=None):
if self._play_context.connection == "local":
provider = load_provider(junos_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)
#pc.network_os = "juniper.device.junos"
# pc.network_os = "juniper.device.junos"
pc.network_os = "juniper.device.device"
pc.remote_addr = provider["host"] or self._play_context.remote_addr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@

class ActionModule(ActionNetworkModule):
def run(self, tmp=None, task_vars=None):

del tmp # tmp no longer has any effect

module_name = self._task.action.split(".")[-1]
#module_name = "device_facts"
#self._task.action = "device_facts"
# module_name = "device_facts"
# self._task.action = "device_facts"
self._task.collections.append("juniper.device")
self._config_module = True if module_name in ["junos_config", "config"] else False
persistent_connection = self._play_context.connection.split(".")[-1]
Expand Down
26 changes: 25 additions & 1 deletion ansible_collections/juniper/device/plugins/action/netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@

__metaclass__ = type

DOCUMENTATION = r"""
---
module: netconf
short_description: Action plugin for NETCONF operations on Juniper devices
description:
- This action plugin handles NETCONF operations for Juniper devices.
- It provides the necessary connection setup and module routing.
version_added: "1.0.0"
author:
- Juniper Networks
notes:
- This is an action plugin that handles NETCONF operations.
"""

EXAMPLES = r"""
# This action plugin is used internally by NETCONF modules
# No direct usage examples as this is an action plugin
"""

RETURN = r"""
# This action plugin handles NETCONF operations
# Return values are handled by the calling module
"""

import copy
import sys

Expand All @@ -44,7 +68,7 @@

class ActionModule(ActionNetworkModule):
def run(self, tmp=None, task_vars=None):

del tmp # tmp no longer has any effect

module_name = self._task.action.split(".")[-1]
Expand Down
20 changes: 20 additions & 0 deletions ansible_collections/juniper/device/plugins/doc_fragments/junos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function


__metaclass__ = type

# Copyright: (c) 2015, Peter Sprygada <[email protected]>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)


class ModuleDocFragment(object):
# Standard files documentation fragment
DOCUMENTATION = r"""options: {}
notes:
- For information on using CLI and netconf see the :ref:`Junos OS Platform Options
guide <junos_platform_options>`
- For more information on using Ansible to manage network devices see the :ref:`Ansible
Network Guide <network_guide>`
- For more information on using Ansible to manage Juniper network devices see U(https://www.ansible.com/ansible-juniper).
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

class AnsibleConnectionFailure(Exception):
"""Raised when connection to the device fails."""
pass
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,23 @@

import json
import re

from ansible.errors import AnsibleConnectionFailure
from .exceptions import AnsibleConnectionFailure
from ansible.module_utils._text import to_native, to_text
from ansible.module_utils.six import string_types
from ansible_collections.ansible.netcommon.plugins.plugin_utils.netconf_base import (
NetconfBase,
ensure_ncclient,
)

try:
from ansible_collections.ansible.netcommon.plugins.plugin_utils.netconf_base import (
NetconfBase,
ensure_ncclient,
)
HAS_NETCONF_BASE = True
except ImportError:
# Handle case where netconf_base is not available during testing
HAS_NETCONF_BASE = False
NetconfBase = object

def ensure_ncclient(func):
return func


try:
Expand Down Expand Up @@ -280,4 +289,4 @@ def commit(
if timeout:
subele = sub_ele(obj, "confirm-timeout")
subele.text = str(timeout)
return self.rpc(obj)
return self.rpc(obj)
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def __init__(self, **kwargs):
),
"gather_network_resources": dict(type="list", elements="str"),
"available_network_resources": {"type": "bool", "default": False},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,4 @@ def get_facts(
legacy_facts_type,
)

return self.ansible_facts, self._warnings
return self.ansible_facts, self._warnings
Original file line number Diff line number Diff line change
Expand Up @@ -533,4 +533,4 @@ def to_param_list(module):
else:
return aggregate
else:
return [module.params]
return [module.params]
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
}

DOCUMENTATION = """
---
module: junos_hostname
module: _tbrdevice_hostname
version_added: 2.9.0
short_description: Manage Hostname server configuration on Junos devices.
description: This module manages hostname configuration on devices running Junos.
Expand Down
Loading