{"id":19647846,"url":"https://github.com/nl2go/ansible-filter","last_synced_at":"2025-10-04T02:03:33.817Z","repository":{"id":57410527,"uuid":"232339122","full_name":"nl2go/ansible-filter","owner":"nl2go","description":"Contains Ansible related filter set for collection/object operations. Aims to extend the official Ansible Filters.","archived":false,"fork":false,"pushed_at":"2020-04-15T14:11:48.000Z","size":43,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-25T11:26:25.349Z","etag":null,"topics":["ansible","ansible-plugin","hetzner","hetzner-robot-api","pypi"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nl2go.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-07T14:13:39.000Z","updated_at":"2024-04-05T14:34:08.000Z","dependencies_parsed_at":"2022-08-28T01:14:04.047Z","dependency_job_id":null,"html_url":"https://github.com/nl2go/ansible-filter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/nl2go/ansible-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nl2go%2Fansible-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nl2go%2Fansible-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nl2go%2Fansible-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nl2go%2Fansible-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nl2go","download_url":"https://codeload.github.com/nl2go/ansible-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nl2go%2Fansible-filter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254466,"owners_count":25956604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-plugin","hetzner","hetzner-robot-api","pypi"],"created_at":"2024-11-11T14:46:13.688Z","updated_at":"2025-10-04T02:03:33.781Z","avatar_url":"https://github.com/nl2go.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Travis (.com) branch](https://img.shields.io/travis/com/nl2go/ansible-filter/master)](https://travis-ci.com/nl2go/ansible-filter)\n[![Codecov](https://img.shields.io/codecov/c/github/nl2go/ansible-filter)](https://codecov.io/gh/nl2go/ansible-filter)\n[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/nl2go/ansible-filter)](https://codeclimate.com/github/nl2go/ansible-filter)\n[![PyPI](https://img.shields.io/pypi/v/ansible-filter)](https://pypi.org/project/ansible-filter/#history)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/ansible-filter)](https://pypi.org/project/ansible-filter/#files)\n\n# Ansible Filter\n\nContains [Ansible](https://www.ansible.com/) related filter set for collection/object operations. Aims to extend the official\n[Ansible Filters](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html).\n\nAvailable filters are listed [below](#filters).\n\n## Install\n\n### PyPI\n\n    pip install -U ansible-filter\n\n### Source\n\n    git clone git@github.com:nl2go/ansible-filter.git\n    cd ansible-filter/\n    pip install .\n\n## Filters\n\n### Change Set\nComputes the change set between a list of objects using a key attribute non-recursively.\n\nThe filter arguments `local` and `origin` are non-associative. Objects present at the `origin` but missing\nwithin `local` are considered non managed.\n\nThe result is a change set with a map of lists to:\n\n- `create` - objects to create at `origin`\n- `update` - objects to update at `origin`\n- `delete` - objects to delete at `origin`\n- `noop` - objects with no operation required\n\nUseful to interact with any kind of a stateful API.\n\n\n    from ansible_filter import change_set\n    \n    local = [{ 'id': 1, 'foo': 'bar' }, { 'id': 2, 'foo': 'foo' }, { 'id': 3, 'foz':'baz' }, { 'id': 4, 'state': 'absent' }]\n    origin = [{ 'id': 2, 'foo': 'bar' }, { 'id': 3, 'foz':'baz' }, { 'id': 4, 'x': 'y' }, { 'id': 5, 'foo': 'bar' }]\n    \n    result = change_set.change_set(local, origin, 'id')\n    print(result)  \n    \n    [\n        'create': [{ 'id': 1, 'foo': 'bar' }],\n        'update': [{ 'id': 2, 'foo': 'foo' }],\n        'delete': [{ 'id': 4, 'x': 'y' }],\n        'noop': [{ 'id': 3, 'foz': 'baz' }],\n    ]\n\n### Form URL Encode\nEncodes arbitrary objects to form URL format.\n\n    from ansible_filter import form_urlencode\n    \n    obj = { 'foo': 'bar', 'foz': ['baz'] }\n    \n    result = form_urlencode.form_urlencode(obj)\n    print(result)\n\n    foo=bar\u0026foz[0]=baz\u0026\n\n### Pick\nFilters a list of objects retaining attributes only matching the names passed as argument, non-recursively.\n\n    from ansible_filter import pick\n    \n    elements = [{ 'foo': 'bar', 'foz': 'baz' }]\n    \n    result = pick.pick(elements, ['foo'])\n    print(result)\n\n    [{ 'foo': 'bar' }]\n    \n### Omit\nFilters a list objects omitting attributes matching the names passed as argument, non-recursively.    \n\n    from ansible_filter import omit\n    \n    elements = [{ 'foo': 'bar', 'foz': 'baz' }]\n    \n    result = omit.omit(elements, ['foo'])\n    print(result)\n\n    [{ 'foz': 'baz' }]\n\n### Group By\nGroups elements by key attribute.\n\n    from ansible_filter import group_by\n    \n    left = [{ 'id': '1', 'foo': 'a' }, { 'id': '2', 'foz': 'x' }]\n    right = [{ 'id': '1', 'foo': 'b' }, { 'id': '2', 'foz': 'y' }]\n    \n    result = group_by.group_by(left, right, 'id')\n    print(result)\n\n    [\n        { 'id': '1', 'group': [{ 'id': '1', 'foo': 'a' }, { 'id': '1', 'foo': 'b' }] }, \n        { 'id': '2', 'group': [{ 'id': '2', 'foz': 'x' }, { 'id': '2', 'foz': 'y' }] }\n    ]\n\n### List 2 Dict\nConverts a list to dict by key attribute.\n\n    from ansible_filter import list_to_dict\n    \n    elements = [{ 'id': '1', 'foo': 'bar' }, { 'id': '2', 'foz': 'baz' }]\n    \n    result = list_to_dict.list_to_dict(elements, 'id')\n    print(result)\n    \n    {'1': {'foo': 'bar', 'id': '1'}, '2': {'id': '2', 'foz': 'baz'}}\n\n### Point to Point Connections\nResolves point to point connections between the local and remote hosts.\n\n    from ansible_filter import network\n    \n    remote_hostnames = ['two', 'three']\n    hostname = 'one'\n    hostvars = {\n        'one': {\n            'ansible_default_ipv4': {\n                'interface': 'eth0'\n            },\n            'ansible_eth0': {\n                'ipv4': {\n                    'address': '127.0.0.1',\n                }\n            }\n        },\n        'two': {\n            'ansible_default_ipv4': {\n                'interface': 'eth0'\n            },\n            'ansible_eth0': {\n                'ipv4': {\n                    'address': '127.0.0.2',\n                }\n            }\n        },\n        'three': {\n            'ansible_default_ipv4': {\n                'interface': 'eth0'\n            },\n            'ansible_eth0': {\n                'ipv4': {\n                    'address': '127.0.0.3',\n                }\n            }        \n        }\n    }\n    \n    result = network.get_point_to_point_connections(remote_hostnames, hostname, hostvars)\n\n    [\n      {\n        'remote': {\n          'interface': 'eth0',\n          'hostname': 'two',\n          'address': '127.0.0.2'\n        },\n        'local': {\n          'interface': 'eth0',\n          'hostname': 'one',\n          'address': '127.0.0.1'\n        }\n      },\n      {\n        'remote': {\n          'interface': 'eth0',\n          'hostname': 'three',\n          'address': '127.0.0.3'\n        },\n        'local': {\n          'interface': 'eth0',\n          'hostname': 'one',\n          'address': '127.0.0.1'\n        }\n      }\n    ]\n\n## Links\n\n*   Website: https://newsletter2go.com/\n*   License: [MIT](https://github.com/nl2go/ansible-filter/blob/master/LICENSE.md)\n*   Releases: https://pypi.org/project/ansible-filter/\n*   Code: https://github.com/nl2go/ansible-filter\n*   Issue tracker: https://github.com/nl2go/ansible-filter/issues\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnl2go%2Fansible-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnl2go%2Fansible-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnl2go%2Fansible-filter/lists"}