Re: [ansible-project] Adding a nested xml element using ansible xml module fails

2019-04-22 Thread Aliaa Yusuf
 
check this it worked with me
https://github.com/cmprescott/ansible-xml/issues/95
 
بتاريخ الجمعة، 30 مارس، 2018 6:55:21 ص UTC+2، كتب Uvindra Dias Jayasinha:
>
> Thanks Kai
>
> On Wednesday, March 28, 2018 at 6:36:58 PM UTC+5:30, Kai Stian Olstad 
> wrote:
>>
>> On Wednesday, 28 March 2018 07.26.14 CEST 'Uvindra Dias Jayasinha' via 
>> Ansible Project wrote: 
>> > Im using Ansible 2.5 on Ubuntu 17.10 
>> > 
>> > Given the following xml file 
>> > 
>> >  
>> >
>> >
>> >  
>> > 
>> > 
>> > Trying to add nested elements so that the file is changed to the 
>> following 
>> > output fails. 
>> > 
>> >  
>> >
>> >  
>> > Old Rasputin 
>> > 2000 
>> >  
>> >
>> >  
>> > 
>> > 
>> > Here is the playbook I used 
>> > 
>> > - name: Add several more beers with the year of manufacture nested 
>> >   xml: 
>> > path: /foo/bar.xml 
>> > xpath: /business/beers 
>> > add_children: 
>> > - beer: 
>> >   - name: Old Rasputin 
>> >   - year: 2000 
>> > 
>> > I see the following exception, 
>> > 
>> > An exception occurred during task execution. To see the full traceback, 
>> use  -vvv. The error was: TypeError: Argument must be bytes or unicode, 
>> got 'list' 
>> > fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": 
>> "Traceback (most recent call last):\n  File 
>> \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", 
>> > line 860, in \nmain()\n  File 
>> \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 840, in main\n 
>> > add_target_children(module, doc, xpath, namespaces, add_children, 
>> input_type)\n  File \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 
>> 409, in add_target_children\n 
>> > new_kids = children_to_nodes(module, children, in_type)\n  File 
>> \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 651, in 
>> children_to_nodes\n 
>> > return [child_to_element(module, child, type) for child in children]\n 
>>  File \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 639, in 
>> child_to_element\n 
>> > node.text = value\n  File \"src/lxml/etree.pyx\", line 1030, in 
>> lxml.etree._Element.text.__set__\n  File \"src/lxml/apihelpers.pxi\", line 
>> 716, in lxml.etree._setNodeText\n   
>> > File \"src/lxml/apihelpers.pxi\", line 704, in 
>> lxml.etree._createTextNode\n  File \"src/lxml/apihelpers.pxi\", line 1442, 
>> in lxml.etree._utf8\nTypeError: Argument must be bytes or unicode, got 
>> 'list'\n", 
>> > "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1} 
>> > 
>> > Is this supported or am I missing something here? 
>>
>> To my knowledge you can't create children's children in one task. 
>> You need to create beer first in one task and then name and year in a 
>> separate task. 
>>
>> -- 
>> Kai Stian Olstad 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7055fa74-39e7-475b-9167-69bcebdcddfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Adding a nested xml element using ansible xml module fails

2018-03-29 Thread 'Uvindra Dias Jayasinha' via Ansible Project
Thanks Kai

On Wednesday, March 28, 2018 at 6:36:58 PM UTC+5:30, Kai Stian Olstad wrote:
>
> On Wednesday, 28 March 2018 07.26.14 CEST 'Uvindra Dias Jayasinha' via 
> Ansible Project wrote: 
> > Im using Ansible 2.5 on Ubuntu 17.10 
> > 
> > Given the following xml file 
> > 
> >  
> >
> >
> >  
> > 
> > 
> > Trying to add nested elements so that the file is changed to the 
> following 
> > output fails. 
> > 
> >  
> >
> >  
> > Old Rasputin 
> > 2000 
> >  
> >
> >  
> > 
> > 
> > Here is the playbook I used 
> > 
> > - name: Add several more beers with the year of manufacture nested 
> >   xml: 
> > path: /foo/bar.xml 
> > xpath: /business/beers 
> > add_children: 
> > - beer: 
> >   - name: Old Rasputin 
> >   - year: 2000 
> > 
> > I see the following exception, 
> > 
> > An exception occurred during task execution. To see the full traceback, 
> use  -vvv. The error was: TypeError: Argument must be bytes or unicode, 
> got 'list' 
> > fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": 
> "Traceback (most recent call last):\n  File 
> \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", 
> > line 860, in \nmain()\n  File 
> \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 840, in main\n 
> > add_target_children(module, doc, xpath, namespaces, add_children, 
> input_type)\n  File \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 
> 409, in add_target_children\n 
> > new_kids = children_to_nodes(module, children, in_type)\n  File 
> \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 651, in 
> children_to_nodes\n 
> > return [child_to_element(module, child, type) for child in children]\n 
>  File \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 639, in 
> child_to_element\n 
> > node.text = value\n  File \"src/lxml/etree.pyx\", line 1030, in 
> lxml.etree._Element.text.__set__\n  File \"src/lxml/apihelpers.pxi\", line 
> 716, in lxml.etree._setNodeText\n   
> > File \"src/lxml/apihelpers.pxi\", line 704, in 
> lxml.etree._createTextNode\n  File \"src/lxml/apihelpers.pxi\", line 1442, 
> in lxml.etree._utf8\nTypeError: Argument must be bytes or unicode, got 
> 'list'\n", 
> > "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1} 
> > 
> > Is this supported or am I missing something here? 
>
> To my knowledge you can't create children's children in one task. 
> You need to create beer first in one task and then name and year in a 
> separate task. 
>
> -- 
> Kai Stian Olstad 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/94851fc5-0a29-421e-86e7-587be61ca630%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Adding a nested xml element using ansible xml module fails

2018-03-28 Thread Kai Stian Olstad
On Wednesday, 28 March 2018 07.26.14 CEST 'Uvindra Dias Jayasinha' via Ansible 
Project wrote:
> Im using Ansible 2.5 on Ubuntu 17.10
> 
> Given the following xml file
> 
> 
>   
>   
> 
> 
> 
> Trying to add nested elements so that the file is changed to the following 
> output fails.
> 
> 
>   
> 
> Old Rasputin
> 2000
> 
>   
> 
> 
> 
> Here is the playbook I used
> 
> - name: Add several more beers with the year of manufacture nested
>   xml:
> path: /foo/bar.xml
> xpath: /business/beers
> add_children:
> - beer: 
>   - name: Old Rasputin
>   - year: 2000
> 
> I see the following exception,
> 
> An exception occurred during task execution. To see the full traceback, use   
>-vvv. The error was: TypeError: Argument must be bytes or unicode, got 
> 'list'
> fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback 
> (most recent call last):\n  File 
> \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", 
> line 860, in \nmain()\n  File 
> \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 840, in main\n
> add_target_children(module, doc, xpath, namespaces, add_children, 
> input_type)\n  File \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 409, 
> in add_target_children\n
> new_kids = children_to_nodes(module, children, in_type)\n  File 
> \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 651, in 
> children_to_nodes\n
> return [child_to_element(module, child, type) for child in children]\n  File 
> \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 639, in 
> child_to_element\n
> node.text = value\n  File \"src/lxml/etree.pyx\", line 1030, in 
> lxml.etree._Element.text.__set__\n  File \"src/lxml/apihelpers.pxi\", line 
> 716, in lxml.etree._setNodeText\n  
> File \"src/lxml/apihelpers.pxi\", line 704, in lxml.etree._createTextNode\n  
> File \"src/lxml/apihelpers.pxi\", line 1442, in lxml.etree._utf8\nTypeError: 
> Argument must be bytes or unicode, got 'list'\n", 
> "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
> 
> Is this supported or am I missing something here?

To my knowledge you can't create children's children in one task.
You need to create beer first in one task and then name and year in a separate 
task. 

-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6957465.PspIIlo9u4%40x1.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Adding a nested xml element using ansible xml module fails

2018-03-27 Thread 'Uvindra Dias Jayasinha' via Ansible Project
Im using Ansible 2.5 on Ubuntu 17.10

Given the following xml file


  
  



Trying to add nested elements so that the file is changed to the following 
output fails.


  

Old Rasputin
2000

  



Here is the playbook I used

- name: Add several more beers with the year of manufacture nested
  xml:
path: /foo/bar.xml
xpath: /business/beers
add_children:
- beer: 
  - name: Old Rasputin
  - year: 2000

I see the following exception,

An exception occurred during task execution. To see the full traceback, use 
 -vvv. The error was: TypeError: Argument must be bytes or unicode, got 'list'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback 
(most recent call last):\n  File \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", 
line 860, in \nmain()\n  File 
\"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 840, in main\n
add_target_children(module, doc, xpath, namespaces, add_children, input_type)\n 
 File \"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 409, in 
add_target_children\n
new_kids = children_to_nodes(module, children, in_type)\n  File 
\"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 651, in children_to_nodes\n 
   
return [child_to_element(module, child, type) for child in children]\n  File 
\"/tmp/ansible_sv9JSC/ansible_module_xml.py\", line 639, in child_to_element\n  
  
node.text = value\n  File \"src/lxml/etree.pyx\", line 1030, in 
lxml.etree._Element.text.__set__\n  File \"src/lxml/apihelpers.pxi\", line 716, 
in lxml.etree._setNodeText\n  
File \"src/lxml/apihelpers.pxi\", line 704, in lxml.etree._createTextNode\n  
File \"src/lxml/apihelpers.pxi\", line 1442, in lxml.etree._utf8\nTypeError: 
Argument must be bytes or unicode, got 'list'\n", 
"module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}

Is this supported or am I missing something here?



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b7ec94f0-276a-4a0d-83eb-6cd316da79e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.