Skip to content

Fix MTU value type coercion in network config serialization#16

Closed
andrew-jones wants to merge 1 commit into
mainfrom
aj-fix-mtu-must-be-int
Closed

Fix MTU value type coercion in network config serialization#16
andrew-jones wants to merge 1 commit into
mainfrom
aj-fix-mtu-must-be-int

Conversation

@andrew-jones
Copy link
Copy Markdown
Contributor

The _config variable is a string resembling a YAML/Python dict literal. Without explicit parsing, Ansible's implicit type coercion was converting the integer mtu: 1500 into the string "1500" when serialized to JSON. Adding | from_yaml before | to_json ensures the value is first parsed into a proper Python dict, preserving mtu as an integer.

Changes

  • Add from_yaml filter before to_json in create_network.yaml so that numeric fields like mtu are serialized with their correct types (e.g. "mtu": 1500 instead of "mtu": "1500")

…iteral. Without from_yaml, Ansible's implicit type coercion was stringifying the integer 1500 during the conversion. Adding | from_yaml explicitly parses that string into a proper Python dict first, which preserves mtu as an integer 1500. Then | to_json serializes it to "mtu": 1500 (not "1500").
Copy link
Copy Markdown
Contributor

@agonzalezrh agonzalezrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use new EE generated last Friday

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