{"id":15697224,"url":"https://github.com/cytopia/ansible-filter-get_attr","last_synced_at":"2025-05-08T23:44:00.842Z","repository":{"id":147859107,"uuid":"138757535","full_name":"cytopia/ansible-filter-get_attr","owner":"cytopia","description":"Ansible filter to have variable substitution in keys and values inside dictionaries ","archived":false,"fork":false,"pushed_at":"2018-06-27T07:48:12.000Z","size":4,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-08T23:43:54.330Z","etag":null,"topics":["ansible","ansible-filters"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cytopia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-26T15:27:10.000Z","updated_at":"2022-01-18T09:00:12.000Z","dependencies_parsed_at":"2023-05-29T01:00:44.379Z","dependency_job_id":null,"html_url":"https://github.com/cytopia/ansible-filter-get_attr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytopia%2Fansible-filter-get_attr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytopia%2Fansible-filter-get_attr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytopia%2Fansible-filter-get_attr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytopia%2Fansible-filter-get_attr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cytopia","download_url":"https://codeload.github.com/cytopia/ansible-filter-get_attr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166474,"owners_count":21864467,"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","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-filters"],"created_at":"2024-10-03T19:14:19.100Z","updated_at":"2025-05-08T23:44:00.825Z","avatar_url":"https://github.com/cytopia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansible filter: get_attr\n\nThis filter overcomes Ansible's lack of variable substitution within dict keys.\n\n* Issue: https://github.com/ansible/ansible/issues/17324\n\n\n## Usage\n\n```yaml\n# Just to set some variables\n- set_fact:\n    key1: \"Name\"\n    val1: \"my-name\"\n    key2: \"tier\"\n    val2: \"dev\"\n\n# Here we actually use variables\n- set_fact:\n    key_val:\n      - key: \"{{ key1 }}\"\n        val: \"{{ val1 }}\"\n      - key: \"{{ key2 }}\"\n        val: \"{{ val2 }}\"\n\n# The filter will actually reorder the above array into a dictionary.\n- debug:\n    msg: \"{{ key_val | get_attr('key', 'val') }}\"\n```\n\nThis will result in the following output:\n```json\n{\n  \"key_val\": {\n    \"Name\": \"my-name\",\n    \"tier\": \"dev\"\n  }\n}\n```\n\n## Integration\n\nCopy `get_attr.py` into your roles `filter_plugins/` directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcytopia%2Fansible-filter-get_attr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcytopia%2Fansible-filter-get_attr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcytopia%2Fansible-filter-get_attr/lists"}