Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/system/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyo

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
mZdd
lmZd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�Zedkre�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatust	communitytsupported_bys�
---
module: interfaces_file
short_description: Tweak settings in /etc/network/interfaces files
extends_documentation_fragment: files
description:
     - Manage (add, remove, change) individual interface options in an interfaces-style file without having
       to manage the file as a whole with, say, M(template) or M(assemble). Interface has to be presented in a file.
     - Read information about interfaces from interfaces-styled files
version_added: "2.4"
options:
  dest:
    description:
      - Path to the interfaces file
    default: /etc/network/interfaces
  iface:
    description:
      - Name of the interface, required for value changes or option remove
  address_family:
    description:
      - Address family of the interface, useful if same interface name is used for both inet and inet6
    version_added: "2.8"
  option:
    description:
      - Name of the option, required for value changes or option remove
  value:
    description:
      - If I(option) is not presented for the I(interface) and I(state) is C(present) option will be added.
        If I(option) already exists and is not C(pre-up), C(up), C(post-up) or C(down), it's value will be updated.
        C(pre-up), C(up), C(post-up) and C(down) options can't be updated, only adding new options, removing existing
        ones or cleaning the whole option set are supported
  backup:
    description:
      - Create a backup file including the timestamp information so you can get
        the original file back if you somehow clobbered it incorrectly.
    type: bool
    default: 'no'
  state:
    description:
      - If set to C(absent) the option or section will be removed if present instead of created.
    default: "present"
    choices: [ "present", "absent" ]

notes:
   - If option is defined multiple times last one will be updated but all will be deleted in case of an absent state
requirements: []
author: "Roman Belyakovsky (@hryamzik)"
s�
dest:
    description: destination file/path
    returned: success
    type: str
    sample: "/etc/network/interfaces"
ifaces:
    description: interfaces dictionary
    returned: success
    type: complex
    contains:
      ifaces:
        description: interface dictionary
        returned: success
        type: dict
        contains:
          eth0:
            description: Name of the interface
            returned: success
            type: dict
            contains:
              address_family:
                description: interface address family
                returned: success
                type: str
                sample: "inet"
              method:
                description: interface method
                returned: success
                type: str
                sample: "manual"
              mtu:
                description: other options, all values returned as strings
                returned: success
                type: str
                sample: "1500"
              pre-up:
                description: list of C(pre-up) scripts
                returned: success
                type: list
                sample:
                  - "route add -net 10.10.10.0/24 gw 10.10.10.1 dev eth1"
                  - "route add -net 10.10.11.0/24 gw 10.10.11.1 dev eth2"
              up:
                description: list of C(up) scripts
                returned: success
                type: list
                sample:
                  - "route add -net 10.10.10.0/24 gw 10.10.10.1 dev eth1"
                  - "route add -net 10.10.11.0/24 gw 10.10.11.1 dev eth2"
              post-up:
                description: list of C(post-up) scripts
                returned: success
                type: list
                sample:
                  - "route add -net 10.10.10.0/24 gw 10.10.10.1 dev eth1"
                  - "route add -net 10.10.11.0/24 gw 10.10.11.1 dev eth2"
              down:
                description: list of C(down) scripts
                returned: success
                type: list
                sample:
                  - "route del -net 10.10.10.0/24 gw 10.10.10.1 dev eth1"
                  - "route del -net 10.10.11.0/24 gw 10.10.11.1 dev eth2"
...
s�
# Set eth1 mtu configuration value to 8000
- interfaces_file:
    dest: /etc/network/interfaces.d/eth1.cfg
    iface: eth1
    option: mtu
    value: 8000
    backup: yes
    state: present
  register: eth1_cfg
N(t
AnsibleModule(tto_bytescC`si|d6dd6S(Ntlinetunknownt	line_type((R
((sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pytlineDict�scC`s.i|d6|d6|d6|d6dd6|d6S(NR
tifacetoptiontvalueRtaddress_family((R
RRRR((sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyt
optionDict�scC`s�tjd�}x|j|�D]}qW|j�}|j�d}|j|�}t|�}tjd|||�j�||}|||!S(Ns\s+is\s(	tretcompiletfinditertstarttsplittfindtlentsearchtend(tstspaceRetmtvalueEndRtoptionStartt	optionLent
valueStart((sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pytgetValueFromLine�s(cC`st|d�}t||�S(Ntr(topentread_interfaces_lines(tmoduletfilenametf((sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pytread_interfaces_file�sc
C`s�g}i}d}d}x�|D]�}|d7}|j�}t|�dkrf|jt|��qn|dddkr�|jt|��qn|ddkr�|jt|��d}q|ddkr�|jt|��d}q|ddkr|jt|��d}q|dd	krC|jt|��d}q|dd
kr,igd6gd6gd
6gd6}|d}	y|d|d<Wntk
r�d|d<nX|d}
y|d|d<Wntk
r�d|d<nX|||	<|ji|d6|	d
6d
d6|d6|
d6�d}q|ddkrX|jt|��d}q|djd�r�|jt|��d}q|ddkr�|jt|��d}q|ddkr�|jt|��d}q|dkrM|d}t|�}|jt||	|||
��|dkr@||j|�q�|||<q|dkro|jt|��q|dkr�|jt|��q|j	dd||f�dSqW||fS(Niit#tmappingtMAPPINGtsourcetNONEs
source-dirssource-directoryRspre-uptuptdownspost-upiRitmethodR
RtparamstIFACEtautosallow-sno-auto-downs
no-scriptstmsgsmisplaced option %s in line %d(spre-upR0R1spost-up(NN(
tNoneRRtappendR
t
IndexErrort
startswithR#Rt	fail_json(
R'tline_stringstlinestifacestcurrently_processingtiR
twordstcurrift
iface_nameRtoption_nameR((sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyR&�s�

				





0					

c`s�t|��t}g|D](}d|kr|d|kr|^q}	|dk	r�g|	D](}d|krZ|d|krZ|^qZ}	nt|	�dkr�|jdd|�|dfSttd�|	��}
tt�fd�|
��}|dkr�t|�dkrFt}|	d	}t��||||
|�\}}q��dkr�ttt�fd�|���dkr�t��|||d	|
|�\}}q�q�|d	d�kr�t}|d	��d}
�d}�d}|
j	��}t��}t
jdjt
t
j|j���|
||�}|j�||}|j�||}|
| �|
|}t|�|ddd	�j��d}t||��|�||<q�n�|dkr�t|�dkr��dkrR�dk	rR�dkrRx|t�fd�|�D]*�t}tt�fd�|��}q!Wq�t}x/|D]$�tt�fd�|��}q_Wq�n|jdd|�||fS(NRRiR6sError: interface %s not foundcS`s|ddkS(NRR((R@((sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyt<lambda>sc`s|d�kS(NR((R@(R(sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyREstpresenti����spre-upR0R1spost-upc`s|d�kS(NR((R@(R(sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyREsRR
s\s+tabsentR7c`s|d�kS(NR((R@(R(sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyRE.sc`s
|�kS(N((tln(t
target_option(sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyRE0sc`s
|�kS(N((RH(RI(sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyRE4ss?Error: unsupported state %s, has to be either present or absent(spre-upsupsdownspost-up(spre-upsupsdownspost-up(tstrtFalseR7RR;tlisttfiltertTruetaddOptionAfterLineRRRtjointmaptescapeRRRtindexR(R'R=RRt	raw_valuetstateRtchangedtitemtiface_linest
iface_optionsttarget_optionstlast_line_dicttold_linet	old_valuetprefix_startR!told_value_positionRRR
RS((RRIRsJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pytsetInterfaceOptionsX5
+

'*.



5*"$%
(cC`s�|dkr�t}x�|D]�}|jdd�dkr|jdd�|kr||jdi�jdd�krt}tj|jdi�jdd�d||jd��|d<||dd<qqW||fS|d}	|	j|	j�d�}
|	j|	j�d	�t|	j�d	�}|	|
 }t|�d
krO|d7}n|d||f|	|}
t	|
||||�}t|�|ddd	�j
|�}|j||�t|fS(
NR2RtRR3t$R
ii����is    s%s %s(RKtgetRNRtsubRRtrfindRRRStinsert(RRRR=R[RYRRVRHt	last_lineR^tsuffix_starttprefixR
toption_dictRS((sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyRO;s&
T>

-

&cC`sptj�\}}tj|d�}|jtdj|�dd��|j�|j|tj	j
|��dS(NtwbRaterrorstsurrogate_or_strict(ttempfiletmkstemptostfdopentwriteR	RPtclosetatomic_movetpathtrealpath(R'R=tdestttmpfdttmpfileR)((sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyt
write_changesVs
"
c
C`sQtdtdtdddd�dtdd�d	tdd�d
tdd�dtdd�dtdd
dt�dtdddddddg��dtdtdtd
d��}|jd}|jd}|jd	}|jd
}|jd}|jd}|jd}|dk	rF|dkrF|dkrF|jdd�nt||�\}}	t}
|dk	r�t|||||||�\}
}n|
r�t	|g|D]}d|kr�|d^q��\}}	n|
r1|j
r1|r�|j|�nt|g|D]}d|kr|d^q|�n|j
d|d|
d|	�dS(Nt
argument_specRwttypeRutdefaults/etc/network/interfacesRRJRRRtbackuptboolRURFtchoicesRGtadd_file_common_argstsupports_check_modetrequired_byR6s=Value must be set if option is defined and state is 'present'R
RVR>(R(RtdictRKRNR3R7R;R*R`R&t
check_modetbackup_localRzt	exit_json(
R'RwRRRRR~RUR=R>RVtdt_((sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pytmain_sB$






$';6t__main__(t
__future__RRRR|t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtRETURNtEXAMPLESRpRRntansible.module_utils.basicRtansible.module_utils._textR	R
RR#R*R&R7R`RORzR�t__name__(((sJ/usr/lib/python2.7/site-packages/ansible/modules/system/interfaces_file.pyt<module>s.


1C					P;				/

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