debops / debops/debops

[question] parse_kv_items

Open
#2,287 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jinja
Stars
1.4k
Forks
379
Avg merge
4d 18h
Merged PRs (30d)
8

Description

Hello,

I try to use empty of debops.debops.parse_kv_items but it seems the result isn't expected.

- name: Manage var
  collections: ['debops.debops', 'debops.roles01',
                'debops.roles02', 'debops.roles03']
  hosts: ['my_test_host']
  vars:
    test_var:
      - name: foo
        other_param: bar
      - name: fizz
        param2: buz
    test_var_after:
      "{{ test_var | debops.debops.parse_kv_items(empty={'some_param': 'other_param', 'empty_param': ['param1', 'param2']}) }}"
  tasks:
    - name: test
      ansible.builtin.debug:
        var: test_var_after

once I run the playbook, here is the output:

TASK [test] *************************************************************************************************************
Tuesday 28 February 2023  02:27:55 +0000 (0:00:06.844)       0:00:07.572 ******
ok: [my_test_host] =>
  test_var_after:
  - id: 0
    name: foo
    other_param: bar
    real_weight: 0
    separator: false
    state: present
    weight: 0
  - empty_param: buz
    id: 10
    name: fizz
    param2: buz
    real_weight: 10
    separator: false
    state: present
    weight: 0

I thought it should have this result:

ok: [my_test_host] =>
  test_var_after:
  - id: 0
    name: foo
    other_param: bar
    real_weight: 0
    separator: false
    state: present
    weight: 0
    some_param: bar
  - empty_param: buz
    id: 10
    name: fizz
    param2: buz
    real_weight: 10
    separator: false
    state: present
    weight: 0
    empty_param: buzz

I can't see some_param or empty_param in the output. It is different with the example in https://docs.debops.org/en/latest/ansible/roles/ansible_plugins/getting-started.html

Can you please try explain how to use it?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the playbook shown in the issue and compare the result with the parse_kv_items documentation at the linked getting-started page. Clarify the documented behavior of the empty argument and update the relevant documentation if the example or explanation is incorrect.

Written by the indexing model from the issue text.

Assessment

Tech stack
yaml
Domain
devops
Issue type
Documentation
Difficulty
2/5
Estimated time
Half a day
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.