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
b93f27e2
Commit
b93f27e2
authored
Sep 03, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the lockfile back to tqm to make sure it stays unique
parent
ba658ff3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
12 deletions
+14
-12
lib/ansible/executor/task_queue_manager.py
+4
-1
lib/ansible/playbook/play_context.py
+3
-4
lib/ansible/plugins/connections/__init__.py
+7
-7
No files found.
lib/ansible/executor/task_queue_manager.py
View file @
b93f27e2
...
...
@@ -23,6 +23,7 @@ import multiprocessing
import
os
import
socket
import
sys
import
tempfile
from
ansible
import
constants
as
C
from
ansible.errors
import
AnsibleError
...
...
@@ -86,6 +87,8 @@ class TaskQueueManager:
except
ValueError
:
fileno
=
None
self
.
_connection_lockfile
=
tempfile
.
TemporaryFile
()
self
.
_workers
=
[]
for
i
in
range
(
self
.
_options
.
forks
):
main_q
=
multiprocessing
.
Queue
()
...
...
@@ -176,7 +179,7 @@ class TaskQueueManager:
new_play
=
play
.
copy
()
new_play
.
post_validate
(
templar
)
play_context
=
PlayContext
(
new_play
,
self
.
_options
,
self
.
passwords
)
play_context
=
PlayContext
(
new_play
,
self
.
_options
,
self
.
passwords
,
self
.
_connection_lockfile
.
fileno
()
)
for
callback_plugin
in
self
.
_callback_plugins
:
if
hasattr
(
callback_plugin
,
'set_play_context'
):
callback_plugin
.
set_play_context
(
play_context
)
...
...
lib/ansible/playbook/play_context.py
View file @
b93f27e2
...
...
@@ -24,7 +24,6 @@ __metaclass__ = type
import
pipes
import
random
import
re
import
tempfile
from
ansible
import
constants
as
C
from
ansible.errors
import
AnsibleError
...
...
@@ -190,7 +189,7 @@ class PlayContext(Base):
_step
=
FieldAttribute
(
isa
=
'bool'
,
default
=
False
)
_diff
=
FieldAttribute
(
isa
=
'bool'
,
default
=
False
)
def
__init__
(
self
,
play
=
None
,
options
=
None
,
passwords
=
None
):
def
__init__
(
self
,
play
=
None
,
options
=
None
,
passwords
=
None
,
connection_lockfd
=
None
):
super
(
PlayContext
,
self
)
.
__init__
()
...
...
@@ -202,7 +201,7 @@ class PlayContext(Base):
# A temporary file (opened pre-fork) used by connection
# plugins for inter-process locking.
self
.
connection_lockf
=
tempfile
.
TemporaryFile
()
self
.
connection_lockf
d
=
connection_lockfd
# set options before play to allow play to override them
if
options
:
...
...
@@ -329,7 +328,7 @@ class PlayContext(Base):
def
copy
(
self
,
exclude_block
=
False
):
new_me
=
super
(
PlayContext
,
self
)
.
copy
()
new_me
.
connection_lockf
=
self
.
connection_lockf
new_me
.
connection_lockf
d
=
self
.
connection_lockfd
return
new_me
def
make_become_cmd
(
self
,
cmd
,
executable
=
None
):
...
...
lib/ansible/plugins/connections/__init__.py
View file @
b93f27e2
...
...
@@ -156,12 +156,12 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
raise
AnsibleError
(
'Incorrect
%
s password'
%
self
.
_play_context
.
become_method
)
def
lock_connection
(
self
):
f
=
self
.
_play_context
.
connection_lockf
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d waiting for lock on
%
d'
%
(
os
.
getpid
(),
f
.
fileno
()
))
fcntl
.
lockf
(
f
.
fileno
()
,
fcntl
.
LOCK_EX
)
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d acquired lock on
%
d'
%
(
os
.
getpid
(),
f
.
fileno
()
))
f
=
self
.
_play_context
.
connection_lockf
d
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d waiting for lock on
%
d'
%
(
os
.
getpid
(),
f
))
fcntl
.
lockf
(
f
,
fcntl
.
LOCK_EX
)
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d acquired lock on
%
d'
%
(
os
.
getpid
(),
f
))
def
unlock_connection
(
self
):
f
=
self
.
_play_context
.
connection_lockf
fcntl
.
lockf
(
f
.
fileno
()
,
fcntl
.
LOCK_UN
)
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d released lock on
%
d'
%
(
os
.
getpid
(),
f
.
fileno
()
))
f
=
self
.
_play_context
.
connection_lockf
d
fcntl
.
lockf
(
f
,
fcntl
.
LOCK_UN
)
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d released lock on
%
d'
%
(
os
.
getpid
(),
f
))
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