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
917e868f
Commit
917e868f
authored
Jul 03, 2014
by
Josh Drake
Committed by
Michael DeHaan
Aug 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement fact cache flushing alongside a command-line argument to invoke it.
parent
aa419044
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
7 deletions
+32
-7
bin/ansible-playbook
+6
-1
lib/ansible/cache/__init__.py
+5
-3
lib/ansible/cache/base.py
+3
-0
lib/ansible/cache/file.py
+7
-3
lib/ansible/cache/memcached.py
+4
-0
lib/ansible/cache/memory.py
+3
-0
lib/ansible/cache/redis.py
+4
-0
No files found.
bin/ansible-playbook
View file @
917e868f
...
...
@@ -83,6 +83,8 @@ def main(args):
help
=
"start the playbook at the task matching this name"
)
parser
.
add_option
(
'--force-handlers'
,
dest
=
'force_handlers'
,
action
=
'store_true'
,
help
=
"run handlers even if a task fails"
)
parser
.
add_option
(
'--flush-cache'
,
dest
=
'flush_cache'
,
action
=
'store_true'
,
help
=
"flush to fact cache"
)
options
,
args
=
parser
.
parse_args
(
args
)
...
...
@@ -191,6 +193,10 @@ def main(args):
force_handlers
=
options
.
force_handlers
)
if
options
.
flush_cache
:
display
(
callbacks
.
banner
(
"FLUSHING FACT CACHE"
))
pb
.
SETUP_CACHE
.
flush
()
if
options
.
listhosts
or
options
.
listtasks
or
options
.
syntax
:
print
''
print
'playbook:
%
s'
%
playbook
...
...
@@ -313,4 +319,3 @@ if __name__ == "__main__":
except
KeyboardInterrupt
,
ke
:
display
(
"ERROR: interrupted"
,
color
=
'red'
,
stderr
=
True
)
sys
.
exit
(
1
)
lib/ansible/cache/__init__.py
View file @
917e868f
...
...
@@ -50,10 +50,12 @@ class FactCache(MutableMapping):
return
len
(
self
.
_plugin
.
keys
())
def
copy
(
self
):
"""
Return a primitive copy of the keys and values from the cache.
"""
""" Return a primitive copy of the keys and values from the cache. """
return
dict
([(
k
,
v
)
for
(
k
,
v
)
in
self
.
iteritems
()])
def
keys
(
self
):
return
self
.
_plugin
.
keys
()
def
flush
(
self
):
""" Flush the fact cache of all keys. """
self
.
_plugin
.
flush
()
lib/ansible/cache/base.py
View file @
917e868f
...
...
@@ -13,3 +13,6 @@ class BaseCacheModule(object):
def
delete
(
self
,
key
):
raise
NotImplementedError
(
"Subclasses of {} must implement the '{}' method"
.
format
(
self
.
__class__
.
__name__
,
self
.
__name__
))
def
flush
(
self
):
raise
NotImplementedError
(
"Subclasses of {} must implement the '{}' method"
.
format
(
self
.
__class__
.
__name__
,
self
.
__name__
))
lib/ansible/cache/file.py
View file @
917e868f
...
...
@@ -47,13 +47,13 @@ class CacheModule(MemoryCacheModule):
def
set
(
self
,
*
args
,
**
kwargs
):
super
(
CacheModule
,
self
)
.
set
(
*
args
,
**
kwargs
)
self
.
f
lush
()
self
.
f
sync
()
def
delete
(
self
,
*
args
,
**
kwargs
):
super
(
CacheModule
,
self
)
.
delete
(
*
args
,
**
kwargs
)
self
.
f
lush
()
self
.
f
sync
()
def
f
lush
(
self
):
def
f
sync
(
self
):
temp
=
tempfile
.
TemporaryFile
(
'r+b'
)
try
:
...
...
@@ -63,3 +63,7 @@ class CacheModule(MemoryCacheModule):
shutil
.
copyfileobj
(
temp
,
f
)
finally
:
temp
.
close
()
def
flush
(
self
):
super
(
CacheModule
,
self
)
.
flush
()
self
.
fsync
()
lib/ansible/cache/memcached.py
View file @
917e868f
...
...
@@ -110,3 +110,7 @@ class CacheModule(BaseCacheModule):
def
delete
(
self
,
key
):
self
.
_cache
.
delete
(
self
.
_make_key
(
key
))
self
.
_keys
.
discard
(
key
)
def
flush
(
self
):
for
key
in
self
.
keys
():
self
.
delete
(
key
)
lib/ansible/cache/memory.py
View file @
917e868f
...
...
@@ -35,3 +35,6 @@ class CacheModule(object):
def
delete
(
self
,
key
):
del
self
.
_cache
[
key
]
def
flush
(
self
):
self
.
_cache
=
{}
lib/ansible/cache/redis.py
View file @
917e868f
...
...
@@ -106,3 +106,7 @@ class CacheModule(BaseCacheModule):
def
delete
(
self
,
key
):
self
.
_cache
.
delete
(
self
.
_make_key
(
key
))
self
.
_cache
.
zrem
(
self
.
_keys_set
,
key
)
def
flush
(
self
):
for
key
in
self
.
keys
():
self
.
delete
(
key
)
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