Ansible filter to read or write LDIF.
Project description
Ansible filter to read or write LDIF.
Install this Ansible Filter:
via pip:
pip install ansible-filters-ldif
via ansible-galaxy:
ansible-galaxy install 'git+https://github.com/atterdag/ansible-filters-ldif.git'
Ansible filters always runs on localhost.
Examples
Convert dictionary to LDIF
---
- name: Create dictionary with entries
set_fact:
dictionary:
- - dc=example,dc=com
- dc:
- example
description:
- This is a line longer than 79 characters, so LDIF breaks it up over multiple lines
o:
- example.com
objectClass:
- dcObject
- organization
- - ou=people,dc=example,dc=com
- objectClass:
- organizationalUnit
ou:
- people
- - cn=Jane Doe,ou=people,dc=example,dc=com
- cn:
- Jane Doe
mail:
- jane.doe@example.com
objectClass:
- inetOrgPerson
sn:
- Doe
- - cn=John Doe,ou=people,dc=example,dc=com
- cn:
- John Doe
mail:
- john.doe@example.com
objectClass:
- inetOrgPerson
sn:
- Doe
- - ou=groups,dc=example,dc=com
- objectClass:
- organizationalUnit
ou:
- groups
- - cn=users,ou=groups,dc=example,dc=com
- cn:
- users
member:
- cn=Jane Doe,ou=people,dc=example,dc=com
- cn=John Doe,ou=people,dc=example,dc=com
objectClass:
- groupOfNames
- name: "Convert dictionary to LDIF while writing it to /tmp/test.ldif using 'to_ldif' filter"
copy:
content: "{{ dictionary | to_ldif }}"
dest: "/tmp/test.ldif"
Convert LDIF to JSON
---
- name: "Create multi-line string variable with LDIF data"
set_fact:
ldif: |
dn: dc=example,dc=com
dc: example
description: This is one line which is longer than
79 characters, so LDIF breaks it up over multiple lines
objectClass: dcObject
objectClass: organization
o: example.com
dn: ou=people,dc=example,dc=com
objectClass: organizationalUnit
ou: people
dn: cn=Jane Doe,ou=people,dc=example,dc=com
objectClass: inetOrgPerson
cn: Jane Doe
sn: Doe
mail: jane.doe@example.com
dn: cn=John Doe,ou=people,dc=example,dc=com
objectClass: inetOrgPerson
cn: John Doe
sn: Doe
mail: john.doe@example.com
dn: ou=groups,dc=example,dc=com
objectClass: organizationalUnit
ou: groups
dn: cn=users,ou=groups,dc=example,dc=com
objectClass: groupOfNames
cn: users
member: cn=Jane Doe,ou=people,dc=example,dc=com
member: cn=John Doe,ou=people,dc=example,dc=com
- name: "Convert string to JSON whiĺe writing it to /tmp/test.json using 'from_ldif' filter"
copy:
content: "{{ (ldif | from_ldif) | to_nice_json }}"
dest: "/tmp/test.json"
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ansible-filters-ldif-0.0.8.tar.gz
(18.5 kB
view hashes)
Built Distribution
Close
Hashes for ansible-filters-ldif-0.0.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f823be371146838ae3fb72460f758cfa4f84d3fff8d1a75caf54238a027ae24 |
|
MD5 | 34931f86474f61a802d73248c3eec1df |
|
BLAKE2b-256 | 882f331b713654cce1163ea29a060181bf777ba23e111dcb31728c4467a6e408 |
Close
Hashes for ansible_filters_ldif-0.0.8-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f0f278550df7cd4bd8a384283007a1c4c25e09bbc02c4b558a0b45a6363ebda |
|
MD5 | 3f630d86681b9f5d7ab0b7ce505b511f |
|
BLAKE2b-256 | 508078f9d5df9df4a3f66a9a1130a659d7b8a9e23c207c1863e26069e544f404 |