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
c0747b7b
Commit
c0747b7b
authored
Oct 30, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pep8 fixes
parent
27e518a0
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
60 additions
and
56 deletions
+60
-56
lib/ansible/inventory/__init__.py
+1
-1
lib/ansible/playbook/play.py
+1
-1
lib/ansible/playbook/task.py
+25
-25
lib/ansible/runner/__init__.py
+1
-1
lib/ansible/utils.py
+3
-0
library/cron
+1
-1
library/fireball
+9
-9
library/lineinfile
+2
-0
library/mysql_user
+2
-3
library/postgresql_db
+1
-1
library/postgresql_user
+1
-1
library/setup
+13
-13
No files found.
lib/ansible/inventory/__init__.py
View file @
c0747b7b
...
...
@@ -300,7 +300,7 @@ class Inventory(object):
groups
=
[
g
.
name
for
g
in
host
.
get_groups
()
if
g
.
name
!=
'all'
]
results
[
'group_names'
]
=
sorted
(
groups
)
vars
.
update
(
results
)
else
:
else
:
vars
.
update
(
host
.
get_variables
())
return
vars
...
...
lib/ansible/playbook/play.py
View file @
c0747b7b
...
...
@@ -123,7 +123,7 @@ class Play(object):
include_file
=
utils
.
template
(
self
.
basedir
,
tokens
[
0
],
mv
)
data
=
utils
.
parse_yaml_from_file
(
utils
.
path_dwim
(
self
.
basedir
,
include_file
))
for
y
in
data
:
results
.
append
(
Task
(
self
,
y
,
module_vars
=
mv
.
copy
()))
results
.
append
(
Task
(
self
,
y
,
module_vars
=
mv
.
copy
()))
elif
type
(
x
)
==
dict
:
task_vars
=
self
.
vars
.
copy
()
results
.
append
(
Task
(
self
,
x
,
module_vars
=
task_vars
))
...
...
lib/ansible/playbook/task.py
View file @
c0747b7b
...
...
@@ -99,10 +99,10 @@ class Task(object):
# delegate_to can use variables
if
not
(
self
.
delegate_to
is
None
):
self
.
delegate_to
=
utils
.
template
(
None
,
self
.
delegate_to
,
self
.
module_vars
)
# delegate_to: localhost should use local transport
if
self
.
delegate_to
in
[
'127.0.0.1'
,
'localhost'
]:
self
.
transport
=
'local'
self
.
delegate_to
=
utils
.
template
(
None
,
self
.
delegate_to
,
self
.
module_vars
)
# delegate_to: localhost should use local transport
if
self
.
delegate_to
in
[
'127.0.0.1'
,
'localhost'
]:
self
.
transport
=
'local'
# notified by is used by Playbook code to flag which hosts
# need to run a notifier
...
...
@@ -195,37 +195,37 @@ class Task(object):
# when: str $x != $y
if
type
(
expression
)
not
in
[
str
,
unicode
]:
raise
errors
.
AnsibleError
(
"invalid usage of when_ operator:
%
s"
%
expression
)
raise
errors
.
AnsibleError
(
"invalid usage of when_ operator:
%
s"
%
expression
)
tokens
=
expression
.
split
()
if
len
(
tokens
)
<
2
:
raise
errors
.
AnsibleError
(
"invalid usage of when_ operator:
%
s"
%
expression
)
raise
errors
.
AnsibleError
(
"invalid usage of when_ operator:
%
s"
%
expression
)
# when_set / when_unset
if
tokens
[
0
]
in
[
'set'
,
'unset'
]:
if
len
(
tokens
)
!=
2
:
raise
errors
.
AnsibleError
(
"usage: when: <set|unset> <$variableName>"
)
return
"is_
%
s('
%
s')"
%
(
tokens
[
0
],
tokens
[
1
])
if
len
(
tokens
)
!=
2
:
raise
errors
.
AnsibleError
(
"usage: when: <set|unset> <$variableName>"
)
return
"is_
%
s('
%
s')"
%
(
tokens
[
0
],
tokens
[
1
])
# when_integer / when_float / when_string
elif
tokens
[
0
]
in
[
'integer'
,
'float'
,
'string'
]:
cast
=
None
if
tokens
[
0
]
==
'integer'
:
cast
=
'int'
elif
tokens
[
0
]
==
'string'
:
cast
=
'str'
elif
tokens
[
0
]
==
'float'
:
cast
=
'float'
tcopy
=
tokens
[
1
:]
for
(
i
,
t
)
in
enumerate
(
tokens
[
1
:]):
if
t
.
find
(
"$"
)
!=
-
1
:
# final variable substitution will happen in Runner code
tcopy
[
i
]
=
"
%
s('
%
s')"
%
(
cast
,
t
)
else
:
tcopy
[
i
]
=
t
return
" "
.
join
(
tcopy
)
cast
=
None
if
tokens
[
0
]
==
'integer'
:
cast
=
'int'
elif
tokens
[
0
]
==
'string'
:
cast
=
'str'
elif
tokens
[
0
]
==
'float'
:
cast
=
'float'
tcopy
=
tokens
[
1
:]
for
(
i
,
t
)
in
enumerate
(
tokens
[
1
:]):
if
t
.
find
(
"$"
)
!=
-
1
:
# final variable substitution will happen in Runner code
tcopy
[
i
]
=
"
%
s('
%
s')"
%
(
cast
,
t
)
else
:
tcopy
[
i
]
=
t
return
" "
.
join
(
tcopy
)
else
:
raise
errors
.
AnsibleError
(
"invalid usage of when_ operator:
%
s"
%
expression
)
raise
errors
.
AnsibleError
(
"invalid usage of when_ operator:
%
s"
%
expression
)
...
...
lib/ansible/runner/__init__.py
View file @
c0747b7b
...
...
@@ -369,7 +369,7 @@ class Runner(object):
conn
=
None
actual_host
=
inject
.
get
(
'ansible_ssh_host'
,
host
)
actual_port
=
port
if
self
.
transport
in
[
'paramiko'
,
'ssh'
]:
if
self
.
transport
in
[
'paramiko'
,
'ssh'
]:
actual_port
=
inject
.
get
(
'ansible_ssh_port'
,
port
)
# the delegated host may have different SSH port configured, etc
...
...
lib/ansible/utils.py
View file @
c0747b7b
...
...
@@ -142,10 +142,13 @@ def is_failed(result):
return
((
result
.
get
(
'rc'
,
0
)
!=
0
)
or
(
result
.
get
(
'failed'
,
False
)
in
[
True
,
'True'
,
'true'
]))
def
check_conditional
(
conditional
):
def
is_set
(
var
):
return
not
var
.
startswith
(
"$"
)
def
is_unset
(
var
):
return
var
.
startswith
(
"$"
)
return
eval
(
conditional
.
replace
(
"
\n
"
,
"
\\
n"
))
def
is_executable
(
path
):
...
...
library/cron
View file @
c0747b7b
...
...
@@ -154,7 +154,7 @@ def add_job(name,job,tmpfile):
def
update_job
(
name
,
job
,
tmpfile
):
return
_update_job
(
name
,
job
,
tmpfile
,
do_add_job
)
def
do_add_job
(
lines
,
comment
,
job
):
def
do_add_job
(
lines
,
comment
,
job
):
lines
.
append
(
comment
)
lines
.
append
(
job
)
...
...
library/fireball
View file @
c0747b7b
...
...
@@ -77,7 +77,7 @@ syslog.openlog('ansible-%s' % os.path.basename(__file__))
PIDFILE
=
os
.
path
.
expanduser
(
"~/.fireball.pid"
)
def
log
(
msg
):
syslog
.
syslog
(
syslog
.
LOG_NOTICE
,
msg
)
syslog
.
syslog
(
syslog
.
LOG_NOTICE
,
msg
)
if
os
.
path
.
exists
(
PIDFILE
):
try
:
...
...
@@ -92,17 +92,17 @@ if os.path.exists(PIDFILE):
HAS_ZMQ
=
False
try
:
import
zmq
HAS_ZMQ
=
True
import
zmq
HAS_ZMQ
=
True
except
ImportError
:
pass
pass
HAS_KEYCZAR
=
False
try
:
from
keyczar.keys
import
AesKey
HAS_KEYCZAR
=
True
from
keyczar.keys
import
AesKey
HAS_KEYCZAR
=
True
except
ImportError
:
pass
pass
# NOTE: this shares a fair amount of code in common with async_wrapper, if async_wrapper were a new module we could move
# this into utils.module_common and probably should anyway
...
...
@@ -163,9 +163,9 @@ def command(data):
def
fetch
(
data
):
if
'data'
not
in
data
:
return
dict
(
failed
=
True
,
msg
=
'internal error: data is required'
)
return
dict
(
failed
=
True
,
msg
=
'internal error: data is required'
)
if
'in_path'
not
in
data
:
return
dict
(
failed
=
True
,
msg
=
'internal error: out_path is required'
)
return
dict
(
failed
=
True
,
msg
=
'internal error: out_path is required'
)
fh
=
open
(
data
[
'in_path'
])
data
=
fh
.
read
()
...
...
library/lineinfile
View file @
c0747b7b
...
...
@@ -157,12 +157,14 @@ def absent(module, dest, regexp, backup):
f
.
close
()
cre
=
re
.
compile
(
regexp
)
found
=
[]
def
matcher
(
line
):
if
cre
.
search
(
line
):
found
.
append
(
line
)
return
False
else
:
return
True
lines
=
filter
(
matcher
,
lines
)
changed
=
len
(
found
)
>
0
if
changed
:
...
...
library/mysql_user
View file @
c0747b7b
...
...
@@ -176,7 +176,7 @@ def privileges_get(cursor, user,host):
privileges
=
res
.
group
(
1
)
.
split
(
", "
)
privileges
=
[
'ALL'
if
x
==
'ALL PRIVILEGES'
else
x
for
x
in
privileges
]
if
"WITH GRANT OPTION"
in
res
.
group
(
4
):
privileges
.
append
(
'GRANT'
)
privileges
.
append
(
'GRANT'
)
db
=
res
.
group
(
2
)
.
replace
(
'`'
,
''
)
output
[
db
]
=
privileges
return
output
...
...
@@ -213,8 +213,7 @@ def privileges_grant(cursor, user,host,db_table,priv):
priv_string
=
","
.
join
(
filter
(
lambda
x
:
x
!=
'GRANT'
,
priv
))
query
=
"GRANT
%
s ON
%
s TO '
%
s'@'
%
s'"
%
(
priv_string
,
db_table
,
user
,
host
)
if
'GRANT'
in
priv
:
query
=
query
+
" WITH GRANT OPTION"
query
=
query
+
" WITH GRANT OPTION"
cursor
.
execute
(
query
)
def
load_mycnf
():
...
...
library/postgresql_db
View file @
c0747b7b
...
...
@@ -149,7 +149,7 @@ def main():
# To use defaults values, keyword arguments must be absent, so
# check which values are empty and don't include in the **kw
# dictionary
params_map
=
{
params_map
=
{
"login_host"
:
"host"
,
"login_user"
:
"user"
,
"login_password"
:
"password"
,
...
...
library/postgresql_user
View file @
c0747b7b
...
...
@@ -379,7 +379,7 @@ def main():
# To use defaults values, keyword arguments must be absent, so
# check which values are empty and don't include in the **kw
# dictionary
params_map
=
{
params_map
=
{
"login_host"
:
"host"
,
"login_user"
:
"user"
,
"login_password"
:
"password"
,
...
...
library/setup
View file @
c0747b7b
...
...
@@ -853,19 +853,19 @@ def run_setup(module):
# templating w/o making a nicer key for it (TODO)
if
os
.
path
.
exists
(
"/usr/bin/ohai"
):
cmd
=
subprocess
.
Popen
(
"/usr/bin/ohai"
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
cmd
.
communicate
()
ohai
=
True
try
:
ohai_ds
=
json
.
loads
(
out
)
except
:
ohai
=
False
if
ohai
:
for
(
k
,
v
)
in
ohai_ds
.
items
():
if
type
(
v
)
==
str
or
type
(
v
)
==
unicode
:
k2
=
"ohai_
%
s"
%
k
.
replace
(
'-'
,
'_'
)
setup_options
[
k2
]
=
v
cmd
=
subprocess
.
Popen
(
"/usr/bin/ohai"
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
cmd
.
communicate
()
ohai
=
True
try
:
ohai_ds
=
json
.
loads
(
out
)
except
:
ohai
=
False
if
ohai
:
for
(
k
,
v
)
in
ohai_ds
.
items
():
if
type
(
v
)
==
str
or
type
(
v
)
==
unicode
:
k2
=
"ohai_
%
s"
%
k
.
replace
(
'-'
,
'_'
)
setup_options
[
k2
]
=
v
setup_result
=
{}
setup_result
[
'ansible_facts'
]
=
setup_options
...
...
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