Skip to main content

Nested structure diff library with dot-path notation for Ansible

Project description

Nested structure diff library with dot-path notation for Ansible.

License: MIT

Description

This package is built to plug into Ansible’s module_utils, which doesn’t require it to be installed on managed remote hosts, only the controller. It will be picked up by Ansiballz, which zips a module’s dependencies and ships it over SSH. The library is kept small to keep the footprint down.

Usage

By design, the algorithm will ignore any keys that are omitted on the right (the target), to allow an API endpoint to choose plausible defaults. For example, an API client implementing this library will diff the desired state with a JSON REST resource to predict whether or not a REST call needs to occur for the user’s changes to be applied.

from ansible.module_utils.dotdiff import dotdiff

orig = { ‘one’: ‘one’,

‘two’: ‘two’ }

dest = { ‘one’: ‘another’,

‘three’: ‘three’ }

dotdiff(orig, dest)

dotdiff() yields a list of DiffEntry objects:

[one: “one” => “another”, three: “<undefined>” => “three”]

Keys that would be added to the structure in this transaction have their values marked as ‘<undefined>’.

Nested lists and dictionaries are supported at an arbitrary level and will be indicated using dot-separated paths. Changing a list’s member count will yield a DiffEntry indicating a change in cardinality with a pound (#) sign.

mylist.#: “3” => “4”

This visualization is inspired by Terraform.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansible-dotdiff-0.1.5.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

ansible_dotdiff-0.1.5-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ansible-dotdiff-0.1.5.tar.gz.

File metadata

  • Download URL: ansible-dotdiff-0.1.5.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.2

File hashes

Hashes for ansible-dotdiff-0.1.5.tar.gz
Algorithm Hash digest
SHA256 fb78560d8d885e0fdb3d473cf9ad4e5ccb83386b70c9bf33dbd1723bc151ec3b
MD5 b217a0b179fea06a797fa6b930ed99a8
BLAKE2b-256 71ea6f29f7db6f0137338df3a4b73816ad68fc9292a1fef95c0ee4a2b093d3ac

See more details on using hashes here.

File details

Details for the file ansible_dotdiff-0.1.5-py2.py3-none-any.whl.

File metadata

  • Download URL: ansible_dotdiff-0.1.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.2

File hashes

Hashes for ansible_dotdiff-0.1.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4d48706b7d01a4cc22f808d43889290ab25f41fd131ba69e8c9af719d290dc23
MD5 ecea25211ece3d4b0bc4a8b166a9fb37
BLAKE2b-256 f80408e6f634e02852edb53897fddd5042b6f0fc8c63d6c7349fae5ac20bdf08

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page