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
fa8e6530
Commit
fa8e6530
authored
Feb 09, 2013
by
Blair Zajac
Committed by
Michael DeHaan
Feb 16, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify and correct comparisons with None.
parent
21722017
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
16 additions
and
16 deletions
+16
-16
lib/ansible/callbacks.py
+1
-1
lib/ansible/runner/__init__.py
+1
-1
library/apt
+1
-1
library/git
+1
-1
library/mysql_db
+1
-1
library/mysql_user
+1
-1
library/selinux
+2
-2
library/service
+5
-5
library/virt
+1
-1
plugins/inventory/ec2.py
+2
-2
No files found.
lib/ansible/callbacks.py
View file @
fa8e6530
...
@@ -132,7 +132,7 @@ def regular_generic_msg(hostname, result, oneline, caption):
...
@@ -132,7 +132,7 @@ def regular_generic_msg(hostname, result, oneline, caption):
def
banner
(
msg
):
def
banner
(
msg
):
if
cowsay
!=
None
:
if
cowsay
:
cmd
=
subprocess
.
Popen
([
cowsay
,
"-W"
,
"60"
,
msg
],
cmd
=
subprocess
.
Popen
([
cowsay
,
"-W"
,
"60"
,
msg
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
(
out
,
err
)
=
cmd
.
communicate
()
(
out
,
err
)
=
cmd
.
communicate
()
...
...
lib/ansible/runner/__init__.py
View file @
fa8e6530
...
@@ -501,7 +501,7 @@ class Runner(object):
...
@@ -501,7 +501,7 @@ class Runner(object):
else
:
else
:
err
=
stderr
err
=
stderr
if
rc
!=
None
:
if
rc
is
not
None
:
return
dict
(
rc
=
rc
,
stdout
=
out
,
stderr
=
err
)
return
dict
(
rc
=
rc
,
stdout
=
out
,
stderr
=
err
)
else
:
else
:
return
dict
(
stdout
=
out
,
stderr
=
err
)
return
dict
(
stdout
=
out
,
stderr
=
err
)
...
...
library/apt
View file @
fa8e6530
...
@@ -202,7 +202,7 @@ def main():
...
@@ -202,7 +202,7 @@ def main():
if module.boolean(p['
update_cache
']):
if module.boolean(p['
update_cache
']):
cache.update()
cache.update()
cache.open(progress=None)
cache.open(progress=None)
if
p['
package
'] == None
:
if
not p['
package
']
:
module.exit_json(changed=False)
module.exit_json(changed=False)
force_yes = module.boolean(p['
force
'])
force_yes = module.boolean(p['
force
'])
...
...
library/git
View file @
fa8e6530
...
@@ -89,7 +89,7 @@ def has_local_mods(dest):
...
@@ -89,7 +89,7 @@ def has_local_mods(dest):
os
.
chdir
(
dest
)
os
.
chdir
(
dest
)
cmd
=
"git status -s"
cmd
=
"git status -s"
lines
=
os
.
popen
(
cmd
)
.
read
()
.
splitlines
()
lines
=
os
.
popen
(
cmd
)
.
read
()
.
splitlines
()
lines
=
filter
(
lambda
c
:
re
.
search
(
'^
\\
?
\\
?.*$'
,
c
)
==
None
,
lines
)
lines
=
filter
(
lambda
c
:
not
re
.
search
(
'^
\\
?
\\
?.*$'
,
c
),
lines
)
return
len
(
lines
)
>
0
return
len
(
lines
)
>
0
def
reset
(
module
,
dest
,
force
):
def
reset
(
module
,
dest
,
force
):
...
...
library/mysql_db
View file @
fa8e6530
...
@@ -187,7 +187,7 @@ def main():
...
@@ -187,7 +187,7 @@ def main():
else
:
else
:
connect_to_db
=
'mysql'
connect_to_db
=
'mysql'
try
:
try
:
if
module
.
params
[
"login_unix_socket"
]
!=
None
:
if
module
.
params
[
"login_unix_socket"
]:
db_connection
=
MySQLdb
.
connect
(
host
=
module
.
params
[
"login_host"
],
unix_socket
=
module
.
params
[
"login_unix_socket"
],
user
=
login_user
,
passwd
=
login_password
,
db
=
connect_to_db
)
db_connection
=
MySQLdb
.
connect
(
host
=
module
.
params
[
"login_host"
],
unix_socket
=
module
.
params
[
"login_unix_socket"
],
user
=
login_user
,
passwd
=
login_password
,
db
=
connect_to_db
)
else
:
else
:
db_connection
=
MySQLdb
.
connect
(
host
=
module
.
params
[
"login_host"
],
user
=
login_user
,
passwd
=
login_password
,
db
=
connect_to_db
)
db_connection
=
MySQLdb
.
connect
(
host
=
module
.
params
[
"login_host"
],
user
=
login_user
,
passwd
=
login_password
,
db
=
connect_to_db
)
...
...
library/mysql_user
View file @
fa8e6530
...
@@ -285,7 +285,7 @@ def main():
...
@@ -285,7 +285,7 @@ def main():
module
.
fail_json
(
msg
=
"when supplying login arguments, both login_user and login_password must be provided"
)
module
.
fail_json
(
msg
=
"when supplying login arguments, both login_user and login_password must be provided"
)
try
:
try
:
if
module
.
params
[
"login_unix_socket"
]
!=
None
:
if
module
.
params
[
"login_unix_socket"
]:
db_connection
=
MySQLdb
.
connect
(
host
=
module
.
params
[
"login_host"
],
unix_socket
=
module
.
params
[
"login_unix_socket"
],
user
=
login_user
,
passwd
=
login_password
,
db
=
"mysql"
)
db_connection
=
MySQLdb
.
connect
(
host
=
module
.
params
[
"login_host"
],
unix_socket
=
module
.
params
[
"login_unix_socket"
],
user
=
login_user
,
passwd
=
login_password
,
db
=
"mysql"
)
else
:
else
:
db_connection
=
MySQLdb
.
connect
(
host
=
module
.
params
[
"login_host"
],
user
=
login_user
,
passwd
=
login_password
,
db
=
"mysql"
)
db_connection
=
MySQLdb
.
connect
(
host
=
module
.
params
[
"login_host"
],
user
=
login_user
,
passwd
=
login_password
,
db
=
"mysql"
)
...
...
library/selinux
View file @
fa8e6530
...
@@ -147,10 +147,10 @@ def main():
...
@@ -147,10 +147,10 @@ def main():
# check to see if policy is set if state is not 'disabled'
# check to see if policy is set if state is not 'disabled'
if
(
state
!=
'disabled'
):
if
(
state
!=
'disabled'
):
if
(
policy
==
''
or
policy
==
None
)
:
if
not
policy
:
module
.
fail_json
(
msg
=
'policy is required if state is not
\'
disabled
\'
'
)
module
.
fail_json
(
msg
=
'policy is required if state is not
\'
disabled
\'
'
)
else
:
else
:
if
(
policy
==
''
or
policy
==
None
)
:
if
not
policy
:
policy
=
config_policy
policy
=
config_policy
# check changed values and run changes
# check changed values and run changes
...
...
library/service
View file @
fa8e6530
...
@@ -236,7 +236,7 @@ class Service(object):
...
@@ -236,7 +236,7 @@ class Service(object):
break
break
def
check_service_changed
(
self
):
def
check_service_changed
(
self
):
if
self
.
state
and
self
.
running
==
None
:
if
self
.
state
and
self
.
running
is
None
:
self
.
module
.
fail_json
(
msg
=
"failed determining the current service state => state stays unchanged"
)
self
.
module
.
fail_json
(
msg
=
"failed determining the current service state => state stays unchanged"
)
# Find out if state has changed
# Find out if state has changed
if
not
self
.
running
and
self
.
state
in
[
"started"
,
"running"
]:
if
not
self
.
running
and
self
.
state
in
[
"started"
,
"running"
]:
...
@@ -377,7 +377,7 @@ class LinuxService(Service):
...
@@ -377,7 +377,7 @@ class LinuxService(Service):
rc
,
status_stdout
,
status_stderr
=
self
.
service_control
()
rc
,
status_stdout
,
status_stderr
=
self
.
service_control
()
# Check if we have upstart on the system and then the job state
# Check if we have upstart on the system and then the job state
if
self
.
svc_initctl
!=
None
and
self
.
running
is
None
:
if
self
.
svc_initctl
and
self
.
running
is
None
:
# check the job status by upstart response
# check the job status by upstart response
initctl_rc
,
initctl_status_stdout
,
initctl_status_stderr
=
self
.
execute_command
(
"
%
s status
%
s"
%
(
self
.
svc_initctl
,
self
.
name
))
initctl_rc
,
initctl_status_stdout
,
initctl_status_stderr
=
self
.
execute_command
(
"
%
s status
%
s"
%
(
self
.
svc_initctl
,
self
.
name
))
if
initctl_status_stdout
.
find
(
"stop/waiting"
)
!=
-
1
:
if
initctl_status_stdout
.
find
(
"stop/waiting"
)
!=
-
1
:
...
@@ -386,14 +386,14 @@ class LinuxService(Service):
...
@@ -386,14 +386,14 @@ class LinuxService(Service):
self
.
running
=
True
self
.
running
=
True
# if the job status is still not known check it by response code
# if the job status is still not known check it by response code
if
self
.
running
==
None
:
if
self
.
running
is
None
:
if
rc
in
[
2
,
3
,
4
,
69
]:
if
rc
in
[
2
,
3
,
4
,
69
]:
self
.
running
=
False
self
.
running
=
False
elif
rc
==
0
:
elif
rc
==
0
:
self
.
running
=
True
self
.
running
=
True
# if the job status is still not known check it by status output keywords
# if the job status is still not known check it by status output keywords
if
self
.
running
==
None
:
if
self
.
running
is
None
:
# first tranform the status output that could irritate keyword matching
# first tranform the status output that could irritate keyword matching
cleanout
=
status_stdout
.
lower
()
.
replace
(
self
.
name
.
lower
(),
''
)
cleanout
=
status_stdout
.
lower
()
.
replace
(
self
.
name
.
lower
(),
''
)
if
"stop"
in
cleanout
:
if
"stop"
in
cleanout
:
...
@@ -414,7 +414,7 @@ class LinuxService(Service):
...
@@ -414,7 +414,7 @@ class LinuxService(Service):
self
.
running
=
False
self
.
running
=
False
# if the job status is still not known check it by special conditions
# if the job status is still not known check it by special conditions
if
self
.
running
==
None
:
if
self
.
running
is
None
:
if
self
.
name
==
'iptables'
and
status_stdout
.
find
(
"ACCEPT"
)
!=
-
1
:
if
self
.
name
==
'iptables'
and
status_stdout
.
find
(
"ACCEPT"
)
!=
-
1
:
# iptables status command output is lame
# iptables status command output is lame
# TODO: lookup if we can use a return code for this instead?
# TODO: lookup if we can use a return code for this instead?
...
...
library/virt
View file @
fa8e6530
...
@@ -322,7 +322,7 @@ class Virt(object):
...
@@ -322,7 +322,7 @@ class Virt(object):
"""
"""
conn
=
libvirt
.
openReadOnly
(
None
)
conn
=
libvirt
.
openReadOnly
(
None
)
if
conn
==
None
:
if
not
conn
:
return
(
-
1
,
'Failed to open connection to the hypervisor'
)
return
(
-
1
,
'Failed to open connection to the hypervisor'
)
try
:
try
:
domV
=
conn
.
lookupByName
(
vmid
)
domV
=
conn
.
lookupByName
(
vmid
)
...
...
plugins/inventory/ec2.py
View file @
fa8e6530
...
@@ -283,7 +283,7 @@ class Ec2Inventory(object):
...
@@ -283,7 +283,7 @@ class Ec2Inventory(object):
else
:
else
:
dest
=
getattr
(
instance
,
self
.
destination_variable
)
dest
=
getattr
(
instance
,
self
.
destination_variable
)
if
dest
==
None
:
if
not
dest
:
# Skip instances we cannot address (e.g. private VPC subnet)
# Skip instances we cannot address (e.g. private VPC subnet)
return
return
...
@@ -303,7 +303,7 @@ class Ec2Inventory(object):
...
@@ -303,7 +303,7 @@ class Ec2Inventory(object):
self
.
push
(
self
.
inventory
,
self
.
to_safe
(
'type_'
+
instance
.
instance_type
),
dest
)
self
.
push
(
self
.
inventory
,
self
.
to_safe
(
'type_'
+
instance
.
instance_type
),
dest
)
# Inventory: Group by key pair
# Inventory: Group by key pair
if
instance
.
key_name
!=
None
:
if
instance
.
key_name
:
self
.
push
(
self
.
inventory
,
self
.
to_safe
(
'key_'
+
instance
.
key_name
),
dest
)
self
.
push
(
self
.
inventory
,
self
.
to_safe
(
'key_'
+
instance
.
key_name
),
dest
)
# Inventory: Group by security group
# Inventory: Group by security group
...
...
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