Commit Graph

163 Commits (a5ee6ff1e56ff3abdcb42a9b2ac4518a0eeead13)

Author SHA1 Message Date
Daniel Hokka Zakrisson 2f05e95d8a Use lookup plugins for task include with_* 13 years ago
Michael DeHaan 109632e3bc Revert "Vars specified via CLI have the highest priority."
Reverting as this as reported allows some variables to clobber each other.
We'll work on a different fix.

This reverts commit c5469f6367.
13 years ago
Aleksej Romanov c5469f6367 Vars specified via CLI have the highest priority. 13 years ago
Daniel Hokka Zakrisson b8b34b5110 Keep processing the rest of the vars_files even if one has vars 13 years ago
Daniel Hokka Zakrisson 564a212b3c Only gather facts once per node per playbook run
Unless gather_facts: True is on the play
13 years ago
Daniel Hokka Zakrisson 48c5d696d2 Remove debug print statement 13 years ago
Daniel Hokka Zakrisson a83aa1071b Give each task its own module_vars
Otherwise each task will overwrite the previous' items, among
other things.
13 years ago
Michael DeHaan d0eba79760 Template out sudo_user so you can pass in variables using --extra-vars 13 years ago
Daniel Hokka Zakrisson 8a8ffa2342 Allow task includes to work with with_items 13 years ago
Dag Wieers e7af005408 Revert only_if for variables and templating prompt
Since the condition was not templated, it wasn't working.
Only variables in local scope were used, which made this not very practical
13 years ago
Dag Wieers 6b6e3c64c8 Fix a typo in the prompt code
This is unfortunately related to not being able to reuse the same code that was tested.
13 years ago
Michael DeHaan 734db4ffe9 Merge pull request #1080 from dagwieers/prompt-only_if
Add an only_if option to vars_prompt to make prompts conditional
13 years ago
Dag Wieers 4e9a970616 Add an only_if option to vars_prompt to make prompts conditional
Sometimes you may want to allow variables through host_vars or inventory, but prompt for a value if it is not set or if the value does not conform to something specific. This option allows you to specify when you want to offer a prompt.

This patch also moves check_conditional to utils, and adds an is_unset() function which is nicer to read:

    only_if: "not is_set('${var}')"

vs

    only_if: "is_unset('${var}')"
13 years ago
Dag Wieers 069feb5d9c Template the variable prompt to customize the message
We have a password-prompt for a configurable login name. Since we require to ask the password for this specific login, it is important to indicate what password needs to be prov ided on the prompt. So the prompt needs to be templated. That's what this patch does.
13 years ago
Daniel Hokka Zakrisson cc948f339c Allow including files through variables
$FILE{file} will be replaced with the contents of "file"
$PIPE{cat file} will be replaced with the output of "cat file"
13 years ago
Michael DeHaan b8c4bb9e6e Revert "Allow including files through variables"
This reverts commit bf47bb4753.

Conflicts:

	lib/ansible/utils.py
	test/TestUtils.py
13 years ago
Daniel Hokka Zakrisson bf47bb4753 Allow including files through variables
$FILE{file} will be replaced with the contents of "file"
$PIPE{cat file} will be replaced with the output of "cat file"
13 years ago
Lorin Hochstein b9e100a506 Support import of playbooks in other directories
Previously, importing a playbook in a different directory didn't
work because all of the relative paths were resolved relative to
the top-level playbook.

This patch resolves relative paths on a per-play level instead of
relative to the directory of the top-level playbook.

Also removes the dirname argument from the Play._get_vars method
since this argument wasn't used in the metho dbody.
13 years ago
Mark Theunissen 2755602dcb Check to make sure that tags passed as parameters actually exist 13 years ago
Michael DeHaan 2833f48ed3 Make a particular error about an invalid include statement a bit clearer. 13 years ago
Michael DeHaan 898d7676f7 Adds the 'serial' keyword to a playbook which controls how many hosts can be running through a playbook at a single time.
The default is 0, which means all hosts.  If set to 1, each host would run a playbook all the way through before moving
on the next host.  Fact gathering is still parallel, regardless of the serial setting.
13 years ago
Michael DeHaan de221e6b4b Add vars to host_vars to prevent some suprises 14 years ago
Michael DeHaan 6de8c27085 Load parent groups when processing group_vars 14 years ago
Michael DeHaan 72faf8eb0a fix indents 14 years ago
Michael DeHaan 05d6e74cce Merge branch 'vars_prompt_encrypt' of https://github.com/cocoy/ansible into devel 14 years ago
Michael DeHaan 07f459f3b2 Allow user to be passed in via --extra-vars 14 years ago
Michael DeHaan 98a5565106 Fixing up parameterized task includes such that variables can be easily handed to them. 14 years ago
Rodney Quillo d1f821361d vars_prompt encrypt from mgw 14 years ago
Michael DeHaan faed4b5a33 whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added
in 0.6 release)
14 years ago
Michael DeHaan 86ec639176 add error handling if you try to load files in the wrong data format 14 years ago
Michael DeHaan 08c5fe875b yell if input data for host or group vars are not hashes 14 years ago
Michael DeHaan ee5f12cd40 Slight tweaks on vars_prompt upgrades 14 years ago
Petros Moisiadis c717934b7e Improved 'vars_prompt' syntax to support prompt text and (non-)private input
An example of the new syntax:

vars_prompt:
 - name: 'secret_variable_name"
   prompt: "Enter secret value: "
   private: "yes"
 - name: "nonsecret_variable_name"
   prompt: "Enter non-secret value: "
   private: "no"
14 years ago
Michael DeHaan da4562f495 changes to not clear the setup cache between runs, and also decide to run plays with no tasks
in them if it looks like they are not tagged, because if that is the case, then we may just
be gathering facts about them.
14 years ago
Michael DeHaan 617f9dc942 Added some caching logic to improve external inventory scripts, removed some debug statements. 14 years ago
Michael DeHaan 396b81b647 Remove this check as it wasn't really needed and in recent refinements keeps the group_vars stuff from working
as desired.
14 years ago
Michael DeHaan b574c70006 host and group vars should update the setup cache 14 years ago
Michael DeHaan ba3466af95 The following paths are now implict and optional in vars_files:
./group_vars/groupname.yml (for all groups the host is in)
./host_vars/hostname.yml (for the hostname given in the inventory)

This requires an actual inventory file, not script and the paths are relative
to the directory of the inventory file.
14 years ago
Peter Sankauskas 4b66d98332 Adding missing colon... can't believe I missed that... sorry 14 years ago
Peter Sankauskas 413fb15e0a Conditional Imports should only import the first file in the list, not all of them. This change stops looping through the vars_files list as soon as a file is found. 14 years ago
Michael DeHaan 3c2cbae68e Plays and tasks now yell when they see parameters they do not understand, so that typos like 'var' for 'vars'
don't result in people having to ask questions about what is wrong with their playbook
14 years ago
Michael DeHaan e4a546e8bb Make it possible to use variables from 'vars' in the paths to task level include statements. 14 years ago
Michael DeHaan 5f69c557b9 Fix for the way host variables were being swallowed, plus some overall simplification. Deciding what
dictionary to use for templating now happens in exactly one place (executor_internal) and the "inject"
dictionary is passed to what needs it.
14 years ago
Michael DeHaan 61d8e2e7c7 with_items should be processed inside the task class, also make first_available_file
and with_items incompatible.  Most cases that would need this could be solved
with vars_files.
14 years ago
Michael DeHaan 706cfd9ade Misc cleanup -- moved function out of utils, removed debug statement. 14 years ago
Michael DeHaan 60d64251f8 Allow gather_facts: False in a playbook as a way of disabling the fact step if you know
you aren't going to need it.
14 years ago
Michael DeHaan 64c51ade1e Change the way we do with_items to make them happen next to each other in runner, which eliminates the problem of with_items and vars_files sometimes not playing nice with each other.
(Also a fix for the user module error handling when the user
is not present at the time of the return.  This can only really be caused by multiple ansible executions).
14 years ago
Michael DeHaan 028f216689 Error handling and magic around with_items, to let you know when variables are usable inside it and when not. 14 years ago
Michael DeHaan 102b22be1f Make the logic behind vars_files smarter, so host specific vars go into the setup cache, but other variables
are usable top level.  This allows vars_files data to be used, most of the time, just fine in with_items,
(error handling pending) but is mostly a memory and efficiency thing.
14 years ago
Michael DeHaan 15b2b3a020 Warn if something loaded by vars_files is not a dictionary 14 years ago
Michael DeHaan 611e5b0c90 Make adding tags to a playbook work as shorthand to tagging all tasks in the play. 14 years ago
Michael DeHaan a765deccce Allow top level playbook files to import other playbook files, added some basic
playbook structure checking.
14 years ago
Michael DeHaan 969c3feb13 Allow include statements from plays to specify tags (see tags.yml example file).
Also be smart and don't run a play at all if no tasks in the play match any of the tags specified.  This includes not running the setup actions!
14 years ago
Michael DeHaan 83f23ef861 Basic support for tagging tasks and selecting a subset of tasks to run with --tags. 14 years ago
Daniel Hokka Zakrisson a05da2d312 Allow with_items to specify a variable 14 years ago
Daniel Hokka Zakrisson 933b5e8631 Reduce code duplication 14 years ago
Daniel Hokka Zakrisson dff8d7be04 Expand vars_files identically for lists and non-lists 14 years ago
John Kleint 70837469c6 Properly template list of hosts in playbooks.
In playbooks, hosts can be a YAML list. We templated the list before
converting it to a semicolon-separated string, which actually templated its
repr. This converts to a string first. A basic unit test is included.
14 years ago
Brad Olson 7ea4a0e895 Avoid traceback when vars file has no vars items. Could warn or fail instead. 14 years ago
Cosmin Luță 74bfd7eb81 Removed line that caused stacktrace 14 years ago
Michael DeHaan 4664e354c3 Get with_items to work with new play/task architecture. 14 years ago
Michael DeHaan ecb944892d Tweaks on previous refactoring of playbook, version bump a 0.4 reference, remove some debug, etc 14 years ago
Michael DeHaan b9b53d1941 Playbook refactoring -- work in progress. 14 years ago