Commit graph

987 commits

Author SHA1 Message Date
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
Shaun Zinck
b2aed1a4ba pkgin: add stdout to error message when shell commands fail 2013-01-25 16:58:29 -06:00
Shaun Zinck
e9ca960558 pkgin: use module.run_command to run stuff
This also fixes an issue where some console output for packages I was
installing was creating invalid JSON because it contained single-quotes.
2013-01-25 16:48:58 -06:00
Daniel Hokka Zakrisson
6e0cb14ba5 Merge pull request #1911 from tgerla/devel
Port ec2 module to Boto
2013-01-25 08:18:48 -08:00
Juha Litola
2796603c92 Removed apt_key tests, as they didn't test the real functionality.
Tests used heavily mocked version of the apt_key code, which meant that
it didn't properly test real life scenario.
2013-01-25 17:10:04 +02:00
Daniel Hokka Zakrisson
9f6f15f770 Fix unparseable documentation strings
Fixes #1902.
2013-01-25 14:25:12 +01:00
Juha Litola
05f5b5b279 Fixed add_key stalling indefinitely, and test code leaking into production setting 2013-01-25 13:32:30 +02:00
Shaun Zinck
e34eaa423d pkgin: change install/remove to not use return code of pkgin
pkgin always returns 0 so can't be used to tell if the install or remove
worked.  Instead this just queries the installed packages after
performing an operation.
2013-01-24 19:58:31 -06:00
Silviu Dicu
2a893ab0bb ec2 facts module - updated as per comments 2013-01-24 19:14:32 -05:00
Stephen Fromm
e0741e7810 Update apt_repository to query if repo is already configured
This adds two dependencies to the apt_repository module:  apt and
apt_pkg.  These come from the package python-apt.  This is used to parse
the host's sources.list and examine whether the repo is already
configured.  This then eliminates the unnecessary
'add-apt-repository --remove' from running.
2013-01-23 22:17:43 -08:00
Shaun Zinck
4a9201ad65 add pkgin to list of package managers in setup 2013-01-23 22:12:13 -06:00
Shaun Zinck
2eedec777f added first version of pkgin, just does install, remove (for SmartOS) 2013-01-23 22:10:11 -06:00
Brendan Taylor
f18446e7a5 service module 'state' parameter comments should be processed by RST 2013-01-23 16:32:39 -07:00
John Gosset
54ef6015f6 add pacman to list of package managers in setup module 2013-01-23 11:03:05 -05:00
Silviu Dicu
ce9e9af6a3 ec2 facts moduled - updated 2013-01-23 09:39:26 -05:00
Tim Gerla
cafb717b55 Fail gracefully if boto is not available and add me to the author line. 2013-01-22 14:29:28 -08:00
Tim Gerla
139aee58e2 use connect_ec2_endpoint instead of connect_euca, and properly pass keys to connect_ec2 2013-01-22 14:10:21 -08:00
Silviu Dicu
1ab9bfa7cc ec2 module - registers to ansible_facts key 2013-01-22 15:31:51 -05:00
Tim Gerla
456e6f5a55 library/ec2:
- use boto instead of euca2ools
- improve error handling/propagation for run failures
- rename keypair to key_name (and preserve alias for old playbooks)
- should be 100% backward compatible with the euca2ools version
2013-01-22 12:09:31 -08:00
Daniel Hokka Zakrisson
d4c0180494 Make service module daemonize for all the broken "daemons" out there 2013-01-22 20:21:08 +01:00
Daniel Hokka Zakrisson
48f48e8a44 module must be passed to repolist too 2013-01-22 16:27:08 +01:00
Pepe Barbe
8b4bd2ec3e module needs to be passed to local_nvra 2013-01-22 09:03:45 -06:00
Michael DeHaan
e7223760c4 Merge pull request #1810 from davixx/sysctl
new module: sysctl to handle sysctl entry
2013-01-18 15:20:45 -08:00
Michael DeHaan
c66d3200f8 Merge pull request #1670 from Afterburn/devel
Pacman module
2013-01-18 15:19:47 -08:00
Michael DeHaan
1721357a49 Merge pull request #1824 from jvantuyl/apt-key-module
add apt_key module
2013-01-18 15:16:32 -08:00
Michael DeHaan
fa953ba6b3 Merge pull request #1867 from c0rner/devel
get_service_status() is now using self.service_control() to check status
2013-01-18 15:15:07 -08:00
Rune Kaagaard
27ab2e55d3 Service mod.: Proper(?) handling of return code 69
This adds "69" to the return codes from the status command that should be
considered as not running. At least "django-celery" uses this return code,
maybe others::

    /venv/bin/python /code/project/manage.py celeryctl status
    echo $? # 69 when not running.

A bit of googling let me to http://tldp.org/LDP/abs/html/exitcodes.html and
on a Ubuntu Server 12.10 I get::

    ~# cat /usr/include/sysexits.h | grep 69
    #define EX_UNAVAILABLE	69	/* service unavailable */

I'm not sure if the content of sysexits.h is the same on other OS'es.
2013-01-17 10:13:05 +01:00
Jayson Vantuyl
ad6373430b add apt_key module
Pretty straightforward.  Give it a URL with an exported GPG key for signing an
Apt repository.  It downloads it and will install it using apt-key.  It's even
smart enough to tell if it's already there (i.e. actually tells you if it
changed or not).
2013-01-15 17:34:38 -08:00
root
471ee0c90d get_service_status() is now using self.service_control() to check status
Fixes a bug where init-scripts were not used
2013-01-14 12:37:55 +01: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
Daniel Hokka Zakrisson
a19a13ffa7 Add check for multiple keys in one invocation 2013-01-13 15:16:13 +01: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
Michael DeHaan
1cbc9569b3 Merge pull request #1853 from jure/more_info_from_ec2
EC2 module should report back the public_dns_name too
2013-01-10 16:07:55 -08:00
Daniel Hokka Zakrisson
060266e291 Python 2.4 fixes for modules 2013-01-10 19:24:23 +01:00
Daniel Hokka Zakrisson
3bc6228b97 Handle unreadable /proc/xen/capabilities
Fixes #1854.
2013-01-10 18:22:01 +01:00
Jure Triglav
3f43ede70c Fix indentation 2013-01-10 16:21:18 +01:00
Jure Triglav
2ee05f0c96 EC2 module should report back the public_dns_name too. 2013-01-10 16:14:47 +01:00
Daniel Hokka Zakrisson
b57b1f4cbe Correct name is login_user
Fixes #1848.
2013-01-09 23:57:36 +01:00
Daniel Hokka Zakrisson
4955587d8c Merge pull request #1798 from dagwieers/raw-executable
Allow to change executable (shell/interpreter) when using raw
2013-01-08 08:35:08 -08:00
Michael DeHaan
713ce4c0cf Merge pull request #1832 from legrostdg/devel
add encoding documentation in postgresql_db
2013-01-07 05:03:39 -08:00
Félix Sipma
0ba7cf58e9 add encoding documentation in postgresql_db 2013-01-07 12:58:18 +01:00
willthames
4e50478a05 Fix behaviour when file handles a path with tilde
Two problems here
* unchecked exception handling and erroneous assumption as to why
  an exception might fire
* although the file module expands the path, when using file_args
  the unexpanded path is passed.

Expected result: ~/path/to/file should work fine
Actual result: exception is because it doesn't find file with a message
about not being able to get the selinux context
2013-01-07 16:30:29 +10:00
Daniel Hokka Zakrisson
1fa83fa584 Merge pull request #1813 from legrostdg/devel
postgresql_db fails with owner containing a "-"
2013-01-06 07:34:29 -08:00
Félix Sipma
02f531c609 remove quotes in has_table_privilege and has_database_privilege 2013-01-05 19:31:31 +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
davixx
8efa62b0ea new module: sysctl to handle sysctl entry
sysctl now capable to search for sys entry into /sys if not under /proc/sys

module/sysctl rolling back to 0.5

write sysctl.conf safely, tempfile first, atomic replace after.
See comments in  https://github.com/ansible/ansible/pull/1810

Patch to replace .format with % () to handle python-2.4 ,
See also https://github.com/ansible/ansible/pull/1810

using name instead key for default arg name. key putted as alias.
also, val become an alias of value arg name.
See also : https://github.com/ansible/ansible/pull/1810
2013-01-04 21:55:48 +01:00
Félix Sipma
8a262c2b20 add documentation for "template" parameter in postgresql_db 2013-01-04 15:16:05 +01:00
Félix Sipma
cd7fe9875c use double-quotes in postgresql commands (fix bug with "-") 2013-01-04 12:48:29 +01:00
willthames
411b2bf7d9 Added additional template variables
Added two additional template variables
* template_fullpath - absolute path to the template
* template_run_date - date that the template was rendered
Documented these additional variables in the module documentation
2013-01-04 16:36:02 +10: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
Dag Wieers
eb36ff45b9 Make script module use raw module so it does not require python 2012-12-24 00:24:34 +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
Michael DeHaan
3d3deb9797 Merge pull request #1795 from dagwieers/raw-enhanced
Add return code and error output to raw module
2012-12-23 09:34:57 -08: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
Jan-Piet Mens
85e0017a85 fix cron DOCUMENTATION 2012-12-23 14:08:26 +01:00
jkleint
d732b25828 Clarify that lineinfile uses Python regexes. 2012-12-20 11:41:45 -05:00
Daniel Hokka Zakrisson
eb57c9c430 Indicate the reboot option was added in 1.0
Fixes #1787.
2012-12-19 18:45:33 +01:00
Michael DeHaan
6fc6c37401 Merge pull request #1785 from TutoringAustralasia/devel
Add support for @reboot to cron module
2012-12-19 04:46:27 -08:00
Chelsea Robb
96e2805b31 Change check for date/time parts being set 2012-12-19 15:12:04 +11:00
Chelsea Robb
6a02e3d918 Added error message when reboot and extra params are passed, and added better boolean parsing on reboot 2012-12-19 13:11:58 +11:00
Chelsea Robb
fc4ac70342 Add support for @reboot to cron module 2012-12-19 09:32:51 +11:00
Gregory Duchatelet
29f985aa2e do not conditionalize this for older Python, fix indentation, better use
of hash iteration.
2012-12-17 21:07:36 +01:00
Gregory Duchatelet
e64de2ff88 Bugfix: in hosts with python-2.5, hash keys needs flatten string. 2012-12-17 13:46:50 +01:00
afterburn
a6f01dcd6f version 1.0 eruption 2012-12-16 23:21:35 +01:00
afterburn
0bdd17ff3a updated description and examples 2012-12-16 23:18:42 +01:00
Daniel Hokka Zakrisson
d4b1874d44 Merge pull request #1773 from jpmens/scriptdoc
fix and clarify 'script' docs
2012-12-15 09:28:50 -08:00
Jan-Piet Mens
4f8abd981a fix and clarify 'script' docs 2012-12-14 10:59:48 +01:00
Stephen Fromm
ccca5fcd1c Ensure files created by authorized_key have correct selinux context
Three changes:
* Add set_default_selinux_context() to module_common that sets
  a file's context according to the defaults in the policy
* In atomic_replace(), set the default context for the file if
  selinux is enabled and the destination file does not exist.
* In authorized_key, set the default context when creating
  $HOME/.ssh and $HOME/.ssh/authorized_keys.  If these already
  exist, this won't touch them.
2012-12-13 16:35:49 -08:00
Michael DeHaan
f2893b6418 Merge pull request #1746 from njharman/subversion
Subverion module improvements
2012-12-13 04:34:19 -08:00
Michael DeHaan
5d31e8d1fc Merge pull request #1752 from jpmens/mail2
mail module: add MIME attachments, port and addresses with phrases
2012-12-13 04:31:01 -08:00
Norman J. Harman Jr
ddc0507f65 Passing in module instead of just fail_json per upstream request. 2012-12-12 16:55:30 -06:00
Michael DeHaan
ea5d79a712 Merge pull request #1755 from lorin/patch-1
Fix ppa syntax in apt_repository module doc
2012-12-12 14:47:10 -08:00
Norman J. Harman Jr
19b84d0527 pip module improvements
- Do not silently ignore malformed pip requirements files.
- Properly reports changed when removing packages.
- "latest" i.e. --upgrade is *not* incompatible with requirements files.
- Less branchy, simpler logic.
- Removed pointless variable "initializations", Python doesn't need that.
  Other code simplifications.
- Fun fact; pip install is (kind of) case insensitive, pip freeze is not.
  So, 'sqlalchemy' will be reported as installed by install, but missing
  by freeze.

The perhaps controversial change and the one that led to finding /
fixing above issues...

Instead of adding command parameters 'index', and 'find', and 'mirrors',
and etc.  Added 'extra_args' which are passed onto pip.

The use case for --index-url is having a private pypi repo, like
http://pypi.python.org/pypi/localshop, to which you publish private
packages.  I'm sure most every pip option has a use case for someone.
extra_args handles all those. Can reserve ansible command parameters for
the most common.

Tested with pip 1.1.
2012-12-12 15:40:25 -06:00
Seth Vidal
165861dd2f if user has manually installed an intermediate version - don't ignore it: issue 1754 2012-12-12 11:52:35 -05:00
Jan-Piet Mens
f9755ca36d mail module: add MIME attachments, port and addresses with phrases
Add HTML-escaping to code examples in rST tempate of module-formatter
 Add support for specifying port, addresses with phrases and attaching files
 Add support for custom headers and document version_added for new options
 X-Mailer header added :)
 protect empty address lists & attachment list, and add bcc
2012-12-12 07:42:42 +01:00
Lorin Hochstein
f8821fa3d9 Fix ppa syntax in apt_repository module doc
The example for using a ppa had the wrong syntax.

Ironically, the correct syntax is illustrated in a comment on line 23.
2012-12-11 23:01:36 -05:00
Norman J. Harman Jr
2e6999dab9 Subverion module improvements
- Added username, password arguments.
  - Documented existing revision argument.
  - Corrected documentation/docstrings; removed git references, use svn
    nomenclature, etc.
  - Refactored duplicate code, redundant shell calls, filter abuse,
    inconsistent formating, etc.
  - Shell quoting so it doesn't break for one guy who has spaces in
    pathnames.
  - svn called with '--non-interactive' and '--no-auth-cache'.
2012-12-10 20:34:26 -06:00
Michael DeHaan
637883164e Merge pull request #1720 from bladypirat/devel
added support for scheduling downtime for all services on host
2012-12-07 08:00:15 -08:00
Alexandre Bourget
0b9cbcb270 supervisorctl: document the 'present' option 2012-12-06 13:33:00 -05:00
Dag Wieers
ac2f396379 Fix "NameError: global name 'name' is not defined" exception 2012-12-05 18:48:43 +01:00
Daniel Hokka Zakrisson
11b64314df Select all fields from the user, as some of them are version-dependent 2012-12-05 09:51:40 +01: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
Piotr Kweclich
9c20eb089b added support for scheduling downtime for all services on host 2012-12-03 22:40:27 +01:00
Stephen Fromm
5b7c8fcc38 Further tweak how to find pip in virtualenv on centos/redhat/fedora
In a virtualenv, pip is called just pip.  This fixes the pip module to
search for the virtualenv pip first before trying the pip-python and
python-pip variants.  Without this, pip module would not install to the
virtualenv when that parameter is provided.
2012-12-02 08:13:10 -08:00
Stephen Fromm
e33e02950d Make use of mirrors in pip module configurable with use_mirrors option
Older versions of pip (anything less than 1.0?) do not support
--use-mirrors flag.  This makes it configurable.  Default is yes.
2012-12-02 08:04:27 -08:00
Daniel Hokka Zakrisson
d5a456fbcf Merge pull request #1697 from bcoca/mint
Implements multiple interpreter overrides
2012-12-02 05:28:28 -08:00
Stephen Fromm
d277953a53 Fix pip module to check if requirements already installed
This updates _is_package_installed() to accept a requirements file
as an argument.  This is used later in main() to check if python libs
specified in a requirements file are already installed.  I updated
main() to consolidate the handling of install/uninstall in a single
block.  This should help if someone wants to remove packages specified
by a requirements file.
2012-12-01 20:00:21 -08:00
Igor Galić
1ba5c5ae97 : doesn't work in this documentation. 2012-11-28 10:36:22 +01:00
Igor Galić
e031054934 Fix subversion module's documentation
Let our users determine what they want to do with a given module.
Particularily when the mdoule doesn't pose any such restrictions.
2012-11-28 10:02:20 +01:00
Brian Coca
8ef2807305 removed env as per project policy
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2012-11-27 11:18:46 -05:00
Jan-Piet Mens
910f1c042e ini_file: prohibit section name 'default'
allow update of default section
add blurb re template to create base file
2012-11-27 13:21:48 +01:00
Patrik Lundin
d4af9e4c5c Use shlex for rc.conf parsing.
This makes the line parsing a lot more robust (and easier to read).
Code supplied by @dhozac, thanks!

Remove re import because this is not used anywhere.
2012-11-25 13:09:54 +01:00
Patrik Lundin
fde00327b0 Rework "enabled" implementation for FreeBSD.
When trying to perform enabled=yes followed by enabled=no
against FreeBSD the module would die with the following error:
TypeError: sub() takes at most 4 arguments (5 given)

The target FreeBSD client (8.2) is running python 2.6.6. It seems the
extra 'flags' argument was added to re.sub() in 2.7.

In fixing this issue I have attempted to create a general atomic method
for modifying a rc.conf file. Hopefully this will make it easier to add
other rc based platorms. The strip/split magic was inspired by the user
module.
2012-11-25 13:09:54 +01:00
Daniel Hokka Zakrisson
4679d8d6e5 Remove references to non-existant variable rc 2012-11-25 00:23:29 +01:00
Daniel Hokka Zakrisson
1ec2a59073 Merge pull request #1676 from dagwieers/service-action-fix
The vars stop/start were intended as strings
2012-11-24 15:16:30 -08:00
Dag Wieers
18b797f096 The vars stop/start were intended as strings
This is a typo that was reported on IRC, because of this people got: "NameError: global name 'stop' is not defined".
2012-11-25 00:13:53 +01:00
Ton Kersten
7bba04b176 Corrected for fallthrough 2012-11-24 16:26:15 +01:00
Ton Kersten
ee4fe9ff55 Added pip-python to the search for CentOS 6 compatibility 2012-11-24 13:36:32 +01:00