Commit graph

59 commits

Author SHA1 Message Date
mavimo
cafc12c680 Double quoted version_added in documentation 2013-03-30 20:44:34 +01:00
Stephen Fromm
b694b9a66e Fixes for get_remote_head in git module
See issue #2471

This fixes get_remote_head() to be smarter about how to check remote
head.  It checks if it is a remote branch or tag and then checks for the
remote object id associated with it.  If it is sha1, get_remote_head()
returns it as-is since there doesn't appear to be a way to check a
remote repository for a specific object/sha1.  is_remote_tag() is added
to help out the new functionalit in get_remote_head().

In main(), if check_mode is true and version is a sha1, the module now
checks to see if the object is present.
2013-03-20 14:28:06 -07:00
Stephen Fromm
73772a41e6 Add check mode to git module
Related to issue #2114.  This hooks in check_mode to git module.  This
will exit with changed=True at the following places:

* If the repo has not been cloned
* If the destination has local modifications, this will exit with
  changed=True.  This is because reset() will exit anyways if there are
  local mods and force is False.
* If the remote HEAD commit id is not the same as that of the local HEAD.
  This is determined by get_remote_head() that runs 'git ls-remote' to
  determine remote HEAD.

Lastly, if this is run with check_mode enabled, this will exit with
changed=False before fetch() is invoked so that no local mods are made.
2013-03-14 22:29:04 -07:00
Dag Wieers
50b7964f8e Fix the documentation booleans so they use "yes" and "no"
Both modules seboolean and zfs have not been adapted since they defer from the default (either by having a 'null' or special state, or prefering "on"/"off" for state indication.
2013-03-12 13:25:59 +01:00
Daniel Hokka Zakrisson
93f02d614b Merge pull request #2187 from dhozac/argument-type-check
Add type checking for module arguments, converting as much as possible
2013-02-26 14:05:36 -08:00
Daniel Hokka Zakrisson
578ec127fb Remove choices=BOOLEANS as it is no longer needed 2013-02-23 22:57:36 +01:00
Daniel Hokka Zakrisson
df798d0688 Use argument type checking to convert to boolean 2013-02-23 19:59:52 +01:00
Michael DeHaan
b75b9681a8 more places to use yaml.safe_load 2013-02-23 13:34:14 -05:00
Blair Zajac
fa8e653011 Simplify and correct comparisons with None. 2013-02-16 13:32:48 -05:00
Lorin Hochstein
321175cdfa Add example of read-write git checkout via ssh 2013-02-12 22:08:14 -05:00
Lorin Hochstein
c337b64e35 Git module: fix for relative paths
If a relative path is passed as an argument, this change first
converts it to an absolute path.

This fixes a bug where the git module would attempt to chdir into an
invalid directory because of multiple chdir calls against a relative
path.
2013-01-25 20:49:30 -05:00
Stephen Fromm
4eaee3df0a Various cleanup to run_command
* Rename fail_on_rc_non_zero to check_rc, much more succinct.
* Simplify method defintion
* Fix command module and drop shell=shell option; whether to use
  shell is determined by if args is a list.
2013-01-13 11:24:21 -08:00
Stephen Fromm
3fb21a5281 Update modules to use run_command in module_common.py
This updates apt, apt_repository, command, cron, easy_install, facter,
fireball, git, group, mount, ohai, pip, service, setup, subversion,
supervisorctl, svr4pkg, user, and yum to take advantage of run_command
in module_common.py.
2013-01-13 08:37:19 -08:00
Gert Goet
f4dcb33ccc Prevent permission denied when cloning
Without read permission to the current working directory, git-clone will
fail:
root@host:~$ sudo -u git -H git clone \
  git://github.com/ansible/ansible.git /home/git/ansible
fatal: Could not change back to '/root': Permission denied

This commit ensures that the working directory is changed to the
parent-folder of the destination before doing the clone.
2013-01-13 13:07:22 +01:00
Daniel Hokka Zakrisson
451868630d Merge pull request #1817 from chrisberkhout/devel
git module documentation: removed incorrect use of term 'remote branch' ...
2013-01-04 19:26:52 -08:00
Chris Berkhout
c01bc23f63 git module documentation: removed incorrect use of term 'remote branch' (should just be 'remote'). 2013-01-03 16:00:25 +11:00
Stephen Fromm
1bcfdd94f3 Further refine remote branch tracking in b1ec6e8
Move operations that are dependant on a remote branch under a if
is_remote_branch() conditional.  While at it, remove assignment to cmd
string in same block that wasn't used when calling _run().
2012-12-04 17:02:54 -08:00
Stephen Fromm
b1ec6e8163 Fix git module to update branch to latest when using version=<branch>
The git module would not pull in updates to a branch when
version=<branch>.  This updates that block to checkout the branch
and then do a git reset --hard <remote>/<branch>.  This
should now track updates to a branch.
2012-12-04 11:40:48 -08:00
Jan-Piet Mens
caf003c813 DOCUMENTATION strings 2012-11-21 18:49:30 +01:00
Michael DeHaan
663a8fef3f chmod -x for all module files in source checkout 2012-11-19 13:47:40 -05:00
Stephen Fromm
6aa51a7cf3 Rewrite switch_version() to detect branch
Rewrote switch_version() to read .git/HEAD to find branch associated
with HEAD.  If in a detached HEAD state, will read
.git/refs/remotes/<remote>/HEAD.
2012-11-07 16:33:22 -08:00
Stephen Fromm
49d41da152 Use supplied remote name when cloning git repository 2012-11-07 12:15:22 -08:00
Stephen Fromm
328951ef53 Checkout branch before rebase in switch_version 2012-11-07 11:44:48 -08:00
Stephen Fromm
ccc04cf891 More work in git module
Rename pull() to fetch().  It does a git fetch and then a
git fetch --tags.
Add _run() method to handle all subprocess.Popen calls.  Change
all previous calls to subprocess.Popen to use _run().
2012-11-07 11:44:48 -08:00
Jan-Piet Mens
feab57e270 Reformat code: examples consistently
- added terse syntax to modules.rst
 - added description of special variables to template module
2012-10-23 15:14:01 +02:00
Stephen Fromm
769bd9125a Help git module work when working in 'no branch' scenario
Detect when on a 'no branch' branch.  If so, checkout the HEAD branch
as reported by 'git remote show <remote>'.  That should put the repo
back on a branch such that git can then merge changes as necessary.
In addition, removed hard-coded references to origin and replaced
with remote var.
2012-10-22 16:03:35 -07:00
Ashley Penney
f4484f800b Further cleanup to add another rc check and remove a now redundent one. 2012-10-12 18:26:40 +00:00
Ashley Penney
6042419624 Check rc instead of parsing for errors. This now catches the case where the remote branch has been deleted and you're still trying to pull against it. 2012-10-12 18:16:37 +00:00
Stephen Fromm
be19e21126 Add module documentation for git, group, service, and user 2012-09-29 23:50:25 -07:00
Daniel Hokka Zakrisson
f6af88fe9f User-expand the destination path of the git module 2012-09-21 19:20:05 +02:00
Michael DeHaan
f9e9753141 Remove obsolete comment 2012-08-28 07:29:32 -04:00
Ingo Gottwald
30fdd56560 Added cwd to tempdir in git clone method. Fixes usage with sudo. 2012-08-28 11:28:50 +02:00
Dane Summers
71cff25254 added force option to git - made both subversion and git default to force=true for backward compatibility with git's previous behavior 2012-08-23 00:07:14 -04:00
Stephen Fromm
6265be3aee Fix error handling when switching versions
git module used to check stderr for the string 'error' after calling
switch_version().  This changes that to just look at the return code to
determine whether the command failed.  If the rc is not zero, the git
module will call fail_json().

The problem is that git checkout will summarize the commit message,
such as:

    HEAD is now at ea38409... removing artificial error

When the string 'error' is the commit message, this check will
erroneously think the command failed.

This also removes the method switchLocalBranch() since it is no longer
used.
2012-08-07 11:20:14 -07:00
Michael DeHaan
faed4b5a33 whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added
in 0.6 release)
2012-08-06 20:07:02 -04:00
Michael DeHaan
7e9e29011e Add encoding lines to python modules such that they can take unicode options if they are fed them, since the
AnsibleModule stuff no longer base64 encodes for simplicity and speed reasons.
2012-08-02 21:29:10 -04:00
Michael DeHaan
0a3ebdb6d5 Module consistency and make daisy chaining work with invalid arguments detection. 2012-08-01 00:22:02 -04:00
Michael DeHaan
d79900b434 Merge pull request #732 from willthames/fix_git_fail_json
Fixes for git module when it fails.
2012-07-31 05:04:47 -07:00
u348095
e863ba0cec Fixes for git module when it fails.
* module.fail_json *must* have msg argument
Using http://github.com/ rather than git://github.com/ as it gets through more
firewalls
2012-07-31 12:59:22 +10:00
Michael DeHaan
ce5f3dd148 Port the file module over to the new common code infrastructure + cleanup some redundant imports since the module code already imports those things. 2012-07-30 21:50:32 -04:00
Stephen Fromm
87b3e1ecdc Update git module to use module magic and other changes
Convert git module to module magic.
Drop cruft no longer needed.
Standardize indent to 4 spaces in methods switchLocalBranch, reset,
clone, and get_version.
Update is_local_branch to also handle '* branch' format.
Add is_current branch method()
Update pull() method to use is_current_branch()
2012-07-29 22:39:19 -07:00
Lorin Hochstein
9253d89280 git module: Don't pass rc as separate arg to fail_json 2012-07-27 08:40:47 -04:00
Stephen Fromm
1727bd3b7a Update git module to handle branches better
This drops the branch option.  The version option is overloaded
to mean either a sha1, branch, or tag.  This also adds the option
'remote' which defaults to 'origin'.
clone() was simplified by removing the checkout operation.  That
happens later when switch_version() is called.

Added the methods get_branches(), is_remote_branch(), and
is_local_branch().  get_branches() returns an array listing all
of the branches for the git repository.  is_remote_branch() checks
whether the arguments supplied correspond to a remote branch.
Similarly, is_local_branch() checks for a local branch.

The pull() method now checks to see if it is on the desired branch.
If not, it checks out the requested branch and then does a pull.
This should keep issue #604 still fixed.

switch_version(), formerly switchver(), looks to see if it is
checking out a branch.  If a branch, it checks it out with the --track
option.  This type of checkout was in pull() before.

Updated pull, clone, and switch_version to return (rc, out, err).
2012-07-26 00:22:30 -07:00
Stephen Fromm
fd059a3df2 Fix for issue 604
Do not switch to master branch in pull()
Add --track to git checkout, when checking out a remote branch to track.
2012-07-20 10:43:26 -07:00
Michael DeHaan
70ef8e9ebb Merge pull request #637 from goozbach/git-mkdir
git mkdir causes problems with older git (can't c/o to existing directory)
2012-07-20 06:54:20 -07:00
Derek Carter
f0f8eb3445 git mkdir causes problems with older git (can't checkout to existing directory) 2012-07-20 09:48:18 -04:00
Peter Sankauskas
5e35cd6466 Pass through error message when repo not found 2012-07-19 15:48:13 -07:00
Michael DeHaan
45100f03b1 Default git module to master branch so branch= is not required. 2012-05-10 00:41:44 -04:00
Michael DeHaan
e6416def6b update comment about branch support, now that supported 2012-05-10 00:39:15 -04:00
Michael DeHaan
d118cf3e31 Merge pull request #336 from sfromm/issue122
Issue122 - have all modules log to syslog
2012-05-09 17:19:24 -07:00