'Generate the public key..'

def generate(self, module):

    if ((not os.path.exists(self.path)) or self.force):
        try:
            privatekey_content = open(self.privatekey_path, 'r').read()
            privatekey = crypto.load_privatekey(crypto.FILETYPE_PEM, privatekey_content)
            publickey_file = open(self.path, 'w')
            publickey_file.write(crypto.dump_publickey(crypto.FILETYPE_PEM, privatekey))
            publickey_file.close()
        except (IOError, OSError):
            e = get_exception()
            raise PublicKeyError(e)
        except AttributeError:
            self.remove()
            raise PublicKeyError('You    need    to    have    PyOpenSSL>=16.0.0    to    generate    public    keys')
    else:
        self.changed = False
    file_args = module.load_file_common_arguments(module.params)
    if module.set_fs_attributes_if_different(file_args, False):
        self.changed = True
