diff --git a/lib/ansible/module_utils/yumdnf.py b/lib/ansible/module_utils/yumdnf.py index 21ddf5a5a40..619fc583c9a 100644 --- a/lib/ansible/module_utils/yumdnf.py +++ b/lib/ansible/module_utils/yumdnf.py @@ -44,9 +44,7 @@ yumdnf_argument_spec = dict( update_cache=dict(type='bool', default=False, aliases=['expire-cache']), update_only=dict(required=False, default="no", type='bool'), validate_certs=dict(type='bool', default=True), - # this should not be needed, but exists as a failsafe - lock_poll=dict(type='int', default=-1), - lock_timeout=dict(type='int', default=10), + lock_timeout=dict(type='int', default=0), ), required_one_of=[['name', 'list', 'update_cache']], mutually_exclusive=[['name', 'list']], @@ -88,7 +86,6 @@ class YumDnf(with_metaclass(ABCMeta, object)): self.update_only = self.module.params['update_only'] self.update_cache = self.module.params['update_cache'] self.validate_certs = self.module.params['validate_certs'] - self.lock_poll = self.module.params['lock_poll'] self.lock_timeout = self.module.params['lock_timeout'] # It's possible someone passed a comma separated string since it used @@ -103,14 +100,14 @@ class YumDnf(with_metaclass(ABCMeta, object)): self.lockfile = '/var/run/yum.pid' def wait_for_lock(self): - '''Poll until the lock is removed if interval is a positive number''' - if (os.path.isfile(self.lockfile) or glob.glob(self.lockfile)) and self.lock_timeout > 0: - for iteration in range(0, self.lock_timeout): - time.sleep(self.lock_poll) - if not os.path.isfile(self.lockfile) or not glob.glob(self.lockfile): - break - if os.path.isfile(self.lockfile) or glob.glob(self.lockfile): - self.module.fail_json(msg='{0} lockfile was not released'.format(self.pkg_mgr_name)) + '''Poll until the lock is removed if timeout is a positive number''' + if (os.path.isfile(self.lockfile) or glob.glob(self.lockfile)): + if self.lock_timeout > 0: + for iteration in range(0, self.lock_timeout): + time.sleep(1) + if not os.path.isfile(self.lockfile) and not glob.glob(self.lockfile): + return + self.module.fail_json(msg='{0} lockfile is held by another process'.format(self.pkg_mgr_name)) def listify_comma_sep_strings_in_list(self, some_list): """ diff --git a/lib/ansible/modules/packaging/os/dnf.py b/lib/ansible/modules/packaging/os/dnf.py index 77ddaf277c2..187bc0b42da 100644 --- a/lib/ansible/modules/packaging/os/dnf.py +++ b/lib/ansible/modules/packaging/os/dnf.py @@ -176,20 +176,11 @@ options: default: "no" type: bool version_added: "2.7" - lock_poll: - description: - - Poll interval to wait for the dnf lockfile to be freed. - - "By default this is set to -1, if you set it to a positive integer it will enable to polling" - required: false - default: -1 - type: int - version_added: "2.8" lock_timeout: description: - - Amount of time to wait for the dnf lockfile to be freed - - This should be set along with C(lock_poll) to enable the lockfile polling. + - Amount of time to wait for the dnf lockfile to be freed. required: false - default: 10 + default: 0 type: int version_added: "2.8" notes: diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index 2fcc682a455..53a9996dddd 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -183,20 +183,11 @@ options: default: "no" type: bool version_added: "2.7" - lock_poll: - description: - - Poll interval to wait for the yum lockfile to be freed. - - "By default this is set to -1, if you set it to a positive integer it will enable to polling" - required: false - default: -1 - type: int - version_added: "2.8" lock_timeout: description: - - Amount of time to wait for the yum lockfile to be freed - - This should be set along with C(lock_poll) to enable the lockfile polling. + - Amount of time to wait for the yum lockfile to be freed. required: false - default: 10 + default: 0 type: int version_added: "2.8" notes: