Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
a2e5d38f
Commit
a2e5d38f
authored
Aug 30, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #209 from dhozac/lineinfile
Add lineinfile module
parents
b12eeec8
09f7bd1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
rst/modules.rst
+1
-0
rst/modules/lineinfile.rst
+37
-0
No files found.
rst/modules.rst
View file @
a2e5d38f
...
...
@@ -55,6 +55,7 @@ Let's see what's available in the Ansible module library, out of the box:
.. include:: modules/get_url.rst
.. include:: modules/git.rst
.. include:: modules/group.rst
.. include:: modules/lineinfile.rst
.. include:: modules/mount.rst
.. include:: modules/mysql_db.rst
.. include:: modules/mysql_user.rst
...
...
rst/modules/lineinfile.rst
0 → 100644
View file @
a2e5d38f
.. _lineinfile:
lineinfile
``````````
This module will search a file for a line, and ensure that it is present or
absent.
This is primarily useful when you only want to change a single line in a file.
For other cases, see the copy or template modules.
+--------------------+----------+---------+----------------------------------------------------------------------------+
| parameter | required | default | comments |
+====================+==========+=========+============================================================================+
| state | no | present | 'absent' or 'present' |
+--------------------+----------+---------+----------------------------------------------------------------------------+
| name | yes | | The file to modify. |
+--------------------+----------+---------+----------------------------------------------------------------------------+
| regexp | yes | | The regular expression to look for in the file. For state=present, the |
| | | | pattern to replace. For state=absent, the pattern of the line to |
| | | | remove. |
+--------------------+----------+---------+----------------------------------------------------------------------------+
| line | maybe | | Required for state=present. The line to insert/replace into the file. Must |
| | | | match regexp=.
+--------------------+----------+---------+----------------------------------------------------------------------------+
| insertafter | no | EOF | Used with state=present. If specified, the line will be inserted after the |
| | | | specified regular expression. Two special values are available: BOF for |
| | | | inserting the line at the beginning of the file, and EOF for inserting the |
| | | | line at the end of the file. |
+--------------------+----------+---------+----------------------------------------------------------------------------+
Example::
lineinfile name=/etc/selinux/config regexp=^SELINUX= line=SELINUX=disabled
lineinfile name=/etc/sudoers regexp="^#includedir" line="#includedir /etc/sudoers.d"
lineinfile name=/etc/httpd/conf/httpd.conf regexp="^ServerName " insertafter="^#ServerName " line="ServerName ansible.example.com"
lineinfile name=/etc/sudoers state=absent regexp="^%wheel"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment