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__/replace.cpython-311.opt-1.pyc
�

���c�,���ddlmZmZmZeZdZdZdZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZddlmZd	�Zd
�Zd�Zedkre��dSdS)
�)�absolute_import�division�print_functiona�
---
module: replace
author: Evan Kaufman (@EvanK)
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
short_description: Replace all instances of a particular string in a
                   file using a back-referenced regular expression
description:
  - This module will replace all instances of a pattern within a file.
  - It is up to the user to maintain idempotence by ensuring that the
    same pattern would never match any replacements made.
version_added: "1.6"
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 the contents of the file.
      - Uses Python regular expressions; see
        U(https://docs.python.org/3/library/re.html).
      - Uses MULTILINE mode, which means C(^) and C($) match the beginning
        and end of the file, as well as the beginning and end respectively
        of I(each line) of the file.
      - Does not use DOTALL, which means the C(.) special character matches
        any character I(except newlines). A common mistake is to assume that
        a negated character set like C([^#]) will also not match newlines.
      - In order to exclude newlines, they must be added to the set like C([^#\n]).
      - Note that, as of Ansible 2.0, short form tasks should have any escape
        sequences backslash-escaped in order to prevent them being parsed
        as string literal escapes. See the examples.
    type: str
    required: true
  replace:
    description:
      - The string to replace regexp matches.
      - May contain backreferences that will get expanded with the regexp capture groups if the regexp matches.
      - If not set, matches are removed entirely.
      - Backreferences can be used ambiguously like C(\1), or explicitly like C(\g<1>).
    type: str
  after:
    description:
      - If specified, only content after this match will be replaced/removed.
      - Can be used in combination with C(before).
      - Uses Python regular expressions; see
        U(https://docs.python.org/3/library/re.html).
      - Uses DOTALL, which means the C(.) special character I(can match newlines).
    type: str
    version_added: "2.4"
  before:
    description:
      - If specified, only content before this match will be replaced/removed.
      - Can be used in combination with C(after).
      - Uses Python regular expressions; see
        U(https://docs.python.org/3/library/re.html).
      - Uses DOTALL, which means the C(.) special character I(can match newlines).
    type: str
    version_added: "2.4"
  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
  others:
    description:
      - All arguments accepted by the M(ansible.builtin.file) module also work here.
    type: str
  encoding:
    description:
      - The character encoding for reading and writing the file.
    type: str
    default: utf-8
    version_added: "2.4"
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.
  - As of Ansible 2.7.10, the combined use of I(before) and I(after) works properly. If you were relying on the
    previous incorrect behavior, you may be need to adjust your tasks.
    See U(https://github.com/ansible/ansible/issues/31354) for details.
  - Option I(follow) has been removed in Ansible 2.5, because this module modifies the contents of the file so I(follow=no) doesn't make sense.
a�
- name: Replace old hostname with new hostname (requires Ansible >= 2.4)
  ansible.builtin.replace:
    path: /etc/hosts
    regexp: '(\s+)old\.host\.name(\s+.*)?$'
    replace: '\1new.host.name\2'

- name: Replace after the expression till the end of the file (requires Ansible >= 2.4)
  ansible.builtin.replace:
    path: /etc/apache2/sites-available/default.conf
    after: 'NameVirtualHost [*]'
    regexp: '^(.+)$'
    replace: '# \1'

- name: Replace before the expression till the begin of the file (requires Ansible >= 2.4)
  ansible.builtin.replace:
    path: /etc/apache2/sites-available/default.conf
    before: '# live site config'
    regexp: '^(.+)$'
    replace: '# \1'

# Prior to Ansible 2.7.10, using before and after in combination did the opposite of what was intended.
# see https://github.com/ansible/ansible/issues/31354 for details.
- name: Replace between the expressions (requires Ansible >= 2.4)
  ansible.builtin.replace:
    path: /etc/hosts
    after: '<VirtualHost [*]>'
    before: '</VirtualHost>'
    regexp: '^(.+)$'
    replace: '# \1'

- name: Supports common file attributes
  ansible.builtin.replace:
    path: /home/jdoe/.ssh/known_hosts
    regexp: '^old\.host\.name[^\n]*\n'
    owner: jdoe
    group: jdoe
    mode: '0644'

- name: Supports a validate command
  ansible.builtin.replace:
    path: /etc/apache/ports
    regexp: '^(NameVirtualHost|Listen)\s+80\s*$'
    replace: '\1 127.0.0.1:8080'
    validate: '/usr/sbin/apache2ctl -f %s -t'

- name: Short form task (in ansible 2+) necessitates backslash-escaped sequences
  ansible.builtin.replace: path=/etc/hosts regexp='\\b(localhost)(\\d*)\\b' replace='\\1\\2.localdomain\\2 \\1\\2'

- name: Long form task does not
  ansible.builtin.replace:
    path: /etc/hosts
    regexp: '\b(localhost)(\d*)\b'
    replace: '\1\2.localdomain\2 \1\2'

- name: Explicitly specifying positional matched groups in replacement
  ansible.builtin.replace:
    path: /etc/ssh/sshd_config
    regexp: '^(ListenAddress[ ]+)[^\n]+$'
    replace: '\g<1>0.0.0.0'

- name: Explicitly specifying named matched groups
  ansible.builtin.replace:
    path: /etc/ssh/sshd_config
    regexp: '^(?P<dctv>ListenAddress[ ]+)(?P<host>[^\n]+)$'
    replace: '#\g<dctv>\g<host>\n\g<dctv>0.0.0.0'
�#N)�
format_exc)�to_text�to_bytes)�
AnsibleModulec��tj|j���\}}tj|d��}|�|��|���|j�dd��}|}|rad|vr|�	d|z���|�
||z��\}}	}
|dk}|dkr|�	d|�d	|
�����|r%|�|||jd
���dSdS)N)�dir�wb�validatez%szvalidate must contain %%s: %s)�msgrzfailed to validate: rc:z error:�
unsafe_writes)r)�tempfile�mkstemp�tmpdir�os�fdopen�write�close�params�get�	fail_json�run_command�atomic_move)�module�contents�path�tmpfd�tmpfile�fr�valid�rc�out�errs           �</usr/lib/python3.11/site-packages/ansible/modules/replace.py�
write_changesr(�s4���%�&�-�8�8�8�N�E�7�
�	�%����A��G�G�H�����G�G�I�I�I��}� � ��T�2�2�H��L�E��?��x������!@�H�!M��N�N�N��+�+�H�w�,>�?�?���S�#��a���
��7�7�����57�R�R���">��
?�
?�
?��X����7�D��
�o�8V��W�W�W�W�W�X�X�c��|�|j��}|�|d��r|r|dz
}d}|dz
}||fS)NFz and Tz,ownership, perms or SE linux context changed)�load_file_common_argumentsr� set_file_attributes_if_different)r�changed�message�	file_argss    r'�check_file_attrsr0�s]���1�1�&�-�@�@�I�
�.�.�y�%�@�@�B��	��w��G����A�A���G��r)c�.	�tttddgd����tdd���tdd���td�	��td�	��td
d���td�	��tdd����
��dd���}|j}|d}|d}td���}t|ddd���|d<t|ddd���|d<t|ddd���|d<t|ddd���|d<tj�|��r|�dd|z���tj�|��s|�dd|z���n�	t|d��5}t|�
��d|���}ddd��n#1swxYwYnT#ttf$r@}|�d |�d!t|����t���"��Yd}~nd}~wwxYwd}|dr|dr|d�d#|d��}n'|drd$|dz}n|drd%|dz}|r�tj|tj��}	tj|	|��}
|
r@|
�d&��}|
�d&��|
�d&��g}nd'|z|d(<d|d)<|jd1i|��n|}tj|dtj��}
tj|
|d|d��}|d*dkre||dkrY|r2|d|d�|dz||d*d�z|d*f}d+|d*z}d}|jr||||dd,�|d-<nd}d}|r�|js�|d.r7tj�|��r|�|��|d/<tj�|��}t9|t;|d|�0��|��t=|||��\|d(<|d)<|jd1i|��dS)2NrT)�dest�destfile�name)�type�required�aliases�str)r5r6�)r5�default)r5�boolFzutf-8)r�regexp�replace�after�before�backupr�encoding)�
argument_spec�add_file_common_args�supports_check_moderAr)r$r>�surrogate_or_strict�passthru)�errors�	nonstringr?r<r=�zPath %s is a directory !)r$rizPath %s does not exist !�rb)rGrAzUnable to read the contents of z: )r�	exceptionz(?P<subsection>.*?)z%s(?P<subsection>.*)z(?P<subsection>.*)%s�
subsectionz@Pattern for before/after params did not match the given file: %srr-�z%s replacements made)�
before_headerr?�after_headerr>�diffr@�backup_file)rA�)r
�dictrrrr�isdirr�exists�open�read�OSError�IOErrorr�re�compile�DOTALL�search�group�start�end�	exit_json�	MULTILINE�subn�_diff�
check_mode�backup_local�realpathr(r	r0)rrrrA�res_argsr"r�e�pattern�
section_re�match�section�indices�mre�resultrr-s                 r'�mainrq�s���
���6�D�:V�:V�:V�W�W�W��U�T�2�2�2��e�R�0�0�0��E�"�"�"��U�#�#�#��V�U�3�3�3��u�%�%�%��u�g�6�6�6�	
�	
�	
�"� �
�
�
�F��]�F��&�>�D��j�!�H��q�z�z�z�H��f�W�o�6K�Wa�b�b�b�F�7�O��v�h�/�8M�Yc�d�d�d�F�8���v�h�/�8M�Yc�d�d�d�F�8����y� 1�:O�[e�f�f�f�F�9��	�w�}�}�T���H����C�%?�$�%F��G�G�G�
�7�>�>�$���5����C�%?�$�%F��G�G�G�G�	5��d�D�!�!�
^�Q�"�1�6�6�8�8�4I�T\�]�]�]��
^�
^�
^�
^�
^�
^�
^�
^�
^�
^�
^����
^�
^�
^�
^�����!�	5�	5�	5�����D�D�D�RY�Z[�R\�R\�R\�!]�'1�|�|�
�
5�
5�
5�
5�
5�
5�
5�
5�����	5�����G�
�g��=�6�(�+�=�06�w������AQ�AQ�R���	���=�)�F�7�O�;���	��	�=�)�F�8�,<�<�����Z����3�3�
��	�*�h�/�/���	)��k�k�,�/�/�G��{�{�<�0�0�%�)�)�L�2I�2I�J�G�G�`�cj�j�H�U�O�"'�H�Y���F��(�(�x�(�(�(�(���
�*�V�H�%�r�|�
4�
4�C�
�W�S�&��+�W�a�
8�
8�F�
�a�y�1�}�}��F�1�I�-�-��	\��{���
�{�+�f�Q�i�7�(�7�1�:�;�;�:O�O�QW�XY�QZ�[�F�$�v�a�y�0�����<�	�!%�"� $����	 � �H�V��������L�v�(�L��(��	@�����t� 4� 4�	@�&,�&9�&9�$�&?�&?�H�]�#��w����%�%���f�h�v�a�y�8�D�D�D�d�K�K�K�+;�F�G�S�+Q�+Q�(�H�U�O�X�i�(��F�� � �x� � � � � s<�'G4�7%G(�G4�(G,�,G4�/G,�0G4�4I�6I�I�__main__)�
__future__rrrr5�
__metaclass__�
DOCUMENTATION�EXAMPLES�RETURNrrZr�	tracebackr�ansible.module_utils._textrr	�ansible.module_utils.basicr
r(r0rq�__name__rRr)r'�<module>r|s���A�@�@�@�@�@�@�@�@�@��
�c�
�JB��H
��	�	�	�	�	�	�	�	����� � � � � � �8�8�8�8�8�8�8�8�4�4�4�4�4�4�X�X�X�*
�
�
�W!�W!�W!�t�z����D�F�F�F�F�F��r)

Youez - 2016 - github.com/yon3zu
LinuXploit