mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 06:30:19 -07:00
Introduce a connection locking infrastructure
The lock file is (a temporary file) opened in the parent process, whose open fd is inherited by the workers after fork, and passed down through the PlayContext. Connection grows lock/unlock methods which can be used by individual connection plugins.
This commit is contained in:
parent
88d3751c28
commit
5887e96b27
3 changed files with 21 additions and 0 deletions
|
@ -161,6 +161,7 @@ class PlayContext(Base):
|
|||
_private_key_file = FieldAttribute(isa='string', default=C.DEFAULT_PRIVATE_KEY_FILE)
|
||||
_timeout = FieldAttribute(isa='int', default=C.DEFAULT_TIMEOUT)
|
||||
_shell = FieldAttribute(isa='string')
|
||||
_connection_lockfd= FieldAttribute(isa='int', default=None)
|
||||
|
||||
# privilege escalation fields
|
||||
_become = FieldAttribute(isa='bool')
|
||||
|
@ -244,6 +245,11 @@ class PlayContext(Base):
|
|||
if 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.private_key_file = options.private_key_file
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue