String concatenation whith stdout under with_items

12 views
Skip to first unread message

Vino B

unread,
Mar 25, 2019, 2:06:19 PM3/25/19
to Ansible Project
Hi All,

  Request your help with string concatenation whith stdout under with_items.

  - name: _List Name 
    shell: (sysls -l)
    register: sys_list
    ignore_errors: true

  - name: check System Type
    shell: (systype -t {{item.s}}|awk '{if ($3 == "not")  {print "FAILED :{{item.s}} is not set"} else {print "OK :{{item.s}} is set"}}')
 with_items:
      - { s:  "{{ sys_list.stdout_lines + [\"t1.dev.com\"] }}" }
      - { s:  "{{ sys_list.stdout_lines + [\"t1.dev.s1.com\"] }}" }

Note:
sys_list.stdout_lines : contains the string  "axe"
systype -t axe.t1.dev.com |awk '{if ($3 == "not")  {print "FAILED :{{item.s}} is not set"} else {print "OK :{{item.s}} is set"}}'
systype -t axe.t1.dev.s1.com |awk '{if ($3 == "not")  {print "FAILED :{{item.s}} is not set"} else {print "OK :{{item.s}} is set"}}'

Issue:

The above code is interpreting as below with square bracket and considering as 2 separate variables as below

V1: [axe]   V2: t1.dev.com
V1:[axe]    V2: 1.dev.s1.com

systype -t [axe],'t1.dev.com' |awk '{if ($3 == "not")  {print "FAILED :{{item.s}} is not set"} else {print "OK :{{item.s}} is set"}}'
systype -t [axe],'t1.dev.s1.com' |awk '{if ($3 == "not")  {print "FAILED :{{item.s}} is not set"} else {print "OK :{{item.s}} is set"}}'

From,
Vino.B
Reply all
Reply to author
Forward
0 new messages