??????????????
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 173
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 174
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 175
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 176
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 177
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 178
σ
ίUdac @` sΥ d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d d
l Z d d
l
Z
d d
l Z d d l m
Z
d d l m Z d d
l m Z d Z d Z d Z e d k rΡ e n d
S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust coret supported_bysΒ
---
module: blockinfile
short_description: Insert/update/remove a text block surrounded by marker lines
version_added: '2.0'
description:
- This module will insert/update/remove a block of multi-line text surrounded by customizable marker lines.
author:
- Yaegashi Takeshi (@yaegashi)
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: yes
aliases: [ dest, destfile, name ]
state:
description:
- Whether the block should be there or not.
type: str
choices: [ absent, present ]
default: present
marker:
description:
- The marker line template.
- C({mark}) will be replaced with the values C(in marker_begin) (default="BEGIN") and C(marker_end) (default="END").
- Using a custom marker without the C({mark}) variable may result in the block being repeatedly inserted on subsequent playbook runs.
type: str
default: '# {mark} ANSIBLE MANAGED BLOCK'
block:
description:
- The text to insert inside the marker lines.
- If it is missing or an empty string, the block will be removed as if C(state) were specified to C(absent).
type: str
default: ''
aliases: [ content ]
insertafter:
description:
- If specified, the block will be inserted after the last match of specified regular expression.
- A special value is available; C(EOF) for inserting the block at the end of the file.
- If specified regular expression has no matches, C(EOF) will be used instead.
type: str
choices: [ EOF, '*regex*' ]
default: EOF
insertbefore:
description:
- If specified, the block will be inserted before the last match of specified regular expression.
- A special value is available; C(BOF) for inserting the block at the beginning of the file.
- If specified regular expression has no matches, the block will be inserted at the end of the file.
type: str
choices: [ BOF, '*regex*' ]
create:
description:
- Create a new file if it does not exist.
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
marker_begin:
description:
- This will be inserted at C({mark}) in the opening ansible block marker.
type: str
default: BEGIN
version_added: '2.5'
marker_end:
required: false
description:
- This will be inserted at C({mark}) in the closing ansible block marker.
type: str
default: END
version_added: '2.5'
notes:
- This module supports check mode.
- When using 'with_*' loops be aware that if you do not set a unique mark the block will be overwritten on each iteration.
- As of Ansible 2.3, the I(dest) option has been changed to I(path) as default, but I(dest) still works as well.
- 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.
- When more then one block should be handled in one file you must change the I(marker) per task.
extends_documentation_fragment:
- files
- validate
sE
# Before Ansible 2.3, option 'dest' or 'name' was used instead of 'path'
- name: Insert/Update "Match User" configuration block in /etc/ssh/sshd_config
blockinfile:
path: /etc/ssh/sshd_config
block: |
Match User ansible-agent
PasswordAuthentication no
- name: Insert/Update eth0 configuration stanza in /etc/network/interfaces
(it might be better to copy files into /etc/network/interfaces.d/)
blockinfile:
path: /etc/network/interfaces
block: |
iface eth0 inet static
address 192.0.2.23
netmask 255.255.255.0
- name: Insert/Update configuration using a local file and validate it
blockinfile:
block: "{{ lookup('file', './local/sshd_config') }}"
dest: /etc/ssh/sshd_config
backup: yes
validate: /usr/sbin/sshd -T -f %s
- name: Insert/Update HTML surrounded by custom markers after
Last updated on {{ ansible_date_time.iso8601 }}
- name: Remove HTML as well as surrounding markers blockinfile: path: /var/www/html/index.html marker: "" block: "" - name: Add mappings to /etc/hosts blockinfile: path: /etc/hosts block: | {{ item.ip }} {{ item.name }} marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.name }}" loop: - { name: host1, ip: 10.10.1.10 } - { name: host2, ip: 10.10.1.11 } - { name: host3, ip: 10.10.1.12 } N( t b( t AnsibleModule( t to_bytesc C` s t j d | j \ } } t j | d } | j | | j | j j d d } | } | rέ d | k r | j d d | n | j | | \ } } } | d k } | d k rέ | j d d | | f qέ n | r| j | | d | j d n d S( Nt dirt wbt validates %st msgs validate must contain %%s: %si s" failed to validate: rc:%s error:%st unsafe_writes( t tempfilet mkstempt tmpdirt ost fdopent writet closet paramst gett Nonet fail_jsont run_commandt atomic_move( t modulet contentst patht tmpfdt tmpfilet fR t validt rct outt err( ( sE /usr/lib/python2.7/site-packages/ansible/modules/files/blockinfile.pyt write_changes’ s c C` sZ | j | j } | j | t d | rP | r= | d 7} n t } | d 7} n | | f S( Nt diffs and s, ownership, perms or SE linux context changed( t load_file_common_argumentsR t set_file_attributes_if_differentt Falset True( R t changedt messageR( t file_args( ( sE /usr/lib/python2.7/site-packages/ansible/modules/files/blockinfile.pyt check_file_attrs· s c C` sI t d t d t d d d t d d d d g d t d d d d d d d g d t d d d d d t d d d d d d g d t d d d t d d d t d d d t d t d d d t d t d d d t d d d d d t d d d d d d d g g d t d t } | j } | d } t j j | rh| j d! d" d# d$ | n t j j | } | s=| j | d s°| j d! d% d# d&