Commit graph

2585 commits

Author SHA1 Message Date
James Cammarata
b1a37dcc08 Revert "Rejoin args list into a string for run_command when using an unsafe shell"
This reverts commit 4273cb2d8e.
2014-03-13 14:04:51 -05:00
James Cammarata
4273cb2d8e Rejoin args list into a string for run_command when using an unsafe shell
This allows the use of an args list with leading environment variables,
which otherwise would fail due to the way Popen works.
2014-03-13 13:51:59 -05:00
Michael DeHaan
d1753046e0 Revert "Correctly catch template errors without returning invalid data"
This reverts commit 3cd7d47b7e.
2014-03-13 07:46:19 -04:00
James Cammarata
303e085f8b Only use cwd in run_command kwargs if the directory exists 2014-03-12 15:59:55 -05:00
James Cammarata
60a7f57300 Make sure the cwd exists in run_command before trying to use it 2014-03-12 14:33:31 -05:00
Dan Koch
bbf320fd22 Work around for cwd stat problems with run_command and sudo
This fixes issue #6443
2014-03-12 14:59:50 -04:00
James Cammarata
2c7d58abe0 Compile ca certs into a temp file to reduce number of attempts
For those who may have a large number of certs found, this can reduce
the number of ssl connections attempted.
2014-03-12 13:45:16 -05:00
Michael DeHaan
d37f0c6d12 Use same implementation as ssh.py for "is in host file" checks in module code, prevents git module from adding keys more than once. 2014-03-12 14:11:45 -04:00
Michael DeHaan
6d841d120e Don't process shell commands as arrays. 2014-03-12 11:57:28 -04:00
James Cammarata
86d2ee4b97 Don't append tags from roles to the plays tags list
Fixes #6393
2014-03-12 10:41:18 -05:00
James Cammarata
a9017af2bb Adding validate_certs to all modules that use fetch_url 2014-03-12 10:19:54 -05:00
Michael DeHaan
cfabc2e28a module.run_command is intended to bypass the shell here, so can't do ">>" 2014-03-12 10:57:49 -04:00
James Cammarata
7f38cff989 Remove unused code from get_ca_certs() function 2014-03-12 09:33:19 -05:00
James Cammarata
804e4166c8 Rewriting ssl validation to try multiple certs found in paths
Previously, the function checked only for a single CA root cert, however
some distributions may have multiple certs in a directory. This will now
try any .crt or .pem file contained within several common paths for
each platform.

Fixes #6412
2014-03-12 09:21:19 -05:00
Michael DeHaan
0b0ca95731 Expand environment variables and tildes passed to commands generically across the board. 2014-03-12 10:11:09 -04:00
James Tanner
0e38f5dfdc Check for hash availability during vault operations 2014-03-12 09:38:29 -04:00
Brian Coca
906e59d8a8 added new role_names variable that exposes current roles list 2014-03-11 22:13:29 -04:00
Brian Coca
7778aca966 templates ignore_errors 2014-03-11 21:30:58 -04:00
James Cammarata
6c25e78299 Merge branch 'devel' of https://github.com/dparalen/ansible into dparalen-devel 2014-03-11 15:34:15 -05:00
James Tanner
e4e64a9699 Rename lxc to libvirt_lxc 2014-03-11 16:16:24 -04:00
James Cammarata
bca6adc812 Merge pull request #4064 from mscherer/lxc
Add a plugin that permit to use ansible for lxc system, using libvirt
2014-03-11 15:12:51 -05:00
James Cammarata
430cce9df3 Merge branch 'ec2_security_token' of https://github.com/willthames/ansible into willthames-ec2_security_token 2014-03-11 10:45:38 -05:00
Serge van Ginderachter
6b1cb22fc3 Allow hash_behaviour=merge to be respected in core inventory
(For now, this means, enable it also for inventory scripts)
2014-03-11 12:49:54 +01:00
Serge van Ginderachter
29c60bdaff group_vars plugin: do not parse hidden files in subfolders, e.g. avoid .svn/ 2014-03-11 12:20:58 +01:00
James Tanner
6740a1f342 Wrap crypto.hash imports with try/except 2014-03-10 19:44:08 -04:00
Michael DeHaan
411bcb7161 Merge remote branch 'real/devel' into devel 2014-03-10 19:11:21 -04:00
Michael DeHaan
2fa6110961 Update the message about pycrypto to include that python-devel must be installed. 2014-03-10 17:23:37 -04:00
James Tanner
0d6f6ad282 Implement new default cipher class AES256 2014-03-10 16:15:44 -05:00
Michael DeHaan
20f0157152 Merge pull request #6378 from franckcuny/headers-gce-utils
Add BSD license to module_utils/gce.py
2014-03-10 16:14:51 -05:00
James Tanner
ba0fec4f42 Force command action to not be executed by the shell unless specifically enabled 2014-03-10 16:13:30 -05:00
James Cammarata
9730157525 Validate SSL certs accessed through urllib*
* Adds another module utility file which generalizes the
  access of urls via the urllib* libraries.
* Adds a new spec generator for common arguments.
* Makes the user-agent string configurable.

Fixes #6211
2014-03-10 16:06:52 -05:00
James Cammarata
6577ff5f85 Add tags from handlers to tag availability calculation 2014-03-10 16:06:13 -05:00
Richard Isaacson
4993cb57f4 Merge pull request #6283 from magicrobotmonkey/upstream
fix missing stdin in _parallel_runner

Tested with GIST https://gist.github.com/risaacson/7290d30a612e0c70ea1b.
Passes "make tests"
Passes non_destructive tests.
2014-03-10 14:38:56 -05:00
Franck Cuny
82f99bfa3d Add BSD license to module_utils/gce.py 2014-03-10 12:02:45 -07:00
Matt Martz
4b400ca5e9 Only used stripped data for testing if the file is json, but used unstripped when actually parsing. Fixes #6348 2014-03-10 13:43:34 -05:00
Seth Woodworth
1d5db30067 Updates loop warning, removes unnecessary c 2014-03-09 00:19:28 -05:00
James Cammarata
04a6dc6d12 Check for skipped tags in passed role variables before adding to them
Fixes #6330
2014-03-08 18:55:42 -06:00
Michael DeHaan
d2cb35f898 Merge pull request #6320 from angstwad/instance-redo
Use isinstance() rather than a check using type()
2014-03-07 20:41:33 -06:00
James Cammarata
4753804ab4 Merge pull request #6332 from jimi-c/issue_6329_space_in_var
Correctly catch template errors without returning invalid data
2014-03-07 17:38:47 -05:00
James Cammarata
e3b887f770 Fix range issue in inventory and add additional error checking
Fixes #6331
2014-03-07 16:34:04 -06:00
James Cammarata
3cd7d47b7e Correctly catch template errors without returning invalid data
Fixes #6329
2014-03-07 14:36:54 -06:00
James Cammarata
f80d02d841 Properly wrap logical elements together for su/sudo detection 2014-03-07 00:07:10 -06:00
James Cammarata
b6056044b7 Partial revert of 73c883c due to issues with handlers in roles
Fixes #6322
2014-03-06 21:13:40 -06:00
Michael DeHaan
e486dbab04 Use the loaded variable since we have it assigned, not just for error detection. 2014-03-06 22:15:21 -05:00
Michael DeHaan
3f07ec3d73 Fixup JSON error reporting in previous commits. 2014-03-06 22:07:35 -05:00
Michael DeHaan
a4d01b0891 Also search .json filenames 2014-03-06 21:47:49 -05:00
Michael DeHaan
79799f6819 Allow any file that can be in YAML to also be in JSON. This is primarily done to support non-visual editors better. 2014-03-06 21:42:51 -05:00
James Cammarata
a0f939581d Merge branch 'aresch-devel' into devel 2014-03-06 16:47:06 -06:00
Paul Durivage
3cce3650e5 Use isinstance() rather than a check using type() 2014-03-06 16:16:25 -06:00
Richard Isaacson
119434d079 Merge pull request #6319 from risaacson/fix_test_dir_inventory
Fix TestInventory Unit Tests

Tested clean.
2014-03-06 15:43:45 -06:00
James Cammarata
9b79591f23 Merge branch 'devel' of https://github.com/aresch/ansible into aresch-devel 2014-03-06 15:17:55 -06:00
James Cammarata
2a0028e687 Sanitize run_command argument output
Fixes #6316
2014-03-06 13:34:22 -06:00
Andrew Resch
4d80019ac8 Fix logic checking for both sudo and su, and their respective users 2014-03-06 10:24:16 -08:00
Richard C Isaacson
16fe09eef8 Fixes related to uncommenting test_dir_inventory in TestInventory.
0. Uncomment the test.
1. Test fails.
2. Make vars unique per file in test inventory files.
3. Modify token addition to not ast.literal_eval(v) a variable containing a hash.
4. Modify vars to have an escape in test inventory file.
5. Catch exceptions explicitly. Any unknown exceptions should be a bug.
6. Test passes.
2014-03-06 12:09:53 -06:00
James Cammarata
9f2999df79 Un-escape newlines in delimiters for assemble module 2014-03-06 09:44:56 -06:00
Brian Coca
79809b67dc fixed another line with same issues
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
2014-03-06 08:43:24 -05:00
Brian Coca
d3d5680d8f tags lists are properly uniqued and joined now, also avoids type issues when passed as list/set or strings
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
2014-03-06 08:28:36 -05:00
Will Thames
b9a7352e0a Work to allow security tokens and profiles to work with Ansible
Allow security tokens and profiles to be used as arguments
to the 'common' ec2 modules

Mostly refactoring to provide two new methods,
`get_aws_connection_info`, which results in a dict that can be
passed through to the boto `connect_to_region` calls, and
`connect_to_aws` that can pass that dict through to the
`connect_to_region` method of the appropriate module.

Tidied up some variable names

Works around boto/boto#2100

profiles don't work with boto < 2.24, but this detects for that
and fails with an appropriate message. It is designed to work
if profile is not passed but boto < 2.24 is installed.

Modifications to allow empty aws auth variables to be passed
(this is useful if wanting to have the keys as an optional
parameter in ec2 calls - if set, use this value, if not set,
use boto config or env variables)

Reworked validate_certs improvements to work with refactoring

Added documentation for profile and security_token to affected modules
2014-03-06 16:28:30 +10:00
James Cammarata
0e98496e12 Merge pull request #6299 from jimi-c/issue_4656_role_deps_across_plays
Keep track of role dependencies across plays
2014-03-05 19:46:46 -06:00
Michael DeHaan
94a7fb60fe Allow escaped comments in inventory files. 2014-03-05 20:10:25 -05:00
aresch
23a0468a4b Fix respecting remote_tmp when sudo is used 2014-03-05 16:25:42 -08:00
James Tanner
4e8ed92130 Fixes #6077 decode escaped newline characters in content for the copy module 2014-03-05 18:49:54 -05:00
Richard C Isaacson
b41d8106ff Revert "Merge pull request #6287 from risaacson/fix_hash_in_var"
This reverts commit a808287451, reversing
changes made to 6129ea7566.
2014-03-05 14:49:30 -06:00
James Cammarata
73c883c122 Keep track of role dependencies across plays
Also fixes a bug in which tags specified on top-level roles were
not being passed down to dependent roles.

Fixes #4656
2014-03-05 14:37:37 -06:00
Richard Isaacson
a808287451 Merge pull request #6287 from risaacson/fix_hash_in_var
Fix inventory for test_dir_inventory, merge PRs from GH-5749, cleanup some formatting.
2014-03-05 14:20:27 -06:00
James Tanner
6129ea7566 Fixes #6298 and adds a sudo unit test for synchronize 2014-03-05 14:51:40 -05:00
Richard C Isaacson
38abd5e20e Break this out into a reusable function and document regex shortcomings. 2014-03-05 10:50:58 -06:00
Luca Berruti
7cf363910a fixes #6244 2014-03-05 09:18:01 +01:00
jctanner
40ee030790 Merge pull request #6265 from franckcuny/gce-fixes
Add credential parameters to the GCE modules.
2014-03-05 00:11:52 -05:00
Franck Cuny
6294264dc4 Add credential parameters to the GCE modules.
In order to simplify the workflow with the GCE modules, it's now
possible to add the parameters and project name as arguments to the
various GCE modules.

The inventory plugin also returns the IP of the host in
`ansible_ssh_host` so that you don't have to specify IPs into the
inventory file.

Some update to the documentation are also added.

Closes #5583.
2014-03-04 19:27:49 -08:00
Richard C Isaacson
49bd8b0b35 Fix inventory for test_dir_inventory
It came up that fixing this unit test may relate to another ticket that is open. This work allows us to uncomment this unit test by fixing how we pars variables allowing a quoted variable to contain a '#'.

Work also went into cleaning up some of the test data to clarify what was working.

Lastly work went into cleaning up formatting so that the code is easily read.
2014-03-04 18:31:49 -06:00
Aaron Bassett
5c589af191 fix missing stdin in _parallel_runner 2014-03-04 16:00:26 -05:00
Richard Isaacson
92aacb198c Merge pull request #6156 from iiordanov/devel
Add support for checking host against global known host files.

The effect of this is that before this fix if files are spread across the known_hosts file but not in the ~/known_hosts file the hosts will execute sequentially. This PR augments the functionality so that all of the knowns hosts will execute in parallel.
2014-03-03 23:51:51 -06:00
Richard Isaacson
e79d859dfb Merge pull request #6213 from sergevanginderachter/fix-delegate-templating
Fixes templating of ansible_ssh_host for delegates.

Tested that this works. Confirmed.
2014-03-03 23:10:09 -06:00
Michael DeHaan
435104065e Merge pull request #6248 from hkariti/fix_list_copy
Fix incorrect use of copy() on list, causing a traceback
2014-03-03 17:11:30 -05:00
Jesse Keating
0c2c37a47a Avoid range selection on empty groups
This prevents a traceback when the group is empty.
Fixes #6258
2014-03-03 13:23:27 -08:00
James Tanner
623cd9ac50 Revert "Merge pull request #6250 from dagwieers/gather_facts-once"
This reverts commit b769b4181a, reversing
changes made to 1e01fb856d.
2014-03-03 10:20:42 -05:00
Dag Wieers
0da06eff5c Fix regression causing setup to run for every play
This patch makes sure setup only runs once, unless it is enforced on a play.
2014-03-03 16:15:19 +01:00
Hagai
0e4b38ed5a Fix incorrect use of copy on list 2014-03-03 14:47:57 +02:00
Tefnet
c652802d29 missing import in assert module
Fixed missing ansible.errors import in assert module
2014-03-02 00:59:17 +01:00
Michael DeHaan
16d3be03af Remove a few extra legacy variable feature references. 2014-02-28 18:51:15 -05:00
Michael DeHaan
46ec8759d5 Remove the legacy templating code, which was guarded by deprecation warnings in the previous two releases, and undocumented for a long time. use {{ foo }} to access variables instead of ${foo} or $foo. 2014-02-28 18:38:45 -05:00
Michael DeHaan
9d01d88a57 Bump versions on the devel branch (devel branch version is 1.6) 2014-02-28 18:27:16 -05:00
Michael DeHaan
5443ddec75 Trim references to fireball as we want folks using accelerate or pipelining options. Fireball is pretty well deprecated at this point, but will still be part of the release. 2014-02-28 13:50:39 -05:00
James Cammarata
79645535c0 Handle empty results from failed connections in _remote_md5()
Fixes #5800
2014-02-28 12:50:03 -06:00
Gilles Cornu
04f6367172 Fully clean 'ssh_old' and 'paramiko_alt' options
These transports have been removed in 33857855ad
2014-02-28 18:28:04 +01:00
Ashok Raja R
cb3c6417dd pause plugin doesn't flush raw_input prompt
##### Issue Type:

Bugfix Pull Request

##### Ansible Version:

ansible 1.4.3

##### Environment:

N/A

##### Summary:

We are using a wrapper python script to run ansible-playbook. We use subprocess to execute and print the stdout as and when its written. Problem is when we use pause it doesn't display the prompt string as raw_input does not flush stdout before reading from stdin.

It looks like a dirty fix to add "\n" to the prompt string but i don't see any other way to over come this. If anyone else have a better fix please do propose/suggest.

##### Steps To Reproduce:

```yaml
#File: test_play.yml
- name: Test
  hosts: $nodes
  gather_facts: false

  tasks:
    - name: Waiting for User
      local_action: pause prompt="Do you want to continue (yes/no)? "
```

```python
#!/usr/bin/env python
#File: test.py
import shlex, subprocess

def run_process(process):
    process = process.encode("utf-8")
    command = shlex.split(process)
    p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    for line in iter(p.stdout.readline, b''):
        print line,

cmd = "/usr/bin/python -u /usr/bin/ansible-playbook -i hosts.txt test_play.yml -e 'nodes=local'"
run_process(cmd)
```

```
shell $ python test.py
```

##### Expected Results:
```
PLAY [Test] *******************************************************************

TASK: [Waiting for User] ******************************************************
[localhost]
Do you want to continue (yes/no)? :
```

##### Actual Results:
```
PLAY [Test] *******************************************************************

TASK: [Waiting for User] ******************************************************
[localhost]
```
2014-02-28 11:28:38 +05:30
James Cammarata
df9de6ea71 Expand the source path in the action plugin when not using a remote source
Fixes #6209
2014-02-27 12:50:35 -06:00
Serge van Ginderachter
9833263417 Fixes templating of ansible_ssh_host for delegates 2014-02-27 18:06:34 +01:00
James Cammarata
c11e2100e0 Save the original transport in runner after detecting the smart transport
Fixes #6192
2014-02-27 10:30:50 -06:00
Michael DeHaan
cd7d7eb1bc Merge pull request #6202 from muffl0n/unarchive_destdir
unarchive: output dest in error-message
2014-02-27 10:36:10 -05:00
muffl0n
17946b23d5 output dest in error-message 2014-02-27 13:29:26 +01:00
Richard C Isaacson
9c8bbe2904 column must always be less than len(probline)
Fixes related to GH-5773.
2014-02-26 16:28:34 -06:00
James Cammarata
14ba10393b Minor tweak to region config in boto configuration file 2014-02-26 15:40:33 -06:00
James Cammarata
88acb48e61 Merge branch 'ec2_boto_config_region' of https://github.com/willthames/ansible into willthames-ec2_boto_config_region 2014-02-26 15:32:05 -06:00
James Cammarata
2a383786dd And remove the expanduser calls from the action_plugin 2014-02-26 15:29:00 -06:00
Richard C Isaacson
585766201d When looking for double colon len(line) is longer then 1.
Addresses GH-5116.

It comes up that when parsing json that if you are missing the last double quote on the last variable and the next line is just '}' we will get an out of range error. In this instance we will also then make sure that the line is long enough to have two colons.
2014-02-26 14:25:56 -06:00
James Cammarata
b758ed9417 Merge pull request #6150 from hkariti/fix_join_bug
Fix incorrect use of .join on list causing a traceback
2014-02-26 12:50:07 -06:00
James Cammarata
96f1c3ce2e Move where the expanduser call is made, to avoid issues with None 2014-02-26 12:33:17 -06:00
James Cammarata
e659d55d62 Merge branch 'devel' of https://github.com/muffl0n/ansible into muffl0n-devel 2014-02-26 12:28:26 -06:00