Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
d118cf3e
Commit
d118cf3e
authored
May 09, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #336 from sfromm/issue122
Issue122 - have all modules log to syslog
parents
0fe8e51c
aea022b0
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
61 additions
and
3 deletions
+61
-3
library/apt
+3
-0
library/async_status
+6
-1
library/async_wrapper
+4
-0
library/command
+3
-0
library/copy
+6
-1
library/facter
+1
-0
library/file
+3
-0
library/git
+3
-0
library/group
+3
-0
library/ohai
+1
-0
library/ping
+6
-0
library/service
+3
-0
library/setup
+4
-0
library/slurp
+6
-1
library/user
+3
-0
library/virt
+3
-0
library/yum
+3
-0
No files found.
library/apt
View file @
d118cf3e
...
@@ -25,6 +25,7 @@ import os
...
@@ -25,6 +25,7 @@ import os
import
sys
import
sys
import
shlex
import
shlex
import
subprocess
import
subprocess
import
syslog
import
traceback
import
traceback
APT_PATH
=
"/usr/bin/apt-get"
APT_PATH
=
"/usr/bin/apt-get"
...
@@ -113,6 +114,8 @@ if not os.path.exists(APT_PATH):
...
@@ -113,6 +114,8 @@ if not os.path.exists(APT_PATH):
argfile
=
sys
.
argv
[
1
]
argfile
=
sys
.
argv
[
1
]
args
=
open
(
argfile
,
'r'
).
read
()
args
=
open
(
argfile
,
'r'
).
read
()
items
=
shlex
.
split
(
args
)
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
):
if
not
len
(
items
):
fail_json
(
msg
=
'the module requires arguments -a'
)
fail_json
(
msg
=
'the module requires arguments -a'
)
...
...
library/async_status
View file @
d118cf3e
...
@@ -28,13 +28,18 @@ import subprocess
...
@@ -28,13 +28,18 @@ import subprocess
import
sys
import
sys
import
datetime
import
datetime
import
traceback
import
traceback
import
syslog
# ===========================================
# ===========================================
# FIXME: better error handling
# FIXME: better error handling
argsfile
=
sys
.
argv
[
1
]
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
=
{}
params
=
{}
for
x
in
items
:
for
x
in
items
:
...
...
library/async_wrapper
View file @
d118cf3e
...
@@ -30,6 +30,7 @@ import datetime
...
@@ -30,6 +30,7 @@ import datetime
import
traceback
import
traceback
import
signal
import
signal
import
time
import
time
import
syslog
def
daemonize_self
():
def
daemonize_self
():
# daemonizing code: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012
# daemonizing code: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012
...
@@ -76,6 +77,9 @@ wrapped_module = sys.argv[3]
...
@@ -76,6 +77,9 @@ wrapped_module = sys.argv[3]
argsfile
=
sys
.
argv
[
4
]
argsfile
=
sys
.
argv
[
4
]
cmd
=
"
%
s
%
s"
%
(
wrapped_module
,
argsfile
)
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
# setup logging directory
logdir
=
os
.
path
.
expanduser
(
"~/.ansible_async"
)
logdir
=
os
.
path
.
expanduser
(
"~/.ansible_async"
)
log_path
=
os
.
path
.
join
(
logdir
,
jid
)
log_path
=
os
.
path
.
join
(
logdir
,
jid
)
...
...
library/command
View file @
d118cf3e
...
@@ -29,9 +29,12 @@ import datetime
...
@@ -29,9 +29,12 @@ import datetime
import
traceback
import
traceback
import
shlex
import
shlex
import
os
import
os
import
syslog
argfile
=
sys
.
argv
[
1
]
argfile
=
sys
.
argv
[
1
]
args
=
open
(
argfile
,
'r'
)
.
read
()
args
=
open
(
argfile
,
'r'
)
.
read
()
syslog
.
openlog
(
'ansible-
%
s'
%
os
.
path
.
basename
(
__file__
))
syslog
.
syslog
(
syslog
.
LOG_NOTICE
,
'Invoked with
%
s'
%
args
)
shell
=
False
shell
=
False
...
...
library/copy
View file @
d118cf3e
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
import
sys
import
sys
import
os
import
os
import
shlex
import
shlex
import
syslog
# ===========================================
# ===========================================
# convert arguments of form a=b c=d
# convert arguments of form a=b c=d
...
@@ -32,7 +33,11 @@ if len(sys.argv) == 1:
...
@@ -32,7 +33,11 @@ if len(sys.argv) == 1:
argfile
=
sys
.
argv
[
1
]
argfile
=
sys
.
argv
[
1
]
if
not
os
.
path
.
exists
(
argfile
):
if
not
os
.
path
.
exists
(
argfile
):
sys
.
exit
(
1
)
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
=
{}
params
=
{}
...
...
library/facter
View file @
d118cf3e
...
@@ -22,4 +22,5 @@
...
@@ -22,4 +22,5 @@
# facter
# facter
# ruby-json
# ruby-json
/usr/bin/logger
-t
ansible-facter Invoked as-is
/usr/bin/facter
--json
2>/dev/null
/usr/bin/facter
--json
2>/dev/null
library/file
View file @
d118cf3e
...
@@ -25,6 +25,7 @@ import shutil
...
@@ -25,6 +25,7 @@ import shutil
import
stat
import
stat
import
grp
import
grp
import
pwd
import
pwd
import
syslog
try
:
try
:
import
selinux
import
selinux
HAVE_SELINUX
=
True
HAVE_SELINUX
=
True
...
@@ -125,6 +126,8 @@ def selinux_context(path):
...
@@ -125,6 +126,8 @@ def selinux_context(path):
argfile
=
sys
.
argv
[
1
]
argfile
=
sys
.
argv
[
1
]
args
=
open
(
argfile
,
'r'
)
.
read
()
args
=
open
(
argfile
,
'r'
)
.
read
()
items
=
shlex
.
split
(
args
)
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
):
if
not
len
(
items
):
fail_kv
(
msg
=
'the module requires arguments -a'
)
fail_kv
(
msg
=
'the module requires arguments -a'
)
...
...
library/git
View file @
d118cf3e
...
@@ -32,6 +32,7 @@ import re
...
@@ -32,6 +32,7 @@ import re
import
sys
import
sys
import
shlex
import
shlex
import
subprocess
import
subprocess
import
syslog
# ===========================================
# ===========================================
# Basic support methods
# Basic support methods
...
@@ -58,6 +59,8 @@ if not os.path.exists(argfile):
...
@@ -58,6 +59,8 @@ if not os.path.exists(argfile):
args
=
open
(
argfile
,
'r'
)
.
read
()
args
=
open
(
argfile
,
'r'
)
.
read
()
items
=
shlex
.
split
(
args
)
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
):
if
not
len
(
items
):
fail_json
(
msg
=
"the command module requires arguments (-a)"
)
fail_json
(
msg
=
"the command module requires arguments (-a)"
)
...
...
library/group
View file @
d118cf3e
...
@@ -26,6 +26,7 @@ import grp
...
@@ -26,6 +26,7 @@ import grp
import
shlex
import
shlex
import
subprocess
import
subprocess
import
sys
import
sys
import
syslog
GROUPADD
=
"/usr/sbin/groupadd"
GROUPADD
=
"/usr/sbin/groupadd"
GROUPDEL
=
"/usr/sbin/groupdel"
GROUPDEL
=
"/usr/sbin/groupdel"
...
@@ -131,6 +132,8 @@ if len(sys.argv) == 2 and os.path.exists(sys.argv[1]):
...
@@ -131,6 +132,8 @@ if len(sys.argv) == 2 and os.path.exists(sys.argv[1]):
else
:
else
:
args
=
' '
.
join
(
sys
.
argv
[
1
:])
args
=
' '
.
join
(
sys
.
argv
[
1
:])
items
=
shlex
.
split
(
args
)
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
):
if
not
len
(
items
):
fail_json
(
msg
=
'the module requires arguments -a'
)
fail_json
(
msg
=
'the module requires arguments -a'
)
...
...
library/ohai
View file @
d118cf3e
...
@@ -18,4 +18,5 @@
...
@@ -18,4 +18,5 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
#
/usr/bin/logger
-t
ansible-ohai Invoked as-is
/usr/bin/ohai
/usr/bin/ohai
library/ping
View file @
d118cf3e
...
@@ -22,4 +22,10 @@ try:
...
@@ -22,4 +22,10 @@ try:
except
ImportError
:
except
ImportError
:
import
simplejson
as
json
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"
})
print
json
.
dumps
({
"ping"
:
"pong"
})
library/service
View file @
d118cf3e
...
@@ -25,6 +25,7 @@ import sys
...
@@ -25,6 +25,7 @@ import sys
import
shlex
import
shlex
import
subprocess
import
subprocess
import
os.path
import
os.path
import
syslog
# TODO: switch to fail_json and other helper functions
# TODO: switch to fail_json and other helper functions
# like other modules are using
# like other modules are using
...
@@ -95,6 +96,8 @@ def _do_enable(name, enable):
...
@@ -95,6 +96,8 @@ def _do_enable(name, enable):
argfile
=
sys
.
argv
[
1
]
argfile
=
sys
.
argv
[
1
]
args
=
open
(
argfile
,
'r'
)
.
read
()
args
=
open
(
argfile
,
'r'
)
.
read
()
items
=
shlex
.
split
(
args
)
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
):
if
not
len
(
items
):
fail_json
(
dict
(
failed
=
True
,
msg
=
'this module requires arguments (-a)'
))
fail_json
(
dict
(
failed
=
True
,
msg
=
'this module requires arguments (-a)'
))
...
...
library/setup
View file @
d118cf3e
...
@@ -31,6 +31,7 @@ import socket
...
@@ -31,6 +31,7 @@ import socket
import
struct
import
struct
import
subprocess
import
subprocess
import
traceback
import
traceback
import
syslog
try
:
try
:
import
json
import
json
...
@@ -295,6 +296,9 @@ except:
...
@@ -295,6 +296,9 @@ except:
(
k
,
v
)
=
opt
.
split
(
"="
)
(
k
,
v
)
=
opt
.
split
(
"="
)
setup_options
[
k
]
=
v
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_file
=
os
.
path
.
expandvars
(
setup_options
.
get
(
'metadata'
,
DEFAULT_ANSIBLE_SETUP
))
ansible_dir
=
os
.
path
.
dirname
(
ansible_file
)
ansible_dir
=
os
.
path
.
dirname
(
ansible_file
)
...
...
library/slurp
View file @
d118cf3e
...
@@ -21,6 +21,7 @@ import sys
...
@@ -21,6 +21,7 @@ import sys
import
os
import
os
import
shlex
import
shlex
import
base64
import
base64
import
syslog
try
:
try
:
import
json
import
json
...
@@ -36,7 +37,11 @@ if len(sys.argv) == 1:
...
@@ -36,7 +37,11 @@ if len(sys.argv) == 1:
argfile
=
sys
.
argv
[
1
]
argfile
=
sys
.
argv
[
1
]
if
not
os
.
path
.
exists
(
argfile
):
if
not
os
.
path
.
exists
(
argfile
):
sys
.
exit
(
1
)
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
=
{}
params
=
{}
for
x
in
items
:
for
x
in
items
:
...
...
library/user
View file @
d118cf3e
...
@@ -27,6 +27,7 @@ import grp
...
@@ -27,6 +27,7 @@ import grp
import
shlex
import
shlex
import
subprocess
import
subprocess
import
sys
import
sys
import
syslog
try
:
try
:
import
spwd
import
spwd
HAVE_SPWD
=
True
HAVE_SPWD
=
True
...
@@ -264,6 +265,8 @@ if not os.path.exists(USERDEL):
...
@@ -264,6 +265,8 @@ if not os.path.exists(USERDEL):
argfile
=
sys
.
argv
[
1
]
argfile
=
sys
.
argv
[
1
]
args
=
open
(
argfile
,
'r'
)
.
read
()
args
=
open
(
argfile
,
'r'
)
.
read
()
items
=
shlex
.
split
(
args
)
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
):
if
not
len
(
items
):
fail_json
(
msg
=
'the module requires arguments -a'
)
fail_json
(
msg
=
'the module requires arguments -a'
)
...
...
library/virt
View file @
d118cf3e
...
@@ -27,6 +27,7 @@ except ImportError:
...
@@ -27,6 +27,7 @@ except ImportError:
import
os
import
os
import
sys
import
sys
import
subprocess
import
subprocess
import
syslog
try
:
try
:
import
libvirt
import
libvirt
except
ImportError
:
except
ImportError
:
...
@@ -366,6 +367,8 @@ def main():
...
@@ -366,6 +367,8 @@ def main():
args
=
open
(
argfile
,
'r'
)
.
read
()
args
=
open
(
argfile
,
'r'
)
.
read
()
items
=
shlex
.
split
(
args
)
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
):
if
not
len
(
items
):
return
VIRT_FAILED
,
msg
return
VIRT_FAILED
,
msg
...
...
library/yum
View file @
d118cf3e
...
@@ -27,6 +27,7 @@ import datetime
...
@@ -27,6 +27,7 @@ import datetime
import
shlex
import
shlex
import
re
import
re
import
traceback
import
traceback
import
syslog
try
:
try
:
...
@@ -299,6 +300,8 @@ def main():
...
@@ -299,6 +300,8 @@ def main():
args
=
open
(
argfile
,
'r'
)
.
read
()
args
=
open
(
argfile
,
'r'
)
.
read
()
items
=
shlex
.
split
(
args
)
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
):
if
not
len
(
items
):
msg
=
"the yum module requires arguments (-a)"
msg
=
"the yum module requires arguments (-a)"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment