Commit Graph

291 Commits (547c0d81408864e267184536fbdf04f281576f26)

Author SHA1 Message Date
James Tanner 2492c2714a Fixes #5307 set relative paths to the files dir for roles and the inventory dir for non-role tasks 2014-03-31 12:25:40 -04:00
Matt Martz 7e3dd1066c Allow raw and script to support su 2014-03-28 16:46:31 -05:00
Michael DeHaan a062912a1f Merge pull request #6658 from pilou-/fix_fix
'changed' key is not defined when task fails
2014-03-25 11:49:18 -04:00
James Cammarata dc658eaa1c Check to make sure the host is in the inventory vars cache before clearing it
Fixes #6660
2014-03-24 15:59:43 -05:00
Pierre-Louis Bonicoli c76501b8a3 'changed' key is not defined when task fails
fix KeyError introduced by fix of #6591.
2014-03-24 19:31:52 +01:00
Michael DeHaan d0cbb51170 Merge pull request #6615 from 8191/devel
Addresses #6591 Hide diff for lineinfile if file did not change.
2014-03-21 10:46:29 -04:00
Manuel Faux b8158f5f6a Addresses #6591 Hide diff for lineinfile if file did not change. 2014-03-21 08:40:38 +01:00
James Tanner ea5186ca63 Fixes #6590 add set_remote_user parameter to synchronize
This allows usage of custom ssh configs for remote hosts where
the inventory user does not match the configured user.
2014-03-20 13:56:07 -04:00
Michael DeHaan 94e3350b38 Catch a unquoted line error. Fixes #6532 2014-03-17 17:15:42 -04:00
James Tanner ebb6b8442b Catch unicode unescape failures in copy action plugin 2014-03-17 12:14:29 -04:00
Michael DeHaan 3d44f7cd51 Merge pull request #6217 from ashokrajar/patch-1
pause plugin doesn't flush raw_input prompt
2014-03-16 12:32:58 -05:00
Cristian Ciupitu 0749112286 Micro-optimization: replace s.find(x)!=-1 with x in s
timeit shows a speedup of ~3x on Python 2.7.5 x86_64.
It also makes the code a bit shorter.
2014-03-16 13:10:28 -04:00
James Cammarata 9f2999df79 Un-escape newlines in delimiters for assemble module 2014-03-06 09:44:56 -06:00
James Tanner 4e8ed92130 Fixes #6077 decode escaped newline characters in content for the copy module 2014-03-05 18:49:54 -05:00
James Tanner 6129ea7566 Fixes #6298 and adds a sudo unit test for synchronize 2014-03-05 14:51:40 -05:00
Tefnet c652802d29 missing import in assert module
Fixed missing ansible.errors import in assert module
2014-03-02 00:59:17 +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
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
James Cammarata 2a383786dd And remove the expanduser calls from the action_plugin 2014-02-26 15:29:00 -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
James Tanner 9209581565 Fixes #6155 Inject checkmode into synchronize module args 2014-02-25 08:58:58 -05:00
James Cammarata 3b2d409906 Fixing several bugs in assemble and updating tests
Bugfixes:
* the remote_src param was not being converted to a boolean correctly,
  resulting in it never being used by the module as the default behavior
  was remote_src=True (issue #5581)
* the remote_src param was not listed in the generic file params, leading
  to a failure when the above bug regarding remote_src was fixed
* the delimiter should always end with a newline to ensure that the file
  fragments do not run together on one line

Fixes #5581
2014-02-24 14:27:23 -06:00
jctanner 93c746db9c Merge pull request #5651 from nikut/sshfix
allow ansible_ssh_private_key_file to be templated (thanks to benno)
2014-02-24 14:26:48 -05:00
Richard C Isaacson 8be8dbc9ed Formatting cleanup. 2014-02-24 11:11:47 -06:00
Richard C Isaacson aaf0a182e1 Merge remote-tracking branch 'jeromew/ansible_script_creates' into issues_4986 2014-02-24 10:16:39 -06:00
James Cammarata ef2df8157a Fixup result dictionary when copy module calls file module 2014-02-19 18:05:59 -05:00
muffl0n b0f00cc097 already call expanduser in action_plugin 2014-02-19 21:41:57 +01:00
muffl0n 5f0e882d01 call expanduser for src and dest 2014-02-19 21:30:53 +01:00
root 0df166e7c0 Copy tests WIP, fix bug in assert module upgrades where the wrong value was being checked. 2014-02-19 14:36:54 -05:00
James Cammarata 54117ab28f Modified assert module to take tests as an array 2014-02-19 14:05:03 -05:00
Richard Isaacson dc403eb21e Merge pull request #6058 from jctanner/vault_squashed_2
Ansible vault: a framework for encrypting any playbook or var file.
2014-02-19 11:39:55 -05:00
James Tanner 3fc87e011b Fix all other calls to yaml 2014-02-19 11:01:21 -05:00
Richard C Isaacson 1ac19cb981 Copy action_plugin: encode content when dict.
When content is processed and found to be valid JSON it is decoded into a dict. To write it out to a file we need to encode it back into a string.

Addresses GH-5914.
2014-02-18 13:23:44 -06:00
jeromew 7a14cb61c4 Add creates= and removes= to the script: action 2014-02-18 12:52:09 +00:00
Niku Toivola 6cc9b16f06 allow templating of ansible_ssh_private_key_file also in the synchronize module 2014-02-18 11:32:33 +02:00
James Cammarata 788ac51185 Sanitize sudo success_key from stdout for raw/script modules
Fixes #5533
Closes #5605
Closes #5606
Closes #5607
2014-02-17 12:47:47 -06:00
Michael DeHaan c91ceddfac Add the start of an integration test structure using Ansible playbooks, also added an assert action plugin to make writing those easier. 2014-02-13 18:28:29 -05:00
Richard Isaacson eb4a730933 Merge pull request #5969 from risaacson/pull_5136
Updates for the unarchive module and action_plugin.
2014-02-12 10:10:25 -06:00
Richard C Isaacson 598b9c6b7c Cleanup per notes.
Some small changes to per notes from @mpdehann.
2014-02-12 10:01:10 -06:00
Richard C Isaacson cb7c2b7524 Updates for the unarchive module and action_plugin.
There is a bit going on with the changes here. Most of the changes are cleanup of files so that they line up with the standard files.

PR #5136 was merged into the current devel and brought up to working order. A few bug fixes had to be done to get the code to test correctly. Thanks out to @pib!

Issue #5431 was not able to be confirmed as it behaved as expected with a sudo user.

Tests were added via a playbook with archive files to verify functionality.

All tests fire clean including custom playbooks across multiple linux and solaris systems.
2014-02-12 01:57:00 -06:00
Richard C Isaacson e6c9705058 Merge remote-tracking branch 'pib/unarchive_remote' into pull_5136 2014-02-11 22:55:34 -06:00
James Tanner 9ce46e5f41 Refactor the synchronize action plugin and add unit tests 2014-02-10 23:39:17 -05:00
Richard C Isaacson 786e3d2fd2 Refining the fix made in #5885.
It turns out that some of the assumptions in #5885 were slightly off. The previous fix relied on a call to the module to creat a tmp_path. This is insufficent as there are few cases that we need to have the tmp directory before we make the module call. If we don't have a tmp_path before we do a recursive call or when we find a file that does not match the remote md5 hash we need to create a tmp directory. Also we are not more percise when we will need to clean up the remote tmp_path.
2014-02-08 02:25:42 -06:00
Richard C Isaacson a3261500dd Addresses #5739 and cleans up copy.py
The copy action_plugin is not easy to read. Part of this commit is taking that file, restructuring it, and adding comments. No functionality changed in how it interacts with the world.

The fix for #5739 ends up being the assumption that there is a cleanup 'rm -rf' that happens at the end of the copy loop. This was not the fact before and we made a bunch of tmp directories that we hoped would end up being cleaned up. Now we just use the tmp directory that the runner provides and cleanup inline if it is a single file to be coppied or after the loop if it is a recursive copy.

As a part of this we did end up having to change runner to provide a flag so that we could short the inline tmp directory removal. This flag defaults to True so it will not change the behavior of other modules that are being called.
2014-02-04 12:44:10 -06:00
James Cammarata 2d0e9cd75d Revert "Fix for issue 5739. The copy module does not delete directories it will only unlinks symlinks."
This reverts commit b20dc4f578.
2014-02-03 12:54:52 -06:00
James Cammarata 9ff99acaff Merge branch 'issue5739_3' of https://github.com/risaacson/ansible into risaacson-issue5739_3 2014-02-03 09:52:50 -06:00
Richard C Isaacson b20dc4f578 Fix for issue 5739. The copy module does not delete directories it will only unlinks symlinks. 2014-01-31 17:19:44 -06:00
James Cammarata 75e3b59bbd Adding no_log: capability for tasks
Fixes #4088
2014-01-31 16:58:46 -06:00
jctanner 6c25ea1b91 Merge pull request #5527 from sergevanginderachter/basedirdwim
path_dwim: fix when basedir not set
2014-01-30 10:54:19 -08:00
Michael DeHaan d07a3b5e9b AnsibleWorks -> Ansible 2014-01-28 20:29:42 -05:00
Michael Scherer 5c5c8fd7ce Make synchronize module work better with local transport, fix #5668 2014-01-17 17:32:36 +01:00
jeromew 69febcefde remove useless create/delete remote tmp dir roundtrip in copy module 2014-01-08 15:22:12 +00:00
Serge van Ginderachter 836fb4143c path_dwim: fix when basedir not set 2014-01-08 02:21:10 +01:00
smoothify 93a55e8dff Don't override sudo if transport is set to local.
https://github.com/ansible/ansible/pull/5251
2014-01-04 23:32:25 +00:00
Michael DeHaan 10350d1639 Update various copyrights. Not complete, but sufficient. 2014-01-04 13:32:04 -05:00
James Tanner cb2214d6f8 Fixes #4935 Synchronize module: set destination to an fqdn if connection is not local, and abide by ansible_remote_user 2014-01-02 14:58:12 -05:00
jctanner 99560e3902 Merge pull request #5047 from sergevanginderachter/synch_template_ansiblesshhost
synchronize: allow ansible_ssh_host to be templated
2014-01-02 09:05:14 -08:00
Stephen Fromm 833e1f6e2a Make sure action plugin copy cleans up tmp dir
The copy action plugin creates its own tmp dir for each file that it
copies to the target machine.  However, it does not clean up the
original tmp path it was given when run() is called.  This cleans up the
tmp path before it begins looping on source files.
2013-12-20 14:58:34 -08:00
jeromew 5c965a75f0 ssh_alt.py / decrease # of ssh roundtrips 2013-12-13 14:23:40 -05:00
Michael DeHaan 929f8a5c93 Had to revert commits due to async. 2013-12-10 19:24:08 -05:00
Michael DeHaan 74e4ccb59b Revert "ssh_alt.py / decrease # of ssh roundtrips"
This reverts commit 7f8863f96d.
2013-12-10 19:23:52 -05:00
jeromew 7f8863f96d ssh_alt.py / decrease # of ssh roundtrips 2013-12-10 06:00:21 -05:00
jctanner 7aa35d64c2 Merge pull request #5091 from EspadaV8/5089_assemble_fix
#5089 hack-fix assemble module
2013-12-04 10:13:16 -08:00
Paul Bonser 58acd8cce1 If there is no tmp_src, don't modify the args 2013-12-03 18:59:50 -06:00
Paul Bonser 4afcd50487 properly convert arg into boolean 2013-12-03 18:46:37 -06:00
James Tanner d227614529 Fixes #5109 synchronize module ssh port
Added a parameter for dest_port and also check ansible_ssh_port inventory variable.
2013-12-03 14:48:20 -05:00
Paul Bonser 5626efba7e Optionally unarchive a file already on the remote machine 2013-12-02 19:51:10 -06:00
Andrew Smith eed32ea70c dest_contents isn’t always defined, so don’t pass it around
I think this is also a bit of a hack since it should probably be set
before being used, I’m just not sure what it should be set to.
2013-11-28 10:59:51 +10:00
Andrew Smith e2d03173d2 The file module doesn’t have it’s module_args reset
I believe that this should be reset in the same way that the copy module
does
2013-11-28 10:58:14 +10:00
Andrew Smith 7b01c83159 Passing in complex_args throws ‘unsupported parameter for module’ errors
When using assemble only params (e.g. remote_src) the copy (and I’m
guessing file) modules throw an error that the param isn’t supported.
Simply removing the complex_args param fixes it for me, but I’m not sure
that’s the correct thing to do
2013-11-28 10:55:35 +10:00
Andrew Smith da44a7f0cb I think that resultant is meant to be the contents of the combined file
It is used for the transfer and as a diff param but isn’t actually
defined anywhere before it’s used. This seemed like the least bad place
to set it.
2013-11-28 10:53:00 +10:00
Andrew Smith 4503413baa ReturnData is used throughout but not actually imported 2013-11-28 10:51:04 +10:00
Andrew Smith 7d007cac16 Correct the invocation of ‘_assemble_from_fragments’ 2013-11-28 09:44:14 +10:00
James Tanner 12ed39ef7b Fixes #5056 Append new hosts to the groups cache 2013-11-27 13:04:31 -05:00
Brian Coca 65885feeeb fixed typo for assemble function 2013-11-26 08:30:28 -05:00
Serge van Ginderachter 2f9470ec1d synchronize: allow ansible_ssh_host to be templated
This is already enabled in the runner also.
2013-11-25 15:33:04 +01:00
Aleksey Ovcharenko 30678e04ac Make tests happy 2013-11-22 04:06:10 +02:00
Aleksey Ovcharenko 2222f6df58 Allow to specify ansible_ssh_private_key_file location related to user home directory 2013-11-22 01:47:03 +02:00
James Tanner e81c976636 Fix pep8 errors in unarchive module 2013-11-19 16:35:06 -05:00
Skylar Saveland 7bc64581d7 KeyError: 'delegate_to' no more 2013-11-17 21:26:17 -08:00
jctanner be67a6f815 Merge pull request #4625 from pileofrogs/devel
unarchive module & action plugin
2013-11-14 07:57:57 -08:00
James Tanner 33242cacf3 Merge pull request #4375 from pfalcon/ansible
copy: Implement recursive copying if src is a directory.
2013-11-13 15:52:40 -05:00
jctanner 6dd81f25d9 Merge pull request #4856 from akuznecov/devel
Resolves #4855 issue with synchronize module failing on multiple items
2013-11-12 15:37:26 -08:00
jctanner 2cf335969f Merge pull request #4738 from bcoca/assemble_action_plugin
assemble can now use src from master/origin
2013-11-12 08:23:39 -08:00
Alexander Kuznecov 9d2f9bf93c resolves #4855 2013-11-09 00:14:55 +07:00
Michael DeHaan 70c9028e1e include_vars plugin should look in vars/ path for a role. 2013-11-02 09:34:44 -04:00
Michael DeHaan 51fbc6d20a Further simplify the debug: var=foo action plugin code. 2013-10-31 19:39:32 -04:00
Michael DeHaan bbf212a268 Simplify the way the debug: var=varname plugin works. 2013-10-31 19:35:50 -04:00
Michael DeHaan 7f125567cb Some simplification of include_vars and renamed include_files to include_vars. 2013-10-31 19:24:35 -04:00
Michael DeHaan b69ab89eb1 Merge branch 'include_files' of git://github.com/bennojoy/ansible into devel 2013-10-31 19:14:27 -04:00
Brian Coca ac40d15120 now assemble module is also action plugin and can use local source for
files
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2013-10-30 21:40:42 -04:00
Michael DeHaan 90cce35919 This allows variable references in playbooks in a different way. 2013-10-30 21:26:16 -04:00
James Tanner 0faecdf7d1 Fixes #4653 Set dest on results for copy module even if using file module 2013-10-28 22:50:55 -04:00
bennojoy b53e7353f9 include files 2013-10-28 17:40:09 +05:30
jctanner 43f48a2e02 Merge pull request #4167 from tima/rsync3
synchronization module take 3
2013-10-25 14:43:08 -07:00
Dylan Martin 2c28e1daea unarchive module & action_plugin added 2013-10-21 15:22:42 -05:00
Timothy Appnel cbae9c913e synchronize module src and dest handles template markers. 2013-10-19 22:39:25 -04:00