Commit Graph

51 Commits (ad1d038041001a59454ff8a287080495cb3cf970)

Author SHA1 Message Date
Blair Zajac 6d5991aa4c Simplify and correct comparisons with None. 12 years ago
Lorin Hochstein 2408d10075 Add example of read-write git checkout via ssh 12 years ago
Lorin Hochstein 165df51f6a 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.
12 years ago
Stephen Fromm 3f88a14b86 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.
12 years ago
Stephen Fromm e4964f42e0 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.
12 years ago
Gert Goet 2db7cc3314 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.
12 years ago
Daniel Hokka Zakrisson 453d42aed0 Merge pull request #1817 from chrisberkhout/devel
git module documentation: removed incorrect use of term 'remote branch' ...
12 years ago
Chris Berkhout bb482bd112 git module documentation: removed incorrect use of term 'remote branch' (should just be 'remote'). 12 years ago
Stephen Fromm 84264009b5 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().
12 years ago
Stephen Fromm feb5705017 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.
12 years ago
Jan-Piet Mens d184f72aa9 DOCUMENTATION strings 12 years ago
Michael DeHaan 6f6559670f chmod -x for all module files in source checkout 12 years ago
Stephen Fromm 88e4be48a3 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.
12 years ago
Stephen Fromm 0480443759 Use supplied remote name when cloning git repository 12 years ago
Stephen Fromm 3ec51ce587 Checkout branch before rebase in switch_version 12 years ago
Stephen Fromm d6f7ffd4bc 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().
12 years ago
Jan-Piet Mens d069c57974 Reformat code: examples consistently
- added terse syntax to modules.rst
 - added description of special variables to template module
12 years ago
Stephen Fromm 728b08ac71 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.
12 years ago
Ashley Penney 3075ddb634 Further cleanup to add another rc check and remove a now redundent one. 12 years ago
Ashley Penney d8e3f4db42 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. 12 years ago
Stephen Fromm f5d39b8677 Add module documentation for git, group, service, and user 12 years ago
Daniel Hokka Zakrisson 75583deb5b User-expand the destination path of the git module 12 years ago
Michael DeHaan 2d1696f7f7 Remove obsolete comment 12 years ago
Ingo Gottwald 80e53a82d4 Added cwd to tempdir in git clone method. Fixes usage with sudo. 12 years ago
Dane Summers 7cb6fa0286 added force option to git - made both subversion and git default to force=true for backward compatibility with git's previous behavior 12 years ago
Stephen Fromm 38957b2cf0 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.
12 years ago
Michael DeHaan 5ed21bf443 whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added
in 0.6 release)
12 years ago
Michael DeHaan baacde6c74 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.
12 years ago
Michael DeHaan fe9a05f492 Module consistency and make daisy chaining work with invalid arguments detection. 12 years ago
Michael DeHaan dcff6ec4d6 Merge pull request #732 from willthames/fix_git_fail_json
Fixes for git module when it fails.
12 years ago
u348095 f0931b5960 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
12 years ago
Michael DeHaan 4782bc1949 Port the file module over to the new common code infrastructure + cleanup some redundant imports since the module code already imports those things. 12 years ago
Stephen Fromm f2c0fd3941 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()
13 years ago
Lorin Hochstein b56927874a git module: Don't pass rc as separate arg to fail_json 13 years ago
Stephen Fromm 1165866ecb 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).
13 years ago
Stephen Fromm 566f115a4f 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.
13 years ago
Michael DeHaan fc6ee63fba Merge pull request #637 from goozbach/git-mkdir
git mkdir causes problems with older git (can't c/o to existing directory)
13 years ago
Derek Carter 69ef933a1e git mkdir causes problems with older git (can't checkout to existing directory) 13 years ago
Peter Sankauskas cb6acfc1dc Pass through error message when repo not found 13 years ago
Michael DeHaan 2c3b20fc09 Default git module to master branch so branch= is not required. 13 years ago
Michael DeHaan 5f40c49008 update comment about branch support, now that supported 13 years ago
Michael DeHaan 6ec0bc8bfd Merge pull request #336 from sfromm/issue122
Issue122 - have all modules log to syslog
13 years ago
Stephen Fromm 67ee30f135 Apply logging of arguments to modules (issue #122)
The ohai and facter modules use /usr/bin/logger to log the fact that
they have been invoked.  I added 'import os' to the ping module
so that it could have the same syslog statements as the other modules.
I separated the condensed:
    shlex.split(open(argfile, 'r').read())
into two separate statements similar to the other modules.
13 years ago
felix c2135b722d removed unecessary branch addition from switchver 13 years ago
felix 0c2da0e080 added in support for branches in git module (now takes optional "branch") 13 years ago
Stephen Fromm 740ca70d1e Add git reset --hard support to git module
Resets working tree to what is in HEAD and discards any
uncommitted changes.
13 years ago
Stephen Fromm 720ef7404e Add exit_json and fail_json to git module
This adds exit_json() and fail_json() to git module.  It also sets
version to 'HEAD', if not provided.
13 years ago
Seth Vidal 903178cdd4 convert so they handle argsfiles rather than arguments 13 years ago
Michael DeHaan 1bd1552b43 Relicensing to GPLv3, all previous committers ok'd on mailing list. 13 years ago
Michael DeHaan 8f9320aa05 Rename 'ensure' to 'state' because I think it's a bit cleaner and doesn't imply
all modules take a common parameter name.  But more or less we still work idempotently
in modules.
13 years ago