Commit Graph

256 Commits (1f96925159fd7fffc2a10dff53d7d953feed6164)

Author SHA1 Message Date
Daniel Hokka Zakrisson 1b5d039bf4 Extend executable= support in raw to include no execuable
Useful for managing not-UNIX things.
2013-01-08 17:45:37 +01:00
Dag Wieers 846161a1a4 Allow to change executable (shell/interpreter) when using raw
This patch adds an optional 'executable=' option to the raw command line to override the default shell (/bin/sh), much like the shell module does.
2012-12-23 20:49:02 +01:00
Dag Wieers 988db558b3 Add return code and error output to raw module
Since we use 'raw' heavily on equipment where 'command' and 'shell' are not (yet) working (and python may need to be installed first using raw) these improvements are necessary in order to write more complex scripts (with return code handling and separated stdout/stderr).

This change includes the following changes:

 - exec_command() now returns the return code of the command
 - _low_level_exec_command() now returns a dict, including 'rc', 'stdout' and 'stderr'
 - all users of the above interfaces have been improved to make use of the above changes
 - all connection plugins have been modified to return rc and stderr
 - fix the newline problem (stdout and stderr would have excess newlines)

In a future commit I intend to add assertions or error handling code to verify the return code in those places where it wasn't done. Since only the output was available, the return code was ignored, even though we expect them to be 0.
2012-12-23 18:04:54 +01:00
Daniel Hokka Zakrisson e54b4b1c9a Ignore arguments when checking for interpreter, and re-add before use 2012-12-02 14:28:52 +01:00
Daniel Hokka Zakrisson d5a456fbcf Merge pull request #1697 from bcoca/mint
Implements multiple interpreter overrides
2012-12-02 05:28:28 -08:00
Daniel Hokka Zakrisson f6245e17c1 Skip evaluating only_if for BYPASS_HOST_LOOP plugins 2012-11-28 21:37:30 +01:00
Daniel Hokka Zakrisson bda08c8a1b Avoid creating temporary directory for some action plugins
This ensures we don't litter remote systems with temporary directories
that don't get cleaned up, as well as speeds things up from not having
to touch every node.
2012-11-28 21:34:55 +01:00
Brian Coca 2f2bd87b06 multiple _interpreter overrides with ansible_<bin>_interpreter variables, not
just for python anymore
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2012-11-27 11:18:57 -05:00
Stephen Fromm 6a68d3813f Set LANG in module_common.py
Add constant DEFAULT_MODULE_LANG that defaults to C.  Can be set via
environment variable ANSIBLE_MODULE_LANG or configuration variable
module_lang.  Updated test-module to have same behavior.
2012-11-27 00:16:06 -08:00
Dag Wieers 85bba04a1c Provide a proper error when the provided port is not an integer
As reported on the mailinglist, the user received a ValueError when the port number was not templated (fixed in #1649) and therefore it was not an integer. This change will catch the exception and provide a proper error so it is more clear.
2012-11-20 19:06:27 +01:00
Daniel Hokka Zakrisson 48898993b9 Fix removing of temporary files 2012-11-20 16:51:19 +01:00
Daniel Hokka Zakrisson f95fefd8c5 Use plugin system to find modules 2012-11-18 19:09:21 +01:00
Daniel Hokka Zakrisson d2abfb9ff8 Ensure runner adds its basedir, so ansible can benefit from plugins 2012-11-18 18:37:20 +01:00
Daniel Hokka Zakrisson 5183417de8 Reinstate ANSIBLE_KEEP_REMOTE_FILES
Fixes #1395.
2012-11-18 18:32:45 +01:00
Michael DeHaan 3bc0adacbf Merge pull request #1634 from dhozac/ssh-password
Add password support to -c ssh via sshpass
2012-11-17 07:37:51 -08:00
Daniel Hokka Zakrisson e6fed9f216 Add password support to -c ssh via sshpass 2012-11-16 23:46:49 +01:00
Daniel Hokka Zakrisson 021172f78d Use the configured remote_tmp even for root 2012-11-16 23:46:17 +01:00
Romeo Theriault 4cd133ed8f add bsd md5 support to fetch module 2012-11-12 10:37:00 -10:00
Michael DeHaan c890ae18e7 Merge pull request #1575 from dhozac/parameterized-playbook-include
Add parameterized playbook includes
2012-11-12 05:17:38 -08:00
Michael DeHaan 451f05fa3d Merge pull request #1594 from sfromm/issue1342
Add ability to specify syslog facility for modules
2012-11-12 05:06:47 -08:00
Romeo Theriault 54b7f59416 remove verbose option on digest call 2012-11-11 19:43:40 -10:00
Stephen Fromm 06e54c0b97 Add ability to specify syslog facility for modules
Update constants.py so that one can specify environmental variable
ANSIBLE_SYSLOG_FACILITY or syslog_facility in ansible.cfg to define
the syslog facility to use.  Alternatively, you can specify
ansible_syslog_facility in inventory.  Runner now replaces
the syslog facility in the openlog() call with the default or
the injected variables ansible_syslog_facility.

This also updates hacking/test-module to behave similarly.
2012-11-11 00:14:08 -08:00
Daniel Hokka Zakrisson 383dc30560 Rename varReplaceWithItems to template_ds 2012-11-09 15:43:29 +01:00
Daniel Hokka Zakrisson e05e514861 Create a plugin loader system 2012-11-02 01:24:14 +01:00
Michael DeHaan 4c156e4df8 Merge pull request #1502 from dhozac/improved-lookup-plugins
Improved lookup plugins
2012-11-01 16:36:03 -07:00
Daniel Hokka Zakrisson fbda2d4628 Use default port if ansible_ssh_port is not set for the delegated node
Also add testcase for it.
2012-11-01 12:00:49 +01:00
Daniel Hokka Zakrisson c519d5dac0 Add a template lookup plugin
Requires that inject be passed to run
2012-10-31 16:57:10 +01:00
Daniel Hokka Zakrisson 37d9acc097 Make lookup API extensible and allow basedir to be passed
This allows using with_fileglob in play context, e.g.
- include: $item
  with_fileglob: tasks/*.yml
as well as prepares for other data to be passed.
2012-10-31 16:55:38 +01:00
Daniel Hokka Zakrisson 2c77cf1a49 Skip tasks with a with_* that is empty 2012-10-31 16:37:26 +01:00
Michael DeHaan c0747b7baa pep8 fixes 2012-10-30 20:42:07 -04:00
Jeroen Hoekx 77162e95e4 Send a host to runner executor instead of a letter.
Discovered in #1463 .
2012-10-29 09:45:44 +01:00
Michael DeHaan e04dab904a Use previous proven multiprocessing logic as the simplification didn't have the same Ctrl-C handling and may
be subject to race issues, though still don't pass Runner to each.  Still seems performant.
2012-10-26 18:11:38 -04:00
Michael DeHaan 19a5f86c2e Merge pull request #1452 from dhozac/with_items-as-plugin
Make with_items a lookup plugin
2012-10-25 18:24:34 -07:00
Michael DeHaan 9a141160a4 Merge pull request #1449 from dhozac/localhost-interpreters
Use the delegated host's interpreters
2012-10-25 18:19:26 -07:00
Daniel Hokka Zakrisson 026e251b94 Make with_items a lookup plugin 2012-10-25 15:10:33 +02:00
Michael DeHaan ffca0283b0 Closing pool explicitly may cause some exceptions on certain Pythons, disable for now. 2012-10-25 09:07:33 -04:00
Daniel Hokka Zakrisson 13a422261b Use the delegated host's interpreters 2012-10-25 14:10:04 +02:00
Lorin Hochstein 38fdc24966 Fix chmod occurring as wrong user when sudo as non-root
If you sudo to a non-root user, you get a permission denied error.
Here's an example:

    $ ansible myserver.example.com -m postgresql_db -a "db=mydatabase" -u ubuntu -s -U postgres
    myserver.example.com | FAILED >> {
        "failed": true,
        "msg": "chmod: changing permissions of `/tmp/ansible-
        1351092257.96-157699143369671/postgresql_db': Operation not
        permitted\n/usr/bin/python: can't open file '/tmp/ansible-
        1351092257.96-157699143369671/postgresql_db': [Errno 13]
        Permission denied\n",
        "parsed": false
    }

The problem is that ansible is doing the chmod as the sudo user
when it should be doing it as the remote user.
2012-10-24 11:30:56 -04:00
Michael DeHaan f1f44843c3 close the pool. 2012-10-24 07:56:23 -04:00
Michael DeHaan 92ce8a0517 Refine new keyboard interrupt handling. Output still a bit gross. 2012-10-24 07:46:24 -04:00
Michael DeHaan 47b1315ac7 Reinstate Ctrl+C handling 2012-10-24 07:40:48 -04:00
Michael DeHaan a4af4a7049 Since we are not needing to pass runner through the multiprocessing queue, just use
multiprocessing.pool.  Pushing so it can get wider testing.
2012-10-23 08:19:15 -04:00
Michael DeHaan 856dd5a9aa Don't pass runner instance through the mulitprocessing queue, fix temp dir removal 2012-10-23 08:04:32 -04:00
Daniel Hokka Zakrisson 1449c8ac67 Fix ansible_ssh_host again
This time with unit tests to ensure it keeps working.
2012-10-21 21:22:56 +02:00
Michael DeHaan cbc12f0dba Various performance streamlining and making the file features usable in all modules without daisy chaining. 2012-10-20 22:55:09 -04:00
Michael DeHaan 6fa1a49037 Fix the basic templating system such that when the template ends in '$', life continues as normal. 2012-10-20 10:57:52 -04:00
Daniel Hokka Zakrisson e3d18048d4 None is unfortunately not an integer 2012-10-19 16:18:38 +02:00
Michael DeHaan 31b45479e8 When using delegation, local_action should always use the local connection type. 2012-10-18 20:18:33 -04:00
Daniel Hokka Zakrisson 979999b886 Port should be an integer 2012-10-18 21:48:57 +02:00
Daniel Hokka Zakrisson 19797e1a29 Accessing a node that doesn't exist throws an exception 2012-10-18 21:48:10 +02:00
Michael DeHaan d5db8e937e Fix port overrides such that with fireball mode you don't have to specify an explicit port. 2012-10-17 22:50:17 -04:00
Michael DeHaan 0837a29e51 Only expand lists in templating inside of module action lines, to avoid breaking usage with with_items and "in" statements, etc 2012-10-17 19:35:12 -04:00
Michael DeHaan acf2c23808 Various tweaking of the delegate_to loop code. 2012-10-17 19:17:41 -04:00
Daniel Hokka Zakrisson 37b91c7b81 Fix ansible_ssh_host after 339c05bb 2012-10-17 19:17:41 -04:00
Michael DeHaan 22e3e7f323 Allow use of variables in delegate_to 2012-10-16 21:05:09 -04:00
Michael DeHaan a69e59ab2b Allows delegate_to to use inventory host/port info. 2012-10-16 20:57:37 -04:00
Daniel Hokka Zakrisson ab44a4abba Load additional plugins from path specified in configuration 2012-10-14 21:09:24 +02:00
Daniel Hokka Zakrisson 1aaf86069a Look for plugins in the playbook's basedir 2012-10-14 21:09:23 +02:00
Michael DeHaan c5d2f6b0d3 implement lookup plugins for arbitrary enumeration over arbitrary things. See the mailing list for some cool examples. 2012-10-12 20:07:05 -04:00
Michael DeHaan f3d7294690 Test for directory existance, fix exception catching granularity 2012-10-11 07:56:01 -04:00
Michael DeHaan 448c89a06d It has been reported that occasionally the md5sum command on certain platforms (?) can fail, where I suspect there is noise in the output stream.
In those events, capture the output so we can report the error more properly.
2012-10-11 07:44:41 -04:00
Michael DeHaan 04954dbc1e Makes ports configurable for fireball. Note port defaults really belong in the connection plugins, not runner, which can be refactored later. 2012-10-08 19:03:37 -04:00
Jeroen Hoekx 46a4ae74a7 Add inventory variables to hostvars.
Look up only when requested and cache the result.
2012-10-08 20:26:58 +02:00
Michael DeHaan 8e9344eef7 add an error when user tries to async something that can't be asynced 2012-09-30 20:06:55 -04:00
Daniel Hokka Zakrisson 8a8ffa2342 Allow task includes to work with with_items 2012-09-30 13:40:52 +02:00
Daniel Hokka Zakrisson 4b29c2cf74 Revert pull request #1091
Automatic quoting of variables in only_if breaks existing playbooks
where entire statements are put in a variable, and other cases. See
issue #1120 for details.
2012-09-28 13:58:23 +02:00
Michael DeHaan 69612ba16d The very first start of 'fireball mode', which uses ansible in SSH mode to deploy a ephemeral zeromq daemon (entirely optional) that is will die after
it is no longer used.  No key signing will be required.  At this point, development use only -- NOT complete.
2012-09-26 23:51:59 -04:00
Daniel Hokka Zakrisson d181a64315 Use repr on replacements for only_if 2012-09-25 20:14:58 -04:00
Michael DeHaan df147ab921 Merge pull request #1089 from tbielawa/runner_pause
Add 'pause' action plugin and support plugins skipping the host loop.
2012-09-25 17:11:54 -07:00
Michael DeHaan f8a9541405 add __init__ to action plugins 2012-09-25 08:24:35 -04:00
Tim Bielawa 58a4d2f7b4 Add 'pause' action plugin and support plugins skipping the host loop. 2012-09-25 01:13:35 -04:00
Michael DeHaan 734db4ffe9 Merge pull request #1080 from dagwieers/prompt-only_if
Add an only_if option to vars_prompt to make prompts conditional
2012-09-24 17:42:17 -07:00
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}')"
2012-09-24 23:55:54 +02:00
Daniel Hokka Zakrisson 34f7e6ffa0 Pass module arguments as argument instead of keeping it in runner 2012-09-23 23:38:26 +02:00
Michael DeHaan f5f17e98ff Merge pull request #1065 from dhozac/varreplace-include
Allow including files through variables
2012-09-23 10:20:26 -07:00
Daniel Hokka Zakrisson 8d97bb4f8e Add an ansible_ssh_host inventory variable 2012-09-22 00:57:55 +02:00
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"
2012-09-19 17:57:17 +02:00
Michael DeHaan b8c4bb9e6e Revert "Allow including files through variables"
This reverts commit bf47bb4753.

Conflicts:

	lib/ansible/utils.py
	test/TestUtils.py
2012-09-19 10:31:23 -04:00
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"
2012-09-17 16:03:59 +02:00
Timothy Appnel 9d5a79f586 Made groups.groupname and group_names variables accessible in playbooks.
Also modified code that feeds the groups data structure to templates so
that it resolves groups inside of groups to hostnames.
2012-09-10 10:42:26 -04:00
Timothy Appnel 20fc6a29d3 Made groups.groupname and group_names variables accessible in playbooks. 2012-09-07 18:07:52 -04:00
Michael DeHaan dc14681530 rename isset to is_set 2012-09-06 20:55:27 -04:00
Michael DeHaan 8621539341 Merge branch 'only_if-isset' of https://github.com/dhozac/ansible into devel 2012-09-06 20:55:11 -04:00
Michael DeHaan 633e513a65 Modular server-side actions (squash merge) 2012-09-06 18:57:04 -04:00
Daniel Hokka Zakrisson 14db2fa376 Add an isset("$var") function to only_if 2012-09-05 23:18:47 +02:00
Daniel Hokka Zakrisson 7a201dbb2e Keep result pristine for ignore_errors 2012-09-04 22:40:07 +02:00
Michael DeHaan bf92a9e4e0 Store invocation differently from an API perspective, but hide in callbacks 2012-08-20 20:41:53 -04:00
Grzegorz Nosek 73b0dd4ac0 Enable UTF-8 commands via the raw module
Paramiko does not allow Unicode strings as parameters, so encode
the command to UTF-8.

Test case:

ansible localhost -m raw -a 'echo ą'

(also tested on local and ssh transports without problems)
2012-08-20 18:26:21 -04:00
Michael DeHaan 3cbf885079 Change the order the setup cache is used to update things, such that the example/playbooks/conditional_part1.yml file
works as advertised
2012-08-18 19:49:49 -04:00
Michael DeHaan e13c33bb86 Moved Runner's ReturnData class to a seperate file. 2012-08-18 09:30:33 -04:00
Michael DeHaan f07e55c568 Adds 'delegate_to' as a task option which can be used to signal load balancers and outage windows. 2012-08-18 08:46:51 -04:00
Michael DeHaan fe923b9394 Adaptation of fix in #891 to avoid cut on only one md5 call. 2012-08-16 22:45:43 -04:00
Michael DeHaan eee2d1afd0 If ANSIBLE_KEEP_REMOTE_FILES=1 is set as an environment file, remote files will not be deleted, which is useful only for development debugging purposes. 2012-08-16 21:34:55 -04:00
Michael DeHaan de221e6b4b Add vars to host_vars to prevent some suprises 2012-08-14 20:35:01 -04:00
Michael DeHaan 3587ffdef3 Allow /bin/ansible to use --limit 2012-08-11 14:05:24 -04:00
Dietmar Schinnerl fbdddc7c74 Added utils.last_non_blank_line 2012-08-11 16:14:19 +02:00
Dietmar Schinnerl 993bb5c6f1 Added stub implementation of filters 2012-08-11 15:55:14 +02:00
Michael DeHaan 02ba5a48e0 Merge branch 'cleanup-imports' of https://github.com/jdavisp3/ansible into devel 2012-08-10 00:05:04 -04:00
Michael DeHaan a7415e5409 Merge pull request #836 from sfromm/rawfixes
Fixes for raw module usage and failure to open_session()
2012-08-10 17:01:47 -07:00
Sebastien Bocahu a3ff6b1958 Fix unneeded bashism
Signed-off-by: Sebastien Bocahu <sebastien@ispfr.net>
2012-08-10 15:57:51 +02:00