403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.11/site-packages/ansible/modules/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.11/site-packages/ansible/modules/__pycache__/lineinfile.cpython-311.pyc
�

���c�]���ddlmZmZmZeZdZdZdZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZd�Zd	�Zd
�Zd�Zd�Zed
kre��dSdS)�)�absolute_import�division�print_functiona�
---
module: lineinfile
short_description: Manage lines in text files
description:
  - This module ensures a particular line is in a file, or replace an
    existing line using a back-referenced regular expression.
  - This is primarily useful when you want to change a single line in a file only.
  - See the M(ansible.builtin.replace) module if you want to change multiple, similar lines
    or check M(ansible.builtin.blockinfile) if you want to insert/update/remove a block of lines in a file.
    For other cases, see the M(ansible.builtin.copy) or M(ansible.builtin.template) modules.
version_added: "0.7"
options:
  path:
    description:
      - The file to modify.
      - Before Ansible 2.3 this option was only usable as I(dest), I(destfile) and I(name).
    type: path
    required: true
    aliases: [ dest, destfile, name ]
  regexp:
    description:
      - The regular expression to look for in every line of the file.
      - For C(state=present), the pattern to replace if found. Only the last line found will be replaced.
      - For C(state=absent), the pattern of the line(s) to remove.
      - If the regular expression is not matched, the line will be
        added to the file in keeping with C(insertbefore) or C(insertafter)
        settings.
      - When modifying a line the regexp should typically match both the initial state of
        the line as well as its state after replacement by C(line) to ensure idempotence.
      - Uses Python regular expressions. See U(https://docs.python.org/3/library/re.html).
    type: str
    aliases: [ regex ]
    version_added: '1.7'
  search_string:
    description:
      - The literal string to look for in every line of the file. This does not have to match the entire line.
      - For C(state=present), the line to replace if the string is found in the file. Only the last line found will be replaced.
      - For C(state=absent), the line(s) to remove if the string is in the line.
      - If the literal expression is not matched, the line will be
        added to the file in keeping with C(insertbefore) or C(insertafter)
        settings.
      - Mutually exclusive with C(backrefs) and C(regexp).
    type: str
    version_added: '2.11'
  state:
    description:
      - Whether the line should be there or not.
    type: str
    choices: [ absent, present ]
    default: present
  line:
    description:
      - The line to insert/replace into the file.
      - Required for C(state=present).
      - If C(backrefs) is set, may contain backreferences that will get
        expanded with the C(regexp) capture groups if the regexp matches.
    type: str
    aliases: [ value ]
  backrefs:
    description:
      - Used with C(state=present).
      - If set, C(line) can contain backreferences (both positional and named)
        that will get populated if the C(regexp) matches.
      - This parameter changes the operation of the module slightly;
        C(insertbefore) and C(insertafter) will be ignored, and if the C(regexp)
        does not match anywhere in the file, the file will be left unchanged.
      - If the C(regexp) does match, the last matching line will be replaced by
        the expanded line parameter.
      - Mutually exclusive with C(search_string).
    type: bool
    default: no
    version_added: "1.1"
  insertafter:
    description:
      - Used with C(state=present).
      - If specified, the line will be inserted after the last match of specified regular expression.
      - If the first match is required, use(firstmatch=yes).
      - A special value is available; C(EOF) for inserting the line at the end of the file.
      - If specified regular expression has no matches, EOF will be used instead.
      - If C(insertbefore) is set, default value C(EOF) will be ignored.
      - If regular expressions are passed to both C(regexp) and C(insertafter), C(insertafter) is only honored if no match for C(regexp) is found.
      - May not be used with C(backrefs) or C(insertbefore).
    type: str
    choices: [ EOF, '*regex*' ]
    default: EOF
  insertbefore:
    description:
      - Used with C(state=present).
      - If specified, the line will be inserted before the last match of specified regular expression.
      - If the first match is required, use C(firstmatch=yes).
      - A value is available; C(BOF) for inserting the line at the beginning of the file.
      - If specified regular expression has no matches, the line will be inserted at the end of the file.
      - If regular expressions are passed to both C(regexp) and C(insertbefore), C(insertbefore) is only honored if no match for C(regexp) is found.
      - May not be used with C(backrefs) or C(insertafter).
    type: str
    choices: [ BOF, '*regex*' ]
    version_added: "1.1"
  create:
    description:
      - Used with C(state=present).
      - If specified, the file will be created if it does not already exist.
      - By default it will fail if the file is missing.
    type: bool
    default: no
  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
  firstmatch:
    description:
      - Used with C(insertafter) or C(insertbefore).
      - If set, C(insertafter) and C(insertbefore) will work with the first line that matches the given regular expression.
    type: bool
    default: no
    version_added: "2.5"
  others:
    description:
      - All arguments accepted by the M(ansible.builtin.file) module also work here.
    type: str
extends_documentation_fragment:
    - action_common_attributes
    - action_common_attributes.files
    - files
    - validate
attributes:
    check_mode:
        support: full
    diff_mode:
        support: full
    platform:
        platforms: posix
    safe_file_operations:
        support: full
    vault:
        support: none
notes:
  - As of Ansible 2.3, the I(dest) option has been changed to I(path) as default, but I(dest) still works as well.
seealso:
- module: ansible.builtin.blockinfile
- module: ansible.builtin.copy
- module: ansible.builtin.file
- module: ansible.builtin.replace
- module: ansible.builtin.template
- module: community.windows.win_lineinfile
author:
    - Daniel Hokka Zakrissoni (@dhozac)
    - Ahti Kitsik (@ahtik)
    - Jose Angel Munoz (@imjoseangel)
a6

# NOTE: Before 2.3, option 'dest', 'destfile' or 'name' was used instead of 'path'
- name: Ensure SELinux is set to enforcing mode
  ansible.builtin.lineinfile:
    path: /etc/selinux/config
    regexp: '^SELINUX='
    line: SELINUX=enforcing

- name: Make sure group wheel is not in the sudoers configuration
  ansible.builtin.lineinfile:
    path: /etc/sudoers
    state: absent
    regexp: '^%wheel'

- name: Replace a localhost entry with our own
  ansible.builtin.lineinfile:
    path: /etc/hosts
    regexp: '^127\.0\.0\.1'
    line: 127.0.0.1 localhost
    owner: root
    group: root
    mode: '0644'

- name: Replace a localhost entry searching for a literal string to avoid escaping
  ansible.builtin.lineinfile:
    path: /etc/hosts
    search_string: '127.0.0.1'
    line: 127.0.0.1 localhost
    owner: root
    group: root
    mode: '0644'

- name: Ensure the default Apache port is 8080
  ansible.builtin.lineinfile:
    path: /etc/httpd/conf/httpd.conf
    regexp: '^Listen '
    insertafter: '^#Listen '
    line: Listen 8080

- name: Ensure php extension matches new pattern
  ansible.builtin.lineinfile:
    path: /etc/httpd/conf/httpd.conf
    search_string: '<FilesMatch ".php[45]?$">'
    insertafter: '^\t<Location \/>\n'
    line: '        <FilesMatch ".php[34]?$">'

- name: Ensure we have our own comment added to /etc/services
  ansible.builtin.lineinfile:
    path: /etc/services
    regexp: '^# port for http'
    insertbefore: '^www.*80/tcp'
    line: '# port for http by default'

- name: Add a line to a file if the file does not exist, without passing regexp
  ansible.builtin.lineinfile:
    path: /tmp/testfile
    line: 192.168.1.99 foo.lab.net foo
    create: yes

# NOTE: Yaml requires escaping backslashes in double quotes but not in single quotes
- name: Ensure the JBoss memory settings are exactly as needed
  ansible.builtin.lineinfile:
    path: /opt/jboss-as/bin/standalone.conf
    regexp: '^(.*)Xms(\d+)m(.*)$'
    line: '\1Xms${xms}m\3'
    backrefs: yes

# NOTE: Fully quoted because of the ': ' on the line. See the Gotchas in the YAML docs.
- name: Validate the sudoers file before saving
  ansible.builtin.lineinfile:
    path: /etc/sudoers
    state: present
    regexp: '^%ADMIN ALL='
    line: '%ADMIN ALL=(ALL) NOPASSWD: ALL'
    validate: /usr/sbin/visudo -cf %s

# See https://docs.python.org/3/library/re.html for further details on syntax
- name: Use backrefs with alternative group syntax to avoid conflicts with variable values
  ansible.builtin.lineinfile:
    path: /tmp/config
    regexp: ^(host=).*
    line: \g<1>{{ hostname }}
    backrefs: yes
�#N)�
AnsibleModule)�to_bytes�	to_native�to_textc��tj|j���\}}tj|d��5}|�|��ddd��n#1swxYwY|j�dd��}|}|rpd|vr|�d|z���|�	t||zd�����\}}	}
|d	k}|d	kr|�d
|�d|
�����|r`|�|ttj
�t|d�����d���|jd�
��dSdS)N)�dir�wb�validatez%szvalidate must contain %%s: %s��msg�surrogate_or_strict��errorsrzfailed to validate: rc:z error:�
unsafe_writes)r)�tempfile�mkstemp�tmpdir�os�fdopen�
writelines�params�get�	fail_json�run_commandr�atomic_mover	�path�realpath)�module�b_lines�dest�tmpfd�tmpfile�fr�valid�rc�out�errs           �?/usr/lib/python3.11/site-packages/ansible/modules/lineinfile.py�
write_changesr-s����%�&�-�8�8�8�N�E�7�	��5�$�	�	��1�	���W�����������������������}� � ��T�2�2�H��L�E��?��x������!@�H�!M��N�N�N��+�+�H�X��5G�Pe�,f�,f�,f�g�g���S�#��a���
��7�7�����57�R�R���">��
?�
?�
?��I����7�$�R�W�%5�%5�h�t�La�6b�6b�6b�%c�%c�mB�C�C�C�)/���)G�	�	I�	I�	I�	I�	I�I�Is�A�A�Ac��|�|j��}|�|d|���r|r|dz
}d}|dz
}||fS)NF)�diffz and Tz,ownership, perms or SE linux context changed)�load_file_common_argumentsr�set_fs_attributes_if_different)r"�changed�messager/�	file_argss     r,�check_file_attrsr5sb���1�1�&�-�@�@�I�
�,�,�Y��D�,�I�I�B��	��w��G����A�A���G���c	��ddd|zd|zd�}t|d���}tj�|��s�|s|�dd|z���tj�|��}
|
r�tj�|
��sk|jsd	tj|
��nN#t$rA}|�d	t|
���d
t|���d����Yd}~nd}~wwxYwg}n<t|d
��5}|���}ddd��n#1swxYwY|jr%td�|����|d<|�#tjt|d�����}|dvr$tjt|d�����}n*|dvr$tjt|d�����}nd}ddg}d}d}t|d���}|�7t#|��D]'\}}|�|��}|r||d<|}|
rn�(|�5t#|��D]%\}}t|d���|v}|r||d<|}|
rn�&|sft#|��D]V\}}||�d��kr||d<d}�&|�.|�|��r|r|dz|d<|
rn|r	||d<|
rn�Wd}d}ttjd���}|ddk�r�|	r|r|�|��}n|}|�|��s||z
}|||fdk�r�|�s~|r�|dkr�|r |ddd�dvr|d|z|d<t/|��|dkrF||ddz
�d��|kr|�||z��d}d}�nw||d�d��|kr#|�|d||z��d}d}�n-|r�|dkr�|ddkrJ||d�d��|kr#|�|d||z��d}d}�n�||ddz
�d��|kr#|�|d||z��d}d}�n�||d|kr|||d<d}d}�n_|	r�n[|dks|dkr|�d||z��d}d}�n0|dks|ddkrF|r'|ddd�dvr|�|��|�||z��d}d}n�|r�|ddkr�t/|��|dkrE||ddz
�d��|kr|�||z��d}d}nl|||d�d��kr#|�|d||z��d}d}n#|�|d||z��d}d}|jr%td�|����|d<d}|rN|jsG|r4tj�|��r|�|��}t7|||��|jr8tj�|��s|�||||� ��i}t;||||��\}}d!|z|d"<d!|z|d#<||g} |�|||| � ��dS)$N��%s (content)��before�after�
before_header�after_headerrrizDestination %s does not exist !�r)rzError creating z (�)r�rbr6r;)N�BOF�EOF)NrB���Fr�
T��NNNrC)�
�
z
line addedrBz
line replaceds

r<)r2r�backupr/�%s (file attributes)r=r>)rrr �existsr�dirname�
check_mode�makedirs�	Exceptionr
�open�	readlines�_diffr	�join�re�compile�	enumerate�search�rstrip�linesep�expand�endswith�len�append�insert�backup_localr-�	exit_jsonr5)!r"r$�regexp�
search_string�line�insertafter�insertbefore�createrJ�backrefs�
firstmatchr/�b_dest�
b_destpath�er#r'�bre_m�bre_ins�index�match�exact_line_match�b_line�lineno�
b_cur_line�match_foundrr2�	b_linesep�
b_new_line�
backupdest�	attr_diff�difflists!                                 r,�presentr{(s	����+�d�2�*�T�1�3�3�D�
�d�#8�
9�
9�
9�F�
�7�>�>�&�!�!�
$��	S�����)J�T�)Q��R�R�R��W�_�_�V�,�,�
��	c�b�g�n�n�Z�8�8�	c��AR�	c�
c���J�'�'�'�'���
c�
c�
c�� � � ���AT�AT�AT�AT�V]�^_�V`�V`�V`�V`�%a� �b�b�b�b�b�b�b�b�����
c�������
�&�$�
�
�	$�1��k�k�m�m�G�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$��|�6�"�3�8�8�G�#4�#4�5�5��X��
���
�8�F�3H�I�I�I�J�J���.�.�.��*�X�k�:O�P�P�P�Q�Q���	�]�	*�	*��*�X�l�;P�Q�Q�Q�R�R�������H�E��E���
�d�#8�
9�
9�
9�F���"+�G�"4�"4�	�	��F�J��,�,�z�2�2�K��
�!��a��#�����E��� �"+�G�"4�"4�	�	��F�J�"�=�9N�O�O�O�S]�]�K��
�!��a��#�����E����"+�G�"4�"4�	�	��F�J���*�*�7�3�3�3�3�!��a��#'� � ��$����
�)C�)C�$���%��z�E�!�H�!������%�E�!�H�!�����
�C��G����,A�B�B�B�I��Q�x�2�~�~��	 ��	 ����f�-�-�J�J� �J��"�"�9�-�-�	$��)�#�J�
�M�5�)�-?�?�?�HX�?��
#�{�e�3�3��:�7�2�;�r�s�s�#3�~�#E�#E�")�"�+�	�"9�G�B�K��w�<�<�5��8�+�+��u�Q�x�!�|�,�3�3�G�<�<��F�F����v�	�'9�:�:�:�*��"&����U�1�X�&�-�-�g�6�6�&�@�@��N�N�5��8�V�i�-?�@�@�@�&�C�"�G���
#�,�%�"7�"7���8�q�=�=��u�Q�x�(�/�/��8�8�F�B�B����u�Q�x��)�1C�D�D�D�*��"&����U�1�X��\�*�1�1�'�:�:�f�D�D��N�N�5��8�V�i�-?�@�@�@�&�C�"�G��
�U�1�X�
�*�
,�
,� *�G�E�!�H��!�C��G��	�(�	
�	��	�	�+��"6�"6����q�&�9�,�-�-�-������
��	�	��q��R����	&�7�2�;�r�s�s�+�~�=�=��N�N�9�%�%�%����v�	�)�*�*�*������	���q��R����w�<�<�5��8�#�#��u�Q�x�!�|�$�+�+�G�4�4��>�>����v�	�1�2�2�2�"�����
�w�u�Q�x�(�/�/��8�8�
8�
8��N�N�5��8�V�i�%7�8�8�8��C��G��	���u�Q�x��)�!3�4�4�4�����
�|�5�!�#�(�(�7�"3�"3�4�4��W�
��J��-�v�(�-��	3�b�g�n�n�V�,�,�	3��,�,�T�2�2�J��f�g�t�,�,�,�
��Q������!7�!7�Q�����c�*�4��P�P�P��I�#�F�G�S�)�D�D�L�C��!7�$�!>�I�o�� 6�� =�I�n���i� �H�
���W�#�j�x��P�P�P�P�Ps*�"B7�7
D�7C=�=D�D9�9D=�D=c���������t|d���}tj�|��s|�dd���d}ddd|zd|zd�}t|d	��5}	|	���}
ddd��n#1swxYwY|jr%td
�	|
����|d<��#tjt�d������g�t|d���������fd���fd
�|
D��}
t���dk}|jr%td
�	|
����|d<d}|r/|j
s(|r|�|��}t||
|��|rdt���z}i}
t!||||
��\}}d|z|
d<d|z|
d<||
g}|�|t���|||���dS)NrrFzfile not present)r2rr8r9r:rAr6r;c��������|��}n/��t�d���|v}n�|�d��k}|r��|��|S)NrrrE)rXrrYr^)rtrurr�bre_c�foundrbrcs  �����r,�matcherzabsent.<locals>.matchersw������,�,�z�2�2�K�K�
�
&�"�=�9N�O�O�O�S]�]�K�K� �J�$5�$5�g�$>�$>�>�K��	%��L�L��$�$�$���r6c�*��g|]}�|���
|��S�r�)�.0�lr�s  �r,�
<listcomp>zabsent.<locals>.<listcomp> s&���0�0�0�Q�W�W�Q�Z�Z�0�q�0�0�0r6rr<z%s line(s) removedrKr=r>)r2rrrJr/)rrr rLrarQrRrSr	rTrUrVr]rNr`r-r5)r"r$rbrcrdrJrjrr/r'r#r2rxryrzrrr~rr�s  ``           @@@@r,�absentr��s���������
�d�#8�
9�
9�
9�F�
�7�>�>�&�!�!�@�����,>��?�?�?�
�C���+�d�2�*�T�1�3�3�D�

�f�d�	�	� �q��+�+�-�-�� � � � � � � � � � � ���� � � � ��|�6�"�3�8�8�G�#4�#4�5�5��X��
���
�8�F�3H�I�I�I�J�J���E�
�d�#8�
9�
9�
9�F�	�	�	�	�	�	�	�	�	�1�0�0�0�'�0�0�0�G��%�j�j�1�n�G�
�|�5�!�#�(�(�7�"3�"3�4�4��W�
��J��-�v�(�-��	3��,�,�T�2�2�J��f�g�t�,�,�,��0�"�S��Z�Z�/���I�#�F�G�S�)�D�D�L�C��!7�$�!>�I�o�� 6�� =�I�n���i� �H�
���W�C��J�J�C�
�Ya��b�b�b�b�bs�-B�B�Bc��tttddgd����tddddg���tdd	g�
��td���tddg�
��td���td���td
d���td
d���td
d���td
d���td������ddgddgddggdd���}|j}|d}|d}|d}|d}|d}|d}|d}|d}	d||fvr)d}
d}|dkrd}|
dz
}
|�|
|z��t	|d �!��}t
j�|��r|�d"d#|z�$��|d%dkrc|r|�|�d&�'��|	�|�d(�'��|d|d}}
|
�|�d)}t|||||	||
||||��dS|||	fd*kr|�d+�'��t|||||	|��dS),Nr T)r$�destfile�name)�type�required�aliases�strr{r�)r��default�choices�regex)r�r�)r��value�boolF)r�r�)r �staterbrcrdrerfrhrgrJrirrfrerbrcrh)�
argument_spec�mutually_exclusive�add_file_common_args�supports_check_modergrJrirdr8z�The %s is an empty string, which will match every line in the file. This may have unintended consequences, such as replacing the last line in the file rather than appending.z
search stringzregular expressionzT If this is desired, use '^' to match every line in the file and avoid this warning.rr�zPath %s is a directory !r?r�z%regexp is required with backrefs=truerz#line is required with state=presentrCrGzCone of line, search_string, or regexp is required with state=absent)r�dictr�warnrrr �isdirrr{r�)r"rrgrJrhr rirbrcrdr�
param_name�b_path�ins_bef�ins_afts               r,�mainr�:s���
���6�D�:V�:V�:V�W�W�W��E�9�x��>S�T�T�T��U�W�I�6�6�6��E�*�*�*��5�7�)�4�4�4��%�(�(�(��5�)�)�)��v�u�5�5�5��V�U�3�3�3��V�U�3�3�3����7�7�7��u�%�%�%�

�

�

��]�+�h��-H�:�Wf�Jg�i�!� �%���F�*�]�F�
�H�
�F�
�H�
�F��j�!�H��&�>�D���%�J�
�H�
�F��?�+�M��&�>�D�	�f�m�
$�$�$�{��$�
��R�<�<�-�J��i�i�C����C�*�$�%�%�%�
�d�#8�
9�
9�
9�F�	�w�}�}�V���H����C�%?�$�%F��G�G�G�
�g��)�#�#��	J������!H��I�I�I��<����!F��G�G�G�"�.�1�6�-�3H����?�w���G����f�m�T���&�&�(�J�	H�	H�	H�	H�	H�
�M�4�(�,>�>�>����!f��g�g�g��v�t�V�]�D�&�A�A�A�A�Ar6�__main__)�
__future__rrrr��
__metaclass__�
DOCUMENTATION�EXAMPLES�RETURNrrUr�ansible.module_utils.basicr�ansible.module_utils._textrr	r
r-r5r{r�r��__name__r�r6r,�<module>r�s��A�@�@�@�@�@�@�@�@�@��
�W�
�rS��j
��	�	�	�	�	�	�	�	�����5�4�4�4�4�4�C�C�C�C�C�C�C�C�C�C�I�I�I�,
�
�
�RQ�RQ�RQ�j:c�:c�:c�z@B�@B�@B�F�z����D�F�F�F�F�F��r6

Youez - 2016 - github.com/yon3zu
LinuXploit