The Input Which i passed
*client_nfs_export_server_string_ui: '172.11.12.13, 127.0.0.1 , test123.kp.org'* there is some space before and after strings , which i require to trim and create a fresh list. expected output ok: [localhost] => { "msg": [ "172.11.12.13", "127.0.0.1", "test123.kp.org", "myserver.nndc.kp.org" ] } On Friday, May 19, 2023 at 12:14:08 AM UTC+5:30 javed khan Siddque wrote: > Hi Dick, > > screenshots missed from my side. > here we go. > > > - name: "Converting String Input From - > client_nfs_export_server_string > In A List After trim/split by comma -> client_nfs_export_server_list" > ansible.builtin.set_fact: > server_list: "{{ item | trim }}" > client_nfs_export_server_list: "{{ client_nfs_export_server_list | > default([]) + ['{{ server_list }}'] }}" > loop: "{{ client_nfs_export_server_string_ui.split(',') }}" > > > - name: "Print client_nfs_export_server_list Once" > ansible.builtin.debug: > msg: "{{ client_nfs_export_server_list }}" > > > > > ok: [cnpdcstore117.ctolab.kp.org] => (item=172.11.12.13) => { > 528 > "ansible_facts": { > 529 > "client_nfs_export_server_list": [ > 530 > "{{ server_list }}" > 531 > ], > 532 > "server_list": "172.11.12.13" > 533 > }, > 534 > "ansible_loop_var": "item", > 535 > "changed": false, > 536 > "item": "172.11.12.13" > 537 > } > 538 > ok: [cnpdcstore117.ctolab.kp.org] => (item= 127.0.0.1 ) => { > 539 > "ansible_facts": { > 540 > "client_nfs_export_server_list": [ > 541 > "172.11.12.13", > 542 > "{{ server_list }}" > 543 > ], > 544 > "server_list": "127.0.0.1" > 545 > }, > 546 > "ansible_loop_var": "item", > 547 > "changed": false, > 548 > "item": " 127.0.0.1 " > 549 > } > 550 > ok: [cnpdcstore117.ctolab.kp.org] => (item= test123.kp.org) => { > 551 > "ansible_facts": { > 552 > "client_nfs_export_server_list": [ > 553 > "172.11.12.13", > 554 > "{{ server_list }}", > 555 > "{{ server_list }}" > 556 > ], > 557 > "server_list": "test123.kp.org" > 558 > }, > 559 > "ansible_loop_var": "item", > 560 > "changed": false, > 561 > "item": " test123.kp.org" > 562 > } > 563 > > > > > TASK [isilon_allocation_for_KPHC_environment : Print > client_nfs_export_server_list Once] *** > 00:01:11 > 565 > task path: > /tmp/bwrap_1228189_9zrqk15v/awx_1228189_9shz6zke/project/roles/xxxxxxx/tasks/main.yml:25 > 566 > ok: [cnpdcstore117.ctolab.kp.org] => { > 567 > "msg": [ > 568 > "172.11.12.13", > 569 > "{{ server_list }}", > 570 > "{{ server_list }}" > 571 > ] > 572 > } > 573 > META: ending play > 574 > > On Thursday, May 18, 2023 at 11:41:46 PM UTC+5:30 javed khan Siddque wrote: > >> Hi Team, >> >> i am trying to convert a dummy String with list but skipping the first >> iteration >> i am getting below output >> >> *"client_nfs_export_server_list": * >> >> >> >> >> >> *[ "127.0.0.1", "test123.kp.org >> <http://test123.kp.org>", "myserver.nndc.kp.org >> <http://myserver.nndc.kp.org>", "{{ item | trim }}" ]* >> >> >> >> skipping the first iteration >> >> >> -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/59e7a996-a262-48aa-8932-402755133c70n%40googlegroups.com.