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
4e8b97dd
Commit
4e8b97dd
authored
Mar 12, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More shell updates
parent
e7f74251
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
15 deletions
+19
-15
library/system/cron
+10
-8
library/system/debconf
+4
-2
library/system/hostname
+1
-1
library/system/lvg
+4
-4
No files found.
library/system/cron
View file @
4e8b97dd
...
...
@@ -145,6 +145,7 @@ import os
import
re
import
tempfile
import
platform
import
pipes
CRONCMD
=
"/usr/bin/crontab"
...
...
@@ -190,7 +191,8 @@ class CronTab(object):
except
:
raise
CronTabError
(
"Unexpected error:"
,
sys
.
exc_info
()[
0
])
else
:
(
rc
,
out
,
err
)
=
self
.
module
.
run_command
(
self
.
_read_user_execute
())
# using safely quoted shell for now, but this really should be two non-shell calls instead. FIXME
(
rc
,
out
,
err
)
=
self
.
module
.
run_command
(
self
.
_read_user_execute
(),
use_unsafe_shell
=
True
)
if
rc
!=
0
and
rc
!=
1
:
# 1 can mean that there are no jobs.
raise
CronTabError
(
"Unable to read crontab"
)
...
...
@@ -235,8 +237,8 @@ class CronTab(object):
# Add the entire crontab back to the user crontab
if
not
self
.
cron_file
:
#
os.system(self._write_execute(path))
(
rc
,
out
,
err
)
=
self
.
module
.
run_command
(
self
.
_write_execute
(
path
))
#
quoting shell args for now but really this should be two non-shell calls. FIXME
(
rc
,
out
,
err
)
=
self
.
module
.
run_command
(
self
.
_write_execute
(
path
)
,
use_unsafe_shell
=
True
)
os
.
unlink
(
path
)
if
rc
!=
0
:
...
...
@@ -350,9 +352,9 @@ class CronTab(object):
user
=
''
if
self
.
user
:
if
platform
.
system
()
==
'SunOS'
:
return
"su
'
%
s' -c '
%
s -l'"
%
(
self
.
user
,
CRONCMD
)
return
"su
%
s -c '
%
s -l'"
%
(
pipes
.
quote
(
self
.
user
),
pipes
.
quote
(
CRONCMD
)
)
else
:
user
=
'-u
%
s'
%
self
.
user
user
=
'-u
%
s'
%
pipes
.
quote
(
self
.
user
)
return
"
%
s
%
s
%
s"
%
(
CRONCMD
,
user
,
'-l'
)
def
_write_execute
(
self
,
path
):
...
...
@@ -362,10 +364,10 @@ class CronTab(object):
user
=
''
if
self
.
user
:
if
platform
.
system
()
==
'SunOS'
:
return
"chown
%
s
%
s ; su '
%
s' -c '
%
s
%
s'"
%
(
self
.
user
,
path
,
self
.
user
,
CRONCMD
,
path
)
return
"chown
%
s
%
s ; su '
%
s' -c '
%
s
%
s'"
%
(
pipes
.
quote
(
self
.
user
),
pipes
.
quote
(
path
),
pipes
.
quote
(
self
.
user
),
CRONCMD
,
pipes
.
quote
(
path
)
)
else
:
user
=
'-u
%
s'
%
self
.
user
return
"
%
s
%
s
%
s"
%
(
CRONCMD
,
user
,
p
ath
)
user
=
'-u
%
s'
%
pipes
.
quote
(
self
.
user
)
return
"
%
s
%
s
%
s"
%
(
CRONCMD
,
user
,
p
ipes
.
quote
(
path
)
)
...
...
library/system/debconf
View file @
4e8b97dd
...
...
@@ -84,6 +84,8 @@ debconf: name='oracle-java7-installer' question='shared/accepted-oracle-license-
debconf: name='tzdata'
'''
import
pipes
def
get_selections
(
module
,
pkg
):
cmd
=
[
module
.
get_bin_path
(
'debconf-show'
,
True
),
pkg
]
rc
,
out
,
err
=
module
.
run_command
(
' '
.
join
(
cmd
))
...
...
@@ -105,11 +107,11 @@ def set_selection(module, pkg, question, vtype, value, unseen):
data
=
' '
.
join
([
question
,
vtype
,
value
])
setsel
=
module
.
get_bin_path
(
'debconf-set-selections'
,
True
)
cmd
=
[
"echo '
%
s
%
s' |"
%
(
p
kg
,
data
),
setsel
]
cmd
=
[
"echo '
%
s
%
s' |"
%
(
p
ipes
.
quote
(
pkg
),
pipes
.
quote
(
data
)
),
setsel
]
if
unseen
:
cmd
.
append
(
'-u'
)
return
module
.
run_command
(
' '
.
join
(
cmd
))
return
module
.
run_command
(
' '
.
join
(
cmd
)
,
use_unsafe_shell
=
True
)
def
main
():
...
...
library/system/hostname
View file @
4e8b97dd
...
...
@@ -286,7 +286,7 @@ class FedoraStrategy(GenericStrategy):
def
get_permanent_hostname
(
self
):
cmd
=
'hostnamectl status | awk
\'
/^ *Static hostname:/{printf("
%
s", $3)}
\'
'
rc
,
out
,
err
=
self
.
module
.
run_command
(
cmd
)
rc
,
out
,
err
=
self
.
module
.
run_command
(
cmd
,
use_unsafe_shell
=
True
)
if
rc
!=
0
:
self
.
module
.
fail_json
(
msg
=
"Command failed rc=
%
d, out=
%
s, err=
%
s"
%
(
rc
,
out
,
err
))
...
...
library/system/lvg
View file @
4e8b97dd
...
...
@@ -162,13 +162,13 @@ def main():
### create PV
pvcreate_cmd
=
module
.
get_bin_path
(
'pvcreate'
,
True
)
for
current_dev
in
dev_list
:
rc
,
_
,
err
=
module
.
run_command
(
"
%
s
%
s"
%
(
pvcreate_cmd
,
current_dev
))
rc
,
_
,
err
=
module
.
run_command
(
"
%
s
%
s"
%
(
pvcreate_cmd
,
current_dev
))
if
rc
==
0
:
changed
=
True
else
:
module
.
fail_json
(
msg
=
"Creating physical volume '
%
s' failed"
%
current_dev
,
rc
=
rc
,
err
=
err
)
module
.
fail_json
(
msg
=
"Creating physical volume '
%
s' failed"
%
current_dev
,
rc
=
rc
,
err
=
err
)
vgcreate_cmd
=
module
.
get_bin_path
(
'vgcreate'
)
rc
,
_
,
err
=
module
.
run_command
(
"
%
s -s
%
s
%
s
%
s"
%
(
vgcreate_cmd
,
pesize
,
vg
,
dev_string
))
rc
,
_
,
err
=
module
.
run_command
(
"
%
s -s
%
s
%
s
%
s"
%
(
vgcreate_cmd
,
pesize
,
vg
,
dev_string
))
if
rc
==
0
:
changed
=
True
else
:
...
...
@@ -210,7 +210,7 @@ def main():
module
.
fail_json
(
msg
=
"Creating physical volume '
%
s' failed"
%
current_dev
,
rc
=
rc
,
err
=
err
)
### add PV to our VG
vgextend_cmd
=
module
.
get_bin_path
(
'vgextend'
,
True
)
rc
,
_
,
err
=
module
.
run_command
(
"
%
s
%
s
%
s"
%
(
vgextend_cmd
,
vg
,
devs_to_add_string
))
rc
,
_
,
err
=
module
.
run_command
(
"
%
s
%
s
%
s"
%
(
vgextend_cmd
,
vg
,
devs_to_add_string
))
if
rc
==
0
:
changed
=
True
else
:
...
...
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