Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/cli/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/cli/cli_config.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZddlmZd�Zd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatustnetworktsupported_bysl
---
module: cli_config
version_added: "2.7"
author: "Trishna Guha (@trishnaguha)"
short_description: Push text based configuration to network devices over network_cli
description:
  - This module provides platform agnostic way of pushing text based
    configuration to network devices over network_cli connection plugin.
extends_documentation_fragment: network_agnostic
options:
  config:
    description:
      - The config to be pushed to the network device. This argument
        is mutually exclusive with C(rollback) and either one of the
        option should be given as input. The config should have
        indentation that the device uses.
    type: 'str'
  commit:
    description:
      - The C(commit) argument instructs the module to push the
        configuration to the device. This is mapped to module check mode.
    type: 'bool'
  replace:
    description:
      - If the C(replace) argument is set to C(yes), it will replace
        the entire running-config of the device with the C(config)
        argument value. For devices that support replacing running
        configuration from file on device like NXOS/JUNOS, the
        C(replace) argument takes path to the file on the device
        that will be used for replacing the entire running-config.
        The value of C(config) option should be I(None) for such devices.
        Nexus 9K devices only support replace. Use I(net_put) or
        I(nxos_file_copy) in case of NXOS module to copy the flat file
        to remote device and then use set the fullpath to this argument.
    type: 'str'
  backup:
    description:
      - This argument will cause the module to create a full backup of
        the current running config from the remote device before any
        changes are made. If the C(backup_options) value is not given,
        the backup file is written to the C(backup) folder in the playbook
        root directory or role root directory, if playbook is part of an
        ansible role. If the directory does not exist, it is created.
    type: bool
    default: 'no'
    version_added: "2.8"
  rollback:
    description:
      - The C(rollback) argument instructs the module to rollback the
        current configuration to the identifier specified in the
        argument.  If the specified rollback identifier does not
        exist on the remote device, the module will fail. To rollback
        to the most recent commit, set the C(rollback) argument to 0.
        This option is mutually exclusive with C(config).
  commit_comment:
    description:
      - The C(commit_comment) argument specifies a text string to be used
        when committing the configuration. If the C(commit) argument
        is set to False, this argument is silently ignored. This argument
        is only valid for the platforms that support commit operation
        with comment.
    type: 'str'
  defaults:
    description:
      - The I(defaults) argument will influence how the running-config
        is collected from the device.  When the value is set to true,
        the command used to collect the running-config is append with
        the all keyword.  When the value is set to false, the command
        is issued without the all keyword.
    default: 'no'
    type: 'bool'
  multiline_delimiter:
    description:
      - This argument is used when pushing a multiline configuration
        element to the device. It specifies the character to use as
        the delimiting character. This only applies to the configuration
        action.
    type: 'str'
  diff_replace:
    description:
      - Instructs the module on the way to perform the configuration
        on the device. If the C(diff_replace) argument is set to I(line)
        then the modified lines are pushed to the device in configuration
        mode. If the argument is set to I(block) then the entire command
        block is pushed to the device in configuration mode if any
        line is not correct. Note that this parameter will be ignored if
        the platform has onbox diff support.
    choices: ['line', 'block', 'config']
  diff_match:
    description:
      - Instructs the module on the way to perform the matching of
        the set of commands against the current device config. If C(diff_match)
        is set to I(line), commands are matched line by line. If C(diff_match)
        is set to I(strict), command lines are matched with respect to position.
        If C(diff_match) is set to I(exact), command lines must be an equal match.
        Finally, if C(diff_match) is set to I(none), the module will not attempt
        to compare the source configuration with the running configuration on the
        remote device. Note that this parameter will be ignored if the platform
        has onbox diff support.
    choices: ['line', 'strict', 'exact', 'none']
  diff_ignore_lines:
    description:
      - Use this argument to specify one or more lines that should be
        ignored during the diff. This is used for lines in the configuration
        that are automatically updated by the system. This argument takes
        a list of regular expressions or exact line matches.
        Note that this parameter will be ignored if the platform has onbox
        diff support.
  backup_options:
    description:
      - This is a dict object containing configurable options related to backup file path.
        The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
        to I(no) this option will be silently ignored.
    suboptions:
      filename:
        description:
          - The filename to be used to store the backup configuration. If the the filename
            is not given it will be generated based on the hostname, current time and date
            in format defined by <hostname>_config.<current-date>@<current-time>
      dir_path:
        description:
          - This option provides the path ending with directory name in which the backup
            configuration file will be stored. If the directory does not exist it will be first
            created and the filename is either the value of C(filename) or default filename
            as described in C(filename) options description. If the path value is not given
            in that case a I(backup) directory will be created in the current working directory
            and backup configuration will be copied in C(filename) within I(backup) directory.
        type: path
    type: dict
    version_added: "2.8"
s�
- name: configure device with config
  cli_config:
    config: "{{ lookup('template', 'basic/config.j2') }}"

- name: multiline config
  cli_config:
    config: |
      hostname foo
      feature nxapi

- name: configure device with config with defaults enabled
  cli_config:
    config: "{{ lookup('template', 'basic/config.j2') }}"
    defaults: yes

- name: Use diff_match
  cli_config:
    config: "{{ lookup('file', 'interface_config') }}"
    diff_match: none

- name: nxos replace config
  cli_config:
    replace: 'bootflash:nxoscfg'

- name: junos replace config
  cli_config:
    replace: '/var/home/ansible/junos01.cfg'

- name: commit with comment
  cli_config:
    config: set system host-name foo
    commit_comment: this is a test

- name: configurable backup path
  cli_config:
    config: "{{ lookup('template', 'basic/config.j2') }}"
    backup: yes
    backup_options:
      filename: backup.cfg
      dir_path: /home/user
sZ
commands:
  description: The set of commands that will be pushed to the remote device
  returned: always
  type: list
  sample: ['interface Loopback999', 'no shutdown']
backup_path:
  description: The full path to the backup file
  returned: when backup is yes
  type: str
  sample: /playbooks/ansible/backup/hostname_config.2016-07-16@22:28:34
N(t
AnsibleModule(t
Connection(tto_textcC`s�ddddddddg}xn|D]f}|j|r%|jd	|�}|d
krk|jd
|�q�|s�|jdd|�q�q%q%Wd
S(s6validate param if it is supported on the platform
    treplacetrollbacktcommit_commenttdefaultstmultiline_delimitertdiff_replacet
diff_matchtdiff_ignore_linesssupports_%ss}This platform does not specify whether %s is supported or not. Please report an issue against this platform's cliconf plugin.tmsgs+Option %s is not supported on this platformN(tparamstgettNonet	fail_json(tmoduletdevice_operationstfeature_listtfeaturetsupports_feature((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/cli/cli_config.pyt
validate_args�s

cC`si}i}g}i}	|jd}
|jd}|jd}|jd}
|jd}|jd}|j}|
dkr�t}
n|
d kr�t}
n|
dk	r�|
ttgkr�|dk	r�|jd
d|
�n|dk	r|j||�}d|krct|d<qcnN|jd�r�|
r:|jd�n|rP|jd�n|rf|jd�n|r�t	|t
�r�|jd�j�}ni|d6|d6|
d6|d6}|j
|�}d|krct|d<qcn�|jd�rci|d6|d6}|r!|ji|d6�n|
r>|ji|
d6�n|r[|ji|d6�n|j|�}|jd�}|jd�}	|r�t	|t
�r�|}n|j�}i|d6|d6|
d6|d6}|r�|j
|�nt|d<n|	rctj|	�}i|d6|d6}|r=|ji|d6�n|rS|j|�nt|d<qcn|jr�d|kr�i|dd6|d<q�d}|r�t	|t
�r�|dj|�7}q�||7}n|	r�|tj|	�7}ni|d6|d<n|S(!NRR
RRRRtyesttruetTruetnotfalsetFalseRs�Replace value '%s' is a configuration file path already present on the device. Hence 'replace' and 'config' options are mutually exclusivetdifftchangedtsupports_onbox_diffs9diff_replace is ignored as the device supports onbox diffs8diff_mattch is ignored as the device supports onbox diffs>diff_ignore_lines is ignored as the device supports onbox diffs
t	candidatetcommittcommenttsupports_generate_difftrunningtconfig_difftbanner_difftpreparedt(syesRsTrue(R!R"sFalse(Rt
check_modeR R#RRRRtwarnt
isinstancetlisttstript
splitlinestedit_configtupdatetget_difftjsontdumpstedit_bannert_difftjoin(RRt
connectionR'R+trollback_idtresulttrespR,R-RR
RRRRR(tkwargst
diff_responseR$((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/cli/cli_config.pytrun�s�






		*
	

	
cC`s�tdt�dtdd��}tdtdtdd�dtdd	d
|�dtdd�d
tdd�dtdd�dtdd�dtdd�dtdtdd�dtdd�dtddddg�dtdddddg�dtdd��}d-g}dddgg}td|d|d |d!t�}itd"6}t|j�}|j|j��}|r�|jd#t��}t	||�n	t�}|j
dr�d$|jd%�kr�|j�}	q�d&}	ng}	|j
d}
|
rt|
d'd(�nd,}
|jd)|	�}|j
d}|j
drJ||d*<n|
sc|sc|j
dr�y&|jt||||
||��Wq�tk
r�}
|jd+t|
��q�Xn|j|�d,S(.s#main entry point for execution
    tfilenametdir_pathttypetpathtbackuptdefaulttbooltbackup_optionstdicttoptionstconfigtstrR(RRtintR
RRRtchoicestlinetblockRtstricttexacttnoneRR3t
argument_spectmutually_exclusivetrequired_one_oftsupports_check_modeR%Rtget_default_flagtrpctallterrorstsurrogate_then_replacetflagst
__backup__RN(ROR(RMR#RR R	t_socket_patht	from_jsontget_capabilitiesRRRR\R
Rt
get_configR7RDt	ExceptionRt	exit_json(tbackup_specRXRYRZRR@R>tcapabilitiesRRaR'R+R?texc((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/cli/cli_config.pytmainMs\			
	
	



&t__main__(t
__future__RRRRGt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR9tansible.module_utils.basicRtansible.module_utils.connectionR	tansible.module_utils._textR
RRDRlt__name__(((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/cli/cli_config.pyt<module>s 


�+
		e	B

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]