Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue122 #336

Merged
merged 1 commit into from
May 10, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/apt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import os
import sys
import shlex
import subprocess
import syslog
import traceback

APT_PATH = "/usr/bin/apt-get"
Expand Down Expand Up @@ -113,6 +114,8 @@ if not os.path.exists(APT_PATH):
argfile = sys.argv[1]
args = open(argfile, 'r').read()
items = shlex.split(args)
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

if not len(items):
fail_json(msg='the module requires arguments -a')
Expand Down
7 changes: 6 additions & 1 deletion library/async_status
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ import subprocess
import sys
import datetime
import traceback
import syslog

# ===========================================

# FIXME: better error handling

argsfile = sys.argv[1]
items = shlex.split(file(argsfile).read())
args = open(argsfile, 'r').read()
items = shlex.split(args)

syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

params = {}
for x in items:
Expand Down
4 changes: 4 additions & 0 deletions library/async_wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import datetime
import traceback
import signal
import time
import syslog

def daemonize_self():
# daemonizing code: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012
Expand Down Expand Up @@ -76,6 +77,9 @@ wrapped_module = sys.argv[3]
argsfile = sys.argv[4]
cmd = "%s %s" % (wrapped_module, argsfile)

syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % " ".join(sys.argv[1:]))

# setup logging directory
logdir = os.path.expanduser("~/.ansible_async")
log_path = os.path.join(logdir, jid)
Expand Down
3 changes: 3 additions & 0 deletions library/command
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ import datetime
import traceback
import shlex
import os
import syslog

argfile = sys.argv[1]
args = open(argfile, 'r').read()
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

shell = False

Expand Down
7 changes: 6 additions & 1 deletion library/copy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import sys
import os
import shlex
import syslog

# ===========================================
# convert arguments of form a=b c=d
Expand All @@ -32,7 +33,11 @@ if len(sys.argv) == 1:
argfile = sys.argv[1]
if not os.path.exists(argfile):
sys.exit(1)
items = shlex.split(open(argfile, 'r').read())

args = open(argfile, 'r').read()
items = shlex.split(args)
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)


params = {}
Expand Down
1 change: 1 addition & 0 deletions library/facter
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
# facter
# ruby-json

/usr/bin/logger -t ansible-facter Invoked as-is
/usr/bin/facter --json 2>/dev/null
3 changes: 3 additions & 0 deletions library/file
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import shutil
import stat
import grp
import pwd
import syslog
try:
import selinux
HAVE_SELINUX=True
Expand Down Expand Up @@ -125,6 +126,8 @@ def selinux_context(path):
argfile = sys.argv[1]
args = open(argfile, 'r').read()
items = shlex.split(args)
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

if not len(items):
fail_kv(msg='the module requires arguments -a')
Expand Down
3 changes: 3 additions & 0 deletions library/git
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import os
import sys
import shlex
import subprocess
import syslog

# ===========================================
# Basic support methods
Expand All @@ -57,6 +58,8 @@ if not os.path.exists(argfile):

args = open(argfile, 'r').read()
items = shlex.split(args)
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

if not len(items):
fail_json(msg="the command module requires arguments (-a)")
Expand Down
3 changes: 3 additions & 0 deletions library/group
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import grp
import shlex
import subprocess
import sys
import syslog

GROUPADD = "/usr/sbin/groupadd"
GROUPDEL = "/usr/sbin/groupdel"
Expand Down Expand Up @@ -131,6 +132,8 @@ if len(sys.argv) == 2 and os.path.exists(sys.argv[1]):
else:
args = ' '.join(sys.argv[1:])
items = shlex.split(args)
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

if not len(items):
fail_json(msg='the module requires arguments -a')
Expand Down
1 change: 1 addition & 0 deletions library/ohai
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#

/usr/bin/logger -t ansible-ohai Invoked as-is
/usr/bin/ohai
6 changes: 6 additions & 0 deletions library/ping
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ try:
except ImportError:
import simplejson as json

import os
import syslog

syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked as-is')

print json.dumps({ "ping" : "pong" })
3 changes: 3 additions & 0 deletions library/service
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import sys
import shlex
import subprocess
import os.path
import syslog

# TODO: switch to fail_json and other helper functions
# like other modules are using
Expand Down Expand Up @@ -95,6 +96,8 @@ def _do_enable(name, enable):
argfile = sys.argv[1]
args = open(argfile, 'r').read()
items = shlex.split(args)
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

if not len(items):
fail_json(dict(failed=True, msg='this module requires arguments (-a)'))
Expand Down
4 changes: 4 additions & 0 deletions library/setup
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import socket
import struct
import subprocess
import traceback
import syslog

try:
import json
Expand Down Expand Up @@ -295,6 +296,9 @@ except:
(k,v) = opt.split("=")
setup_options[k]=v

syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % setup_options)

ansible_file = os.path.expandvars(setup_options.get('metadata', DEFAULT_ANSIBLE_SETUP))
ansible_dir = os.path.dirname(ansible_file)

Expand Down
7 changes: 6 additions & 1 deletion library/slurp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import sys
import os
import shlex
import base64
import syslog

try:
import json
Expand All @@ -36,7 +37,11 @@ if len(sys.argv) == 1:
argfile = sys.argv[1]
if not os.path.exists(argfile):
sys.exit(1)
items = shlex.split(open(argfile, 'r').read())

args = open(argfile, 'r').read()
items = shlex.split(args)
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

params = {}
for x in items:
Expand Down
3 changes: 3 additions & 0 deletions library/user
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import grp
import shlex
import subprocess
import sys
import syslog
try:
import spwd
HAVE_SPWD=True
Expand Down Expand Up @@ -264,6 +265,8 @@ if not os.path.exists(USERDEL):
argfile = sys.argv[1]
args = open(argfile, 'r').read()
items = shlex.split(args)
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

if not len(items):
fail_json(msg='the module requires arguments -a')
Expand Down
3 changes: 3 additions & 0 deletions library/virt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ except ImportError:
import os
import sys
import subprocess
import syslog
try:
import libvirt
except ImportError:
Expand Down Expand Up @@ -366,6 +367,8 @@ def main():

args = open(argfile, 'r').read()
items = shlex.split(args)
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

if not len(items):
return VIRT_FAILED, msg
Expand Down
3 changes: 3 additions & 0 deletions library/yum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import datetime
import shlex
import re
import traceback
import syslog


try:
Expand Down Expand Up @@ -299,6 +300,8 @@ def main():

args = open(argfile, 'r').read()
items = shlex.split(args)
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % args)

if not len(items):
msg = "the yum module requires arguments (-a)"
Expand Down