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
b9afbf0e
Commit
b9afbf0e
authored
Sep 03, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorganizing the way the connection lockfile is created
parent
7034bbef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
18 deletions
+17
-18
lib/ansible/executor/task_queue_manager.py
+0
-5
lib/ansible/playbook/play_context.py
+10
-6
lib/ansible/plugins/connections/__init__.py
+7
-7
No files found.
lib/ansible/executor/task_queue_manager.py
View file @
b9afbf0e
...
@@ -23,7 +23,6 @@ import multiprocessing
...
@@ -23,7 +23,6 @@ import multiprocessing
import
os
import
os
import
socket
import
socket
import
sys
import
sys
import
tempfile
from
ansible
import
constants
as
C
from
ansible
import
constants
as
C
from
ansible.errors
import
AnsibleError
from
ansible.errors
import
AnsibleError
...
@@ -79,10 +78,6 @@ class TaskQueueManager:
...
@@ -79,10 +78,6 @@ class TaskQueueManager:
self
.
_failed_hosts
=
dict
()
self
.
_failed_hosts
=
dict
()
self
.
_unreachable_hosts
=
dict
()
self
.
_unreachable_hosts
=
dict
()
# A temporary file (opened pre-fork) used by connection plugins for
# inter-process locking.
self
.
_options
.
connection_lockfile
=
tempfile
.
TemporaryFile
()
self
.
_final_q
=
multiprocessing
.
Queue
()
self
.
_final_q
=
multiprocessing
.
Queue
()
# create the pool of worker threads, based on the number of forks specified
# create the pool of worker threads, based on the number of forks specified
...
...
lib/ansible/playbook/play_context.py
View file @
b9afbf0e
...
@@ -24,6 +24,7 @@ __metaclass__ = type
...
@@ -24,6 +24,7 @@ __metaclass__ = type
import
pipes
import
pipes
import
random
import
random
import
re
import
re
import
tempfile
from
ansible
import
constants
as
C
from
ansible
import
constants
as
C
from
ansible.errors
import
AnsibleError
from
ansible.errors
import
AnsibleError
...
@@ -161,7 +162,6 @@ class PlayContext(Base):
...
@@ -161,7 +162,6 @@ class PlayContext(Base):
_private_key_file
=
FieldAttribute
(
isa
=
'string'
,
default
=
C
.
DEFAULT_PRIVATE_KEY_FILE
)
_private_key_file
=
FieldAttribute
(
isa
=
'string'
,
default
=
C
.
DEFAULT_PRIVATE_KEY_FILE
)
_timeout
=
FieldAttribute
(
isa
=
'int'
,
default
=
C
.
DEFAULT_TIMEOUT
)
_timeout
=
FieldAttribute
(
isa
=
'int'
,
default
=
C
.
DEFAULT_TIMEOUT
)
_shell
=
FieldAttribute
(
isa
=
'string'
)
_shell
=
FieldAttribute
(
isa
=
'string'
)
_connection_lockfd
=
FieldAttribute
(
isa
=
'int'
,
default
=
None
)
# privilege escalation fields
# privilege escalation fields
_become
=
FieldAttribute
(
isa
=
'bool'
)
_become
=
FieldAttribute
(
isa
=
'bool'
)
...
@@ -200,6 +200,10 @@ class PlayContext(Base):
...
@@ -200,6 +200,10 @@ class PlayContext(Base):
self
.
password
=
passwords
.
get
(
'conn_pass'
,
''
)
self
.
password
=
passwords
.
get
(
'conn_pass'
,
''
)
self
.
become_pass
=
passwords
.
get
(
'become_pass'
,
''
)
self
.
become_pass
=
passwords
.
get
(
'become_pass'
,
''
)
# A temporary file (opened pre-fork) used by connection
# plugins for inter-process locking.
self
.
connection_lockf
=
tempfile
.
TemporaryFile
()
# set options before play to allow play to override them
# set options before play to allow play to override them
if
options
:
if
options
:
self
.
set_options
(
options
)
self
.
set_options
(
options
)
...
@@ -245,11 +249,6 @@ class PlayContext(Base):
...
@@ -245,11 +249,6 @@ class PlayContext(Base):
if
options
.
connection
:
if
options
.
connection
:
self
.
connection
=
options
.
connection
self
.
connection
=
options
.
connection
# The lock file is opened in the parent process, and the workers will
# inherit the open file, so we just need to help them find it.
if
options
.
connection_lockfile
:
self
.
connection_lockfd
=
options
.
connection_lockfile
.
fileno
()
self
.
remote_user
=
options
.
remote_user
self
.
remote_user
=
options
.
remote_user
self
.
private_key_file
=
options
.
private_key_file
self
.
private_key_file
=
options
.
private_key_file
...
@@ -328,6 +327,11 @@ class PlayContext(Base):
...
@@ -328,6 +327,11 @@ class PlayContext(Base):
return
new_info
return
new_info
def
copy
(
self
,
exclude_block
=
False
):
new_me
=
super
(
PlayContext
,
self
)
.
copy
()
new_me
.
connection_lockf
=
self
.
connection_lockf
return
new_me
def
make_become_cmd
(
self
,
cmd
,
executable
=
None
):
def
make_become_cmd
(
self
,
cmd
,
executable
=
None
):
""" helper function to create privilege escalation commands """
""" helper function to create privilege escalation commands """
...
...
lib/ansible/plugins/connections/__init__.py
View file @
b9afbf0e
...
@@ -156,12 +156,12 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
...
@@ -156,12 +156,12 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
raise
AnsibleError
(
'Incorrect
%
s password'
%
self
.
_play_context
.
become_method
)
raise
AnsibleError
(
'Incorrect
%
s password'
%
self
.
_play_context
.
become_method
)
def
lock_connection
(
self
):
def
lock_connection
(
self
):
f
=
self
.
_play_context
.
connection_lockf
d
f
=
self
.
_play_context
.
connection_lockf
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d waiting for lock on
%
d'
%
(
os
.
getpid
(),
f
))
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d waiting for lock on
%
d'
%
(
os
.
getpid
(),
f
.
fileno
()
))
fcntl
.
lockf
(
f
,
fcntl
.
LOCK_EX
)
fcntl
.
lockf
(
f
.
fileno
()
,
fcntl
.
LOCK_EX
)
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d acquired lock on
%
d'
%
(
os
.
getpid
(),
f
))
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d acquired lock on
%
d'
%
(
os
.
getpid
(),
f
.
fileno
()
))
def
unlock_connection
(
self
):
def
unlock_connection
(
self
):
f
=
self
.
_play_context
.
connection_lockf
d
f
=
self
.
_play_context
.
connection_lockf
fcntl
.
lockf
(
f
,
fcntl
.
LOCK_UN
)
fcntl
.
lockf
(
f
.
fileno
()
,
fcntl
.
LOCK_UN
)
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d released lock on
%
d'
%
(
os
.
getpid
(),
f
))
self
.
_display
.
vvvv
(
'CONNECTION: pid
%
d released lock on
%
d'
%
(
os
.
getpid
(),
f
.
fileno
()
))
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