mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -07:00
openssl_privatekey: Standardize implementaton of the module
The OpenSSLObject class has been merged[1]. This commit makes the openssl_privatekey rely on this class and standardize the way openssl module should be written. Co-Authored-By: Christian Pointner <cpointner@mgit.at> [1] https://github.com/ansible/ansible/pull/26945
This commit is contained in:
parent
9c50933a80
commit
d72ac0b391
3 changed files with 74 additions and 50 deletions
|
@ -95,11 +95,20 @@ class OpenSSLObject(object):
|
|||
self.changed = False
|
||||
self.check_mode = check_mode
|
||||
|
||||
@abc.abstractmethod
|
||||
def check(self):
|
||||
def check(self, module, perms_required=True):
|
||||
"""Ensure the resource is in its desired state."""
|
||||
|
||||
pass
|
||||
def _check_state():
|
||||
return os.path.exists(self.path)
|
||||
|
||||
def _check_perms(module):
|
||||
file_args = module.load_file_common_arguments(module.params)
|
||||
return not module.set_fs_attributes_if_different(file_args, False)
|
||||
|
||||
if not perms_required:
|
||||
return _check_state()
|
||||
|
||||
return _check_state() and _check_perms(module)
|
||||
|
||||
@abc.abstractmethod
|
||||
def dump(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue