����JFIF��������� Mr.X
  
  __  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

deexcl@216.73.217.71: ~ $
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import absolute_import, division, print_function


__metaclass__ = type


DOCUMENTATION = """
module: nxos_system
extends_documentation_fragment:
- cisco.nxos.nxos
author: Peter Sprygada (@privateip)
short_description: Manage the system attributes on Cisco NXOS devices
notes:
- Unsupported for Cisco MDS
description:
- This module provides declarative management of node system attributes on Cisco NXOS
  devices.  It provides an option to configure host system parameters or remove those
  parameters from the device active configuration.
version_added: 1.0.0
options:
  hostname:
    description:
    - Configure the device hostname parameter. This option takes an ASCII string value
      or keyword 'default'
    type: str
  domain_name:
    description:
    - Configures the default domain name suffix to be used when referencing this node
      by its FQDN.  This argument accepts either a list of domain names or a list
      of dicts that configure the domain name and VRF name or keyword 'default'. See
      examples.
    type: list
    elements: raw
  domain_lookup:
    description:
    - Enables or disables the DNS lookup feature in Cisco NXOS.  This argument accepts
      boolean values.  When enabled, the system will try to resolve hostnames using
      DNS and when disabled, hostnames will not be resolved.
    type: bool
  domain_search:
    description:
    - Configures a list of domain name suffixes to search when performing DNS name
      resolution. This argument accepts either a list of domain names or a list of
      dicts that configure the domain name and VRF name or keyword 'default'. See
      examples.
    type: list
    elements: raw
  name_servers:
    description:
    - List of DNS name servers by IP address to use to perform name resolution lookups.  This
      argument accepts either a list of DNS servers or a list of hashes that configure
      the name server and VRF name or keyword 'default'. See examples.
    type: list
    elements: raw
  system_mtu:
    description:
    - Specifies the mtu, must be an integer or keyword 'default'.
    type: str
  state:
    description:
    - State of the configuration values in the device's current active configuration.  When
      set to I(present), the values should be configured in the device active configuration
      and when set to I(absent) the values should not be in the device active configuration
    default: present
    choices:
    - present
    - absent
    type: str
"""

EXAMPLES = """
- name: configure hostname and domain-name
  cisco.nxos.nxos_system:
    hostname: nxos01
    domain_name: test.example.com

- name: remove configuration
  cisco.nxos.nxos_system:
    state: absent

- name: configure name servers
  cisco.nxos.nxos_system:
    name_servers:
    - 8.8.8.8
    - 8.8.4.4

- name: configure name servers with VRF support
  cisco.nxos.nxos_system:
    name_servers:
    - {server: 8.8.8.8, vrf: mgmt}
    - {server: 8.8.4.4, vrf: mgmt}
"""

RETURN = """
commands:
  description: The list of configuration mode commands to send to the device
  returned: always
  type: list
  sample:
    - hostname nxos01
    - ip domain-name test.example.com
"""
import re

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import (
    NetworkConfig,
)
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import (
    ComplexList,
)

from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import (
    get_config,
    load_config,
)


_CONFIGURED_VRFS = None


def has_vrf(module, vrf):
    global _CONFIGURED_VRFS
    if _CONFIGURED_VRFS is not None:
        return vrf in _CONFIGURED_VRFS
    config = get_config(module)
    _CONFIGURED_VRFS = re.findall(r"vrf context (\S+)", config)
    return vrf in _CONFIGURED_VRFS


def map_obj_to_commands(want, have, module):
    commands = list()
    state = module.params["state"]

    def needs_update(x):
        return want.get(x) and (want.get(x) != have.get(x))

    def difference(x, y, z):
        return [item for item in x[z] if item not in y[z]]

    def remove(cmd, commands, vrf=None):
        if vrf:
            commands.append("vrf context %s" % vrf)
        commands.append(cmd)
        if vrf:
            commands.append("exit")

    def add(cmd, commands, vrf=None):
        if vrf:
            if not has_vrf(module, vrf):
                module.fail_json(msg="invalid vrf name %s" % vrf)
        return remove(cmd, commands, vrf)

    if state == "absent":
        if have["hostname"]:
            commands.append("no hostname")

        for item in have["domain_name"]:
            cmd = "no ip domain-name %s" % item["name"]
            remove(cmd, commands, item["vrf"])

        for item in have["domain_search"]:
            cmd = "no ip domain-list %s" % item["name"]
            remove(cmd, commands, item["vrf"])

        for item in have["name_servers"]:
            cmd = "no ip name-server %s" % item["server"]
            remove(cmd, commands, item["vrf"])

        if have["system_mtu"]:
            commands.append("no system jumbomtu")

    if state == "present":
        if needs_update("hostname"):
            if want["hostname"] == "default":
                if have["hostname"]:
                    commands.append("no hostname")
            else:
                commands.append("hostname %s" % want["hostname"])

        if want.get("domain_lookup") is not None:
            if have.get("domain_lookup") != want.get("domain_lookup"):
                cmd = "ip domain-lookup"
                if want["domain_lookup"] is False:
                    cmd = "no %s" % cmd
                commands.append(cmd)

        if want["domain_name"]:
            if want.get("domain_name")[0]["name"] == "default":
                if have["domain_name"]:
                    for item in have["domain_name"]:
                        cmd = "no ip domain-name %s" % item["name"]
                        remove(cmd, commands, item["vrf"])
            else:
                for item in difference(have, want, "domain_name"):
                    cmd = "no ip domain-name %s" % item["name"]
                    remove(cmd, commands, item["vrf"])
                for item in difference(want, have, "domain_name"):
                    cmd = "ip domain-name %s" % item["name"]
                    add(cmd, commands, item["vrf"])

        if want["domain_search"]:
            if want.get("domain_search")[0]["name"] == "default":
                if have["domain_search"]:
                    for item in have["domain_search"]:
                        cmd = "no ip domain-list %s" % item["name"]
                        remove(cmd, commands, item["vrf"])
            else:
                for item in difference(have, want, "domain_search"):
                    cmd = "no ip domain-list %s" % item["name"]
                    remove(cmd, commands, item["vrf"])
                for item in difference(want, have, "domain_search"):
                    cmd = "ip domain-list %s" % item["name"]
                    add(cmd, commands, item["vrf"])

        if want["name_servers"]:
            if want.get("name_servers")[0]["server"] == "default":
                if have["name_servers"]:
                    for item in have["name_servers"]:
                        cmd = "no ip name-server %s" % item["server"]
                        remove(cmd, commands, item["vrf"])
            else:
                for item in difference(have, want, "name_servers"):
                    cmd = "no ip name-server %s" % item["server"]
                    remove(cmd, commands, item["vrf"])
                for item in difference(want, have, "name_servers"):
                    cmd = "ip name-server %s" % item["server"]
                    add(cmd, commands, item["vrf"])

        if needs_update("system_mtu"):
            if want["system_mtu"] == "default":
                if have["system_mtu"]:
                    commands.append("no system jumbomtu")
            else:
                commands.append("system jumbomtu %s" % want["system_mtu"])

    return commands


def parse_hostname(config):
    match = re.search(r"^hostname (\S+)", config, re.M)
    if match:
        return match.group(1)


def parse_domain_name(config, vrf_config):
    objects = list()
    match = re.search(r"^ip domain-name (\S+)", config, re.M)
    if match:
        objects.append({"name": match.group(1), "vrf": None})

    for vrf, cfg in iteritems(vrf_config):
        match = re.search(r"ip domain-name (\S+)", cfg, re.M)
        if match:
            objects.append({"name": match.group(1), "vrf": vrf})

    return objects


def parse_domain_search(config, vrf_config):
    objects = list()

    for item in re.findall(r"^ip domain-list (\S+)", config, re.M):
        objects.append({"name": item, "vrf": None})

    for vrf, cfg in iteritems(vrf_config):
        for item in re.findall(r"ip domain-list (\S+)", cfg, re.M):
            objects.append({"name": item, "vrf": vrf})

    return objects


def parse_name_servers(config, vrf_config, vrfs):
    objects = list()

    match = re.search("^ip name-server (.+)$", config, re.M)
    if match and "use-vrf" not in match.group(1):
        for addr in match.group(1).split(" "):
            objects.append({"server": addr, "vrf": None})

    for vrf, cfg in iteritems(vrf_config):
        vrf_match = re.search("ip name-server (.+)", cfg, re.M)
        if vrf_match:
            for addr in vrf_match.group(1).split(" "):
                objects.append({"server": addr, "vrf": vrf})

    return objects


def parse_system_mtu(config):
    match = re.search(r"^system jumbomtu (\d+)", config, re.M)
    if match:
        return match.group(1)


def map_config_to_obj(module):
    config = get_config(module)
    configobj = NetworkConfig(indent=2, contents=config)

    vrf_config = {}

    vrfs = re.findall(r"^vrf context (\S+)$", config, re.M)
    for vrf in vrfs:
        config_data = configobj.get_block_config(path=["vrf context %s" % vrf])
        vrf_config[vrf] = config_data

    return {
        "hostname": parse_hostname(config),
        "domain_lookup": "no ip domain-lookup" not in config,
        "domain_name": parse_domain_name(config, vrf_config),
        "domain_search": parse_domain_search(config, vrf_config),
        "name_servers": parse_name_servers(config, vrf_config, vrfs),
        "system_mtu": parse_system_mtu(config),
    }


def map_params_to_obj(module):
    obj = {
        "hostname": module.params["hostname"],
        "domain_lookup": module.params["domain_lookup"],
        "system_mtu": module.params["system_mtu"],
    }

    domain_name = ComplexList(dict(name=dict(key=True), vrf=dict()), module)

    domain_search = ComplexList(dict(name=dict(key=True), vrf=dict()), module)

    name_servers = ComplexList(dict(server=dict(key=True), vrf=dict()), module)

    for arg, cast in [
        ("domain_name", domain_name),
        ("domain_search", domain_search),
        ("name_servers", name_servers),
    ]:
        if module.params[arg] is not None:
            obj[arg] = cast(module.params[arg])
        else:
            obj[arg] = None

    return obj


def main():
    """main entry point for module execution"""
    argument_spec = dict(
        hostname=dict(),
        domain_lookup=dict(type="bool"),
        # { name: <str>, vrf: <str> }
        domain_name=dict(type="list", elements="raw"),
        # {name: <str>, vrf: <str> }
        domain_search=dict(type="list", elements="raw"),
        # { server: <str>; vrf: <str> }
        name_servers=dict(type="list", elements="raw"),
        system_mtu=dict(type="str"),
        state=dict(default="present", choices=["present", "absent"]),
    )

    module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)

    warnings = list()

    result = {"changed": False}
    if warnings:
        result["warnings"] = warnings

    want = map_params_to_obj(module)
    have = map_config_to_obj(module)

    commands = map_obj_to_commands(want, have, module)
    result["commands"] = commands

    if commands:
        if not module.check_mode:
            load_config(module, commands)
        result["changed"] = True

    module.exit_json(**result)


if __name__ == "__main__":
    main()

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
storage Folder 0755
__init__.py File 0 B 0644
nxos_aaa_server.py File 10.19 KB 0644
nxos_aaa_server_host.py File 10.92 KB 0644
nxos_acl_interfaces.py File 10.21 KB 0644
nxos_acls.py File 28.71 KB 0644
nxos_banner.py File 6.44 KB 0644
nxos_bfd_global.py File 9.08 KB 0644
nxos_bfd_interfaces.py File 6.84 KB 0644
nxos_bgp.py File 25.3 KB 0644
nxos_bgp_address_family.py File 30.41 KB 0644
nxos_bgp_af.py File 31.01 KB 0644
nxos_bgp_global.py File 48.43 KB 0644
nxos_bgp_neighbor.py File 18.79 KB 0644
nxos_bgp_neighbor_address_family.py File 33.62 KB 0644
nxos_bgp_neighbor_af.py File 26.84 KB 0644
nxos_command.py File 7.41 KB 0644
nxos_config.py File 22.51 KB 0644
nxos_devicealias.py File 18.33 KB 0644
nxos_evpn_global.py File 2.62 KB 0644
nxos_evpn_vni.py File 9.44 KB 0644
nxos_facts.py File 8.52 KB 0644
nxos_feature.py File 9.21 KB 0644
nxos_file_copy.py File 17.39 KB 0644
nxos_gir.py File 11.5 KB 0644
nxos_gir_profile_management.py File 5.84 KB 0644
nxos_hostname.py File 5.63 KB 0644
nxos_hsrp.py File 15.02 KB 0644
nxos_hsrp_interfaces.py File 6.16 KB 0644
nxos_igmp.py File 4.49 KB 0644
nxos_igmp_interface.py File 21.88 KB 0644
nxos_igmp_snooping.py File 9.72 KB 0644
nxos_install_os.py File 21.07 KB 0644
nxos_interfaces.py File 13.69 KB 0644
nxos_l2_interfaces.py File 12.05 KB 0644
nxos_l3_interfaces.py File 15.12 KB 0644
nxos_lacp.py File 6.39 KB 0644
nxos_lacp_interfaces.py File 9.13 KB 0644
nxos_lag_interfaces.py File 8.66 KB 0644
nxos_lldp_global.py File 8.68 KB 0644
nxos_lldp_interfaces.py File 6.21 KB 0644
nxos_logging.py File 27.52 KB 0644
nxos_logging_global.py File 21.08 KB 0644
nxos_ntp.py File 12.98 KB 0644
nxos_ntp_auth.py File 9.17 KB 0644
nxos_ntp_global.py File 19.63 KB 0644
nxos_ntp_options.py File 4.53 KB 0644
nxos_nxapi.py File 14.01 KB 0644
nxos_ospf_interfaces.py File 43.32 KB 0644
nxos_ospfv2.py File 62.64 KB 0644
nxos_ospfv3.py File 53.01 KB 0644
nxos_overlay_global.py File 5.64 KB 0644
nxos_pim.py File 6.15 KB 0644
nxos_pim_interface.py File 19.74 KB 0644
nxos_pim_rp_address.py File 7.61 KB 0644
nxos_ping.py File 7.05 KB 0644
nxos_prefix_lists.py File 26.39 KB 0644
nxos_reboot.py File 2.24 KB 0644
nxos_rollback.py File 3.51 KB 0644
nxos_route_maps.py File 57.7 KB 0644
nxos_rpm.py File 12.29 KB 0644
nxos_snapshot.py File 12.17 KB 0644
nxos_snmp_community.py File 6.6 KB 0644
nxos_snmp_contact.py File 3.81 KB 0644
nxos_snmp_host.py File 15.1 KB 0644
nxos_snmp_location.py File 3.91 KB 0644
nxos_snmp_server.py File 50.27 KB 0644
nxos_snmp_traps.py File 7.97 KB 0644
nxos_snmp_user.py File 12.34 KB 0644
nxos_static_routes.py File 20.79 KB 0644
nxos_system.py File 12.77 KB 0644
nxos_telemetry.py File 8.98 KB 0644
nxos_udld.py File 7.09 KB 0644
nxos_udld_interface.py File 8.51 KB 0644
nxos_user.py File 15.37 KB 0644
nxos_vlans.py File 10.6 KB 0644
nxos_vpc.py File 15.59 KB 0644
nxos_vpc_interface.py File 9.92 KB 0644
nxos_vrf.py File 19.78 KB 0644
nxos_vrf_af.py File 7.71 KB 0644
nxos_vrf_interface.py File 7.37 KB 0644
nxos_vrrp.py File 12 KB 0644
nxos_vsan.py File 10.8 KB 0644
nxos_vtp_domain.py File 5.73 KB 0644
nxos_vtp_password.py File 7.8 KB 0644
nxos_vtp_version.py File 5.54 KB 0644
nxos_vxlan_vtep.py File 16.86 KB 0644
nxos_vxlan_vtep_vni.py File 15.7 KB 0644
nxos_zone_zoneset.py File 33.96 KB 0644