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
c86b34da
Commit
c86b34da
authored
Feb 23, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lots of docsite additions for new features + cleanup lineinfile YAML docs
parent
3422ae67
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
10 deletions
+55
-10
docsite/rst/playbooks2.rst
+40
-0
library/lineinfile
+15
-10
No files found.
docsite/rst/playbooks2.rst
View file @
c86b34da
...
...
@@ -946,6 +946,46 @@ feature produces a large amount of output, it is best used when checking a singl
ansible-playbook foo.yml --check --diff --limit foo.example.com
Passing Complex Arguments From Dictionaries
```````````````````````````````````````````
As a review, most tasks in ansbile are of this form::
tasks:
- name: ensure the cobbler package is installed
yum: name=cobbler state=installed
However, in some cases, it may be useful to feed arguments directly in from a hash (dictionary). In fact, a very small
number of modules (the CloudFormations module is one) actually require complex arguments that can't be fit
into a key=value system. To pass arguments in from a hash (dictionary), do this::
tasks:
- name: call a module that requires some complex arguments
module_name_goes_here: asdf=1234
args:
fibonacci_list
- 1
- 1
- 2
- 3
my_pets:
dogs:
- fido
- woof
fish:
- limpet
- nemo
While complex arguments can be fed to most modules in Ansible, they should only be used where needed. Note
that variable interpolation works exactly as you would suspect, so you can use "${foo}" and so on in values
inside of the dictionary you pass to "args".
If both key=value arguments are given along with 'args', the key=value arguments take priority. This technically
means you can set defaults by using 'args' if you so choose, though that is not the intended purpose of this
feature.
Advanced Task Includes
``````````````````````
...
...
library/lineinfile
View file @
c86b34da
...
...
@@ -89,17 +89,22 @@ options:
get the original file back if you somehow clobbered it incorrectly.
others:
description:
- All arguments accepted by the M(file) module also work here. If you
use file arguments with C(state=absent) and the file exists, it's perms,
ownership or SE linux context will be updated if needed.
- All arguments accepted by the M(file) module also work here.
required: false
examples:
- code: 'lineinfile: dest=/etc/selinux/config regexp=^SELINUX= line=SELINUX=disabled'
- code: 'lineinfile: dest=/etc/sudoers state=absent regexp="^
%
wheel"'
- code: "lineinfile: dest=/etc/host regexp='^127
\
.0
\
.0
\
.1' line='127.0.0.1 localhost' owner=root group=root mode=0644"
- code: 'lineinfile: dest=/etc/httpd/conf/httpd.conf regexp="^Listen " insertafter="^#Listen " line="Listen 8080"'
- code: 'lineinfile: dest=/etc/services regexp="^# port for http" insertbefore="^www.*80/tcp" line="# port for http by default"'
- code: "lineinfile:
\\\"
dest=/etc/sudoers state=present regexp='^
%
wheel' line ='
%
wheel ALL=(ALL) NOPASSWD: ALL'
\\\"
"
"""
EXAMPLES
=
"""
lineinfile: dest=/etc/selinux/config regexp=^SELINUX= line=SELINUX=disabled
lineinfile: dest=/etc/sudoers state=absent regexp="^
%
wheel"
lineinfile: dest=/etc/host regexp='^127
\
.0
\
.0
\
.1' line='127.0.0.1 localhost' owner=root group=root mode=0644
lineinfile: dest=/etc/httpd/conf/httpd.conf regexp="^Listen " insertafter="^#Listen " line="Listen 8080"
lineinfile: dest=/etc/services regexp="^# port for http" insertbefore="^www.*80/tcp" line="# port for http by default"
lineinfile:
\\\"
dest=/etc/sudoers state=present regexp='^
%
wheel' line ='
%
wheel ALL=(ALL) NOPASSWD: ALL'
\\\"
"""
...
...
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