ansible-middleware / ansible-middleware/common

module xml failing when running with jinja2_native=True and value is a number

Aperta
#26 2 commenti 0 reazioni 1 assegnatario Rivendicata da @RanabirChakraborty Vedi su GitHub
good first issue Hacktoberfest
Lingua principale
Python
Stelle
3
Fork
7
Merge medio
4g 8h
PR unite (30g)
3

Descrizione

##### SUMMARY
Setting `jinja2_native=True` in ansible.cfg and run the following playbook:
```yaml
- name: all
hosts: localhost
gather_facts: no
become: no

vars:
myval: 255

tasks:
- redhat.runtimes_common.xml:
path: test.xml
xpath: "/business/rating"
value: "{{ myval }}"
pretty_print: true
```
results in:
```
TASK [redhat.runtimes_common.xml] *******************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: Argument must be bytes or unicode, got 'int'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/cmaso/.ansible/tmp/ansible-tmp-1728972733.6213477-1779995-35690117152941/AnsiballZ_xml.py\", line 107, in \n _ansiballz_main()\n File \"/home/cmaso/.ansible/tmp/ansible-tmp-1728972733.6213477-1779995-35690117152941/AnsiballZ_xml.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/cmaso/.ansible/tmp/ansible-tmp-1728972733.6213477-1779995-35690117152941/AnsiballZ_xml.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.redhat.runtimes_common.plugins.modules.xml', init_globals=dict(_module_fqn='ansible_collections.redhat.runtimes_common.plugins.modules.xml', _modlib_path=modlib_path),\n File \"/usr/lib64/python3.9/runpy.py\", line 225, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib64/python3.9/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib64/python3.9/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_redhat.runtimes_common.xml_payload_i_tmacpd/ansible_redhat.runtimes_common.xml_payload.zip/ansible_collections/redhat/runtimes_common/plugins/modules/xml.py\", line 1018, in \n File \"/tmp/ansible_redhat.runtimes_common.xml_payload_i_tmacpd/ansible_redhat.runtimes_common.xml_payload.zip/ansible_collections/redhat/runtimes_common/plugins/modules/xml.py\", line 1004, in main\n File \"/tmp/ansible_redhat.runtimes_common.xml_payload_i_tmacpd/ansible_redhat.runtimes_common.xml_payload.zip/ansible_collections/redhat/runtimes_common/plugins/modules/xml.py\", line 708, in set_target\n File \"/tmp/ansible_redhat.runtimes_common.xml_payload_i_tmacpd/ansible_redhat.runtimes_common.xml_payload.zip/ansible_collections/redhat/runtimes_common/plugins/modules/xml.py\", line 694, in set_target_inner\n File \"src/lxml/etree.pyx\", line 1024, in lxml.etree._Element.text.__set__\n File \"src/lxml/apihelpers.pxi\", line 748, in lxml.etree._setNodeText\n File \"src/lxml/apihelpers.pxi\", line 736, in lxml.etree._createTextNode\n File \"src/lxml/apihelpers.pxi\", line 1539, in lxml.etree._utf8\nTypeError: Argument must be bytes or unicode, got 'int'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
```

Not totally positive if that can/should be treated as a bug (module docu says that `value` must be a string), maybe it should be reported as a feature request?

##### ISSUE TYPE
- Bug Report

##### ANSIBLE VERSION

```
ansible [core 2.14.14]
config file = /home/cmaso/test/xml/ansible.cfg
configured module search path = ['/home/cmaso/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /home/cmaso/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.9.18 (main, Jul 3 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
```

##### COLLECTION VERSION

```
redhat.amq_broker 2.2.5
redhat.runtimes_common 1.2.2
```

##### EXPECTED RESULTS

Module `xml` may be extended to allow more basic types (e.g. int, boolean, etc) for parameter `value`.

##### ACTUAL RESULTS

```

```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.