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
d039fbe2
Commit
d039fbe2
authored
Aug 03, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3649 from dekked/extra-vars-from-file
Extra vars from file
parents
fa647e43
d5054748
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
bin/ansible-playbook
+14
-4
docsite/latest/rst/playbooks2.rst
+5
-2
No files found.
bin/ansible-playbook
View file @
d039fbe2
...
@@ -94,10 +94,20 @@ def main(args):
...
@@ -94,10 +94,20 @@ def main(args):
options
.
ask_sudo_pass
=
options
.
ask_sudo_pass
or
C
.
DEFAULT_ASK_SUDO_PASS
options
.
ask_sudo_pass
=
options
.
ask_sudo_pass
or
C
.
DEFAULT_ASK_SUDO_PASS
(
sshpass
,
sudopass
)
=
utils
.
ask_passwords
(
ask_pass
=
options
.
ask_pass
,
ask_sudo_pass
=
options
.
ask_sudo_pass
)
(
sshpass
,
sudopass
)
=
utils
.
ask_passwords
(
ask_pass
=
options
.
ask_pass
,
ask_sudo_pass
=
options
.
ask_sudo_pass
)
options
.
sudo_user
=
options
.
sudo_user
or
C
.
DEFAULT_SUDO_USER
options
.
sudo_user
=
options
.
sudo_user
or
C
.
DEFAULT_SUDO_USER
if
options
.
extra_vars
and
options
.
extra_vars
[
0
]
in
'[{'
:
extra_vars
=
utils
.
json_loads
(
options
.
extra_vars
)
extra_vars
=
{}
else
:
if
options
.
extra_vars
:
extra_vars
=
utils
.
parse_kv
(
options
.
extra_vars
)
if
options
.
extra_vars
.
startswith
(
"@"
):
# Argument is a JSON file
with
open
(
options
.
extra_vars
[
1
:])
as
fd
:
extra_vars
=
utils
.
json_loads
(
fd
.
read
())
elif
options
.
extra_vars
[
0
]
in
'[{'
:
# Arguments as JSON
extra_vars
=
utils
.
json_loads
(
options
.
extra_vars
)
else
:
# Arguments as Key-value
extra_vars
=
utils
.
parse_kv
(
options
.
extra_vars
)
only_tags
=
options
.
tags
.
split
(
","
)
only_tags
=
options
.
tags
.
split
(
","
)
skip_tags
=
options
.
skip_tags
skip_tags
=
options
.
skip_tags
if
options
.
skip_tags
is
not
None
:
if
options
.
skip_tags
is
not
None
:
...
...
docsite/latest/rst/playbooks2.rst
View file @
d039fbe2
...
@@ -74,7 +74,7 @@ Overriding Changed Result
...
@@ -74,7 +74,7 @@ Overriding Changed Result
.. versionadded:: 1.3
.. versionadded:: 1.3
When a shell/command or other module runs it will typically report
When a shell/command or other module runs it will typically report
"changed" status based on whether it thinks it affected machine state.
"changed" status based on whether it thinks it affected machine state.
Sometimes you will know, based on the return code
Sometimes you will know, based on the return code
or output that it did not make any changes, and wish to override
or output that it did not make any changes, and wish to override
...
@@ -289,6 +289,9 @@ As of Ansible 1.2, you can also pass in extra vars as quoted JSON, like so::
...
@@ -289,6 +289,9 @@ As of Ansible 1.2, you can also pass in extra vars as quoted JSON, like so::
The key=value form is obviously simpler, but it's there if you need it!
The key=value form is obviously simpler, but it's there if you need it!
As of Ansible 1.3, extra vars can be loaded from a JSON file with the "@" syntax::
--extra-vars "@some_file.json"
Conditional Execution
Conditional Execution
`````````````````````
`````````````````````
...
@@ -822,7 +825,7 @@ The 'register' keyword decides what variable to save a result in. The resulting
...
@@ -822,7 +825,7 @@ The 'register' keyword decides what variable to save a result in. The resulting
- shell: echo "motd contains the word hi"
- shell: echo "motd contains the word hi"
when: motd_contents.stdout.find('hi') != -1
when: motd_contents.stdout.find('hi') != -1
As shown previously, the registered variable's string contents are accessible with the 'stdout' value.
As shown previously, the registered variable's string contents are accessible with the 'stdout' value.
The registered result can be used in the "with_items" of a task if it is converted into
The registered result can be used in the "with_items" of a task if it is converted into
a list (or already is a list) as shown below. "stdout_lines" is already available on the object as
a list (or already is a list) as shown below. "stdout_lines" is already available on the object as
well though you could also call "home_dirs.stdout.split()" if you wanted, and could split by other
well though you could also call "home_dirs.stdout.split()" if you wanted, and could split by other
...
...
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