Esempio n. 1
0
    def check_groups_exist(self):
        # Checks to see if groups specified already exist or not
        if self.groups is not None:
            try:
                groups = [group['groupid'] for group in pvesh.get("access/groups")]
                return set(self.groups).issubset(set(groups))
            except ProxmoxShellError as e:
                self.module.fail_json(msg=e.message, status_code=e.status_code)

        return True
    def __init__(self, module):
        self.module = module
        self.name = module.params['name']
        self.privileges = module.params['privileges']
        self.state = module.params['state']

        try:
            self.existing_roles = pvesh.get("access/roles")
        except ProxmoxShellError as e:
            self.module.fail_json(msg=e.message, status_code=e.status_code)

        self.parse_roles()
Esempio n. 3
0
    def __init__(self, module):
        self.module = module
        self.path = module.params['path']
        self.state = module.params['state']
        self.roles = module.params['roles']
        self.groups = module.params['groups']
        self.users = module.params['users']

        try:
            self.existing_acl = pvesh.get("access/acl")
        except ProxmoxShellError as e:
            self.module.fail_json(msg=e.message, status_code=e.status_code)

        self.parse_acls()
def main():
    module = AnsibleModule(argument_spec=dict(query=dict(type='str',
                                                         required=True,
                                                         aliases=['name']), ),
                           supports_check_mode=True)

    result = {"changed": False}

    try:
        result['response'] = pvesh.get(module.params['query'])
    except ProxmoxShellError as e:
        if e.data:
            result["response"] = e.data

        module.fail_json(msg=e.message, status_code=e.status_code, **result)

    module.exit_json(**result)
    def __init__(self, module):
        self.module = module
        self.path = module.params['path']
        self.state = module.params['state']
        self.roles = module.params['roles']
        self.groups = module.params['groups']
        self.users = module.params['users']

        try:
            self.existing_acl = pvesh.get("access/acl")
        except ProxmoxShellError as e:
            self.module.fail_json(msg=e.message, status_code=e.status_code)

        # PVE 5.x (unnecessarily) uses a string for this value. This ensures
        # that it's an integer for when we compare values later.
        for acl in self.existing_acl:
            acl['propagate'] = int(acl['propagate'])

        self.parse_acls()
Esempio n. 6
0
    def __init__(self, module):
        self.module = module
        self.name = module.params['name']
        self.state = module.params['state']
        self.type = module.params['type']
        self.disable = module.params['disable']
        self.content = module.params['content']
        self.nodes = module.params['nodes']
        self.path = module.params['path']
        self.pool = module.params['pool']
        self.monhost = module.params['monhost']
        self.username = module.params['username']
        self.krbd = module.params['krbd']
        self.maxfiles = module.params['maxfiles']
        self.server = module.params['server']
        self.export = module.params['export']
        self.options = module.params['options']
        self.vgname = module.params['vgname']
        self.thinpool = module.params['thinpool']

        try:
            self.existing_storages = pvesh.get("storage")
        except ProxmoxShellError as e:
            self.module.fail_json(msg=e.message, status_code=e.status_code)
Esempio n. 7
0
 def lookup(self):
     try:
         return pvesh.get("access/users/{}".format(self.name))
     except ProxmoxShellError as e:
         self.module.fail_json(msg=e.message, status_code=e.status_code)