1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/plugins/filter
Stanislav German-Evtushenko 44fd157a2b
Add filter dict_kv (#1264)
- Add filter `dict_kv` which returns a single key-value pair dictionary created from two arguments

Example 1

```
- hosts: localhost
  gather_facts: false
  vars:
    myvar: myvalue
  tasks:
  - debug:
      msg: "{{ myvar | dict_kv('thatsmyvar') }}"

OUTPUT:
ok: [localhost] => {
    "msg": {
        "thatsmyvar": "myvalue"
    }
}
```

Example 2

```
- hosts: localhost
  gather_facts: false
  vars:
    common_config:
      type: host
      database: all
    myservers:
    - server1
    - server2
  tasks:
  - debug:
      msg: "{{ myservers | map('dict_kv', 'server') | map('combine', common_config) }}"

OUTPUT:
ok: [localhost] => {
    "msg": [
        {
            "database": "all",
            "server": "server1",
            "type": "host"
        },
        {
            "database": "all",
            "server": "server2",
            "type": "host"
        }
    ]
}
```
2020-11-24 05:41:18 +01:00
..
__init__.py Initial commit 2020-03-09 09:11:07 +00:00
dict_kv.py Add filter dict_kv (#1264) 2020-11-24 05:41:18 +01:00
jc.py JC plugin (#750) 2020-08-11 09:12:17 +03:00
json_query.py modules: fix examples to use FQCN for builtin modules (#648) 2020-07-14 18:28:08 +03:00
random_mac.py Initial commit 2020-03-09 09:11:07 +00:00
time.py time_filter: improve hints in error message (#368) 2020-05-20 09:22:56 +02:00