blockinfile: PEP8 compliancy, pylint and docs (#30845)

This PR includes;
- PEP8 compliancy fixes
- pylint fixes
- Documentation updates
pull/30858/head^2
Dag Wieers 7 years ago committed by GitHub
parent fb18e27d87
commit 19c3c7fe44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,81 +17,71 @@ DOCUMENTATION = """
--- ---
module: blockinfile module: blockinfile
author: author:
- 'YAEGASHI Takeshi (@yaegashi)' - YAEGASHI Takeshi (@yaegashi)
extends_documentation_fragment: extends_documentation_fragment:
- files - files
- validate - validate
short_description: Insert/update/remove a text block short_description: Insert/update/remove a text block surrounded by marker lines
surrounded by marker lines.
version_added: '2.0' version_added: '2.0'
description: description:
- This module will insert/update/remove a block of multi-line text - This module will insert/update/remove a block of multi-line text
surrounded by customizable marker lines. surrounded by customizable marker lines.
options: options:
path: path:
aliases: [ dest, destfile, name ]
required: true
description: description:
- The file to modify. - The file to modify.
- Before 2.3 this option was only usable as I(dest), I(destfile) and I(name). - Before 2.3 this option was only usable as I(dest), I(destfile) and I(name).
aliases: [ dest, destfile, name ]
required: true
state: state:
required: false
choices: [ present, absent ]
default: present
description: description:
- Whether the block should be there or not. - Whether the block should be there or not.
choices: [ absent, present ]
default: present
marker: marker:
required: false
default: '# {mark} ANSIBLE MANAGED BLOCK'
description: description:
- The marker line template. - The marker line template.
"{mark}" will be replaced with "BEGIN" or "END". "{mark}" will be replaced with "BEGIN" or "END".
default: '# {mark} ANSIBLE MANAGED BLOCK'
block: block:
aliases: [ content ]
required: false
default: ''
description: description:
- The text to insert inside the marker lines. - The text to insert inside the marker lines.
If it's missing or an empty string, If it's missing or an empty string,
the block will be removed as if C(state) were specified to C(absent). the block will be removed as if C(state) were specified to C(absent).
aliases: [ content ]
default: ''
insertafter: insertafter:
required: false
default: EOF
description: description:
- If specified, the block will be inserted after the last match of - If specified, the block will be inserted after the last match of
specified regular expression. A special value is available; C(EOF) for specified regular expression. A special value is available; C(EOF) for
inserting the block at the end of the file. If specified regular inserting the block at the end of the file. If specified regular
expression has no matches, C(EOF) will be used instead. expression has no matches, C(EOF) will be used instead.
choices: [ 'EOF', '*regex*' ] default: EOF
choices: [ EOF, '*regex*' ]
insertbefore: insertbefore:
required: false
default: None
description: description:
- If specified, the block will be inserted before the last match of - If specified, the block will be inserted before the last match of
specified regular expression. A special value is available; C(BOF) for specified regular expression. A special value is available; C(BOF) for
inserting the block at the beginning of the file. If specified regular 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 expression has no matches, the block will be inserted at the end of the
file. file.
choices: [ 'BOF', '*regex*' ] choices: [ BOF, '*regex*' ]
create: create:
required: false
default: 'no'
choices: [ 'yes', 'no' ]
description: description:
- Create a new file if it doesn't exist. - Create a new file if it doesn't exist.
backup: type: bool
required: false
default: 'no' default: 'no'
choices: [ 'yes', 'no' ] backup:
description: description:
- Create a backup file including the timestamp information so you can - Create a backup file including the timestamp information so you can
get the original file back if you somehow clobbered it incorrectly. get the original file back if you somehow clobbered it incorrectly.
type: bool
default: 'no'
follow: follow:
required: false
default: "no"
choices: [ "yes", "no" ]
description: description:
- 'This flag indicates that filesystem links, if they exist, should be followed.' - 'This flag indicates that filesystem links, if they exist, should be followed.'
type: bool
default: 'no'
version_added: "2.1" version_added: "2.1"
notes: notes:
- This module supports check mode. - This module supports check mode.
@ -292,9 +282,9 @@ def main():
else: else:
n0 = len(lines) # insertafter=EOF n0 = len(lines) # insertafter=EOF
elif n0 < n1: elif n0 < n1:
lines[n0:n1+1] = [] lines[n0:n1 + 1] = []
else: else:
lines[n1:n0+1] = [] lines[n1:n0 + 1] = []
n0 = n1 n0 = n1
lines[n0:n0] = blocklines lines[n0:n0] = blocklines

@ -149,7 +149,6 @@ lib/ansible/modules/database/vertica/vertica_facts.py
lib/ansible/modules/database/vertica/vertica_role.py lib/ansible/modules/database/vertica/vertica_role.py
lib/ansible/modules/database/vertica/vertica_schema.py lib/ansible/modules/database/vertica/vertica_schema.py
lib/ansible/modules/database/vertica/vertica_user.py lib/ansible/modules/database/vertica/vertica_user.py
lib/ansible/modules/files/blockinfile.py
lib/ansible/modules/files/synchronize.py lib/ansible/modules/files/synchronize.py
lib/ansible/modules/files/tempfile.py lib/ansible/modules/files/tempfile.py
lib/ansible/modules/monitoring/bigpanda.py lib/ansible/modules/monitoring/bigpanda.py

Loading…
Cancel
Save