Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make plugin work with native Jinja2 #29

Closed
wants to merge 1 commit into from

Conversation

Erik-Lamers1
Copy link

When enabling jinja2_native the update and replace functionality breaks with the following message:

JSON data for schema node must start with an object or with a list: Parse error on line 1: "{\n   ...

My understanding is that this happens because Jinja struggles to parse the raw types in the plugin. When changing these types to their proper type; dict the plugin works with jinja2_native enabled.

Steps to reproduce:

  • Set the following in your ansible.cfg
jinja2_native = true

Full error:

fatal: [hostname]: FAILED! => {
    "changed": false,
    "id": "2024-08-26 12:01:58:293448",
    "invocation": {
        "module_args": {
            "confirm_timeout": null,
            "datastore": "candidate",
            "delete": null,
            "replace": [
                {
                    "action": "replace",
                    "path": "/",
                   "value": "{\n <config>
                }
            ],
            "save_when": "never",
            "update": null,
            "yang_models": "srl"
        }
    },
    "method": "diff"
}

MSG:

JSON data for schema node must start with an object or with a list: Parse error on line 1: "{\n   <config>
Input:
'"{\n<config>

@hellt
Copy link
Member

hellt commented Aug 26, 2024

Hi @Erik-Lamers1

Unfortunately setting the type to dict would prevent a user to use the following:

- name: Set descr
  hosts: clab
  gather_facts: false
  tasks:
    - name: Set description
      nokia.srlinux.config:
        update:
          - path: /interface[name=mgmt0]/description
            value: "test setting description"

(and this is why the tests are failing)

What if you set the type to json and not dict, would that help?

And how do you benefit from having jinja_native mode?

@Erik-Lamers1
Copy link
Author

Ah thanks for the explanation @hellt, I wasn't aware that this value had mixed type.

We use jinja native with some playbooks since another ansible plugin requires this setting to work properly.
For now I will hack this in with local fork, let me close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants