univention / ansible-modules

Ansible Modules for UCS
GNU General Public License v3.0
11 stars 6 forks source link

univention_directory_module: Can't set attribute value with ":" #8

Closed Daenou closed 1 year ago

Daenou commented 1 year ago

When trying to set a value to a translation* udm property I get an error.

Code:

---
- name: Test UDM
  hosts: testhost
  tasks:
    - name: UDM
      univention.ucs_modules.univention_directory_manager:
        module: "settings/extended_attribute"
        dn: "cn=owncloudgroup,cn=custom attributes,cn=univention,dc=school,dc=ch"
        position: "cn=custom attributes,cn=univention,dc=school,dc=ch"
        set_properties: 
          - property: CLIName
            value: OwnCloudGroup
          - property: groupName
            value: school-Cloud
          - property: groupPosition
            value: "1"
          - property: ldapMapping
            value: customAttributeOwnCloudGroup
          - property: longDescription
            value: "school-Cloud activate, use 0 or 1 (customAttributeOwnCloudGroup)"
          - property: mayChange
            value: "1"
          - property: module 
            value: groups/group
          - property: multivalue
            value: "0"
          - property: name
            value: owncloudgroup
          - property: objectClass
            value: customAttributeGroups
          - property: shortDescription
            value: customAttributeOwnCloudGroup
          - property: tabName
            value: ICT
          - property: tabPosition
            value: "1"
          - property: translationGroupName
            value: 'de_DE: school-Cloud'
          - property: translationLongDescription
            value: 'de_DE: school-Cloud aktivieren, 0 oder 1 verwenden (customAttributeOwnCloudGroup)'
          - property: translationShortDescription
            value: 'de_DE: customAttributeOwnCloudGroup'

No error in check mode, but as soon as I run it without I get the following error:

univention.admin.uexeptions.valueInvalidSyntax: translationLongDescription: too many arguments

But this is the official syntax that works with udm.

s3lph commented 1 year ago

I couldn't figure out where in udm-cli parsing with the : delimiter happens, but I was able to figure out how to provide the parsed options to python-udm directly from ansible (extended with en_US translation to demonstrate the syntax):

---
- name: Test UDM
  hosts: testhost
  tasks:
    - name: UDM
      univention.ucs_modules.univention_directory_manager:
        module: "settings/extended_attribute"
        dn: "cn=owncloudgroup,cn=custom attributes,cn=univention,dc=school,dc=ch"
        position: "cn=custom attributes,cn=univention,dc=school,dc=ch"
        set_properties: 
          # ...
          - property: translationGroupName
            value: [['de_DE', 'school-Cloud'], ['en_US', 'school Cloud']]
          - property: translationLongDescription
            value: [['de_DE', 'school-Cloud aktivieren, 0 oder 1 verwenden (customAttributeOwnCloudGroup)'], ['en_US', 'Enable school cloud, use 0 or 1 (customAttributeOwnCloudGroup)']]
          - property: translationShortDescription
            value: [['de_DE', 'customAttributeOwnCloudGroup'], ['en_US', 'customAttributeOwnCloudGroup']]

A documentation PR will follow.

spaceone commented 1 year ago

UDM doesn't parse :. The CLI accepts e.g. --append translationLongDescription='"de_DE" "school-Cloud aktivieren, 0 oder 1 verwenden (customAttributeOwnCloudGroup)"'

Daenou commented 1 year ago

Documentation has been improved, closing.