Print Element of List in msg: of Ansible

29 views
Skip to first unread message

Mahmut Aydın

unread,
Mar 20, 2020, 6:09:31 AM3/20/20
to Ansible Project
Hello Dear All,

I have below  playbook. There is also output of this playbook bottom. I want to print  elements  of below bold list variable. Could you please help me for this how to do?

---
- name: Build Switch Config
  hosts: cvp
  connection: local
  gather_facts: no


  tasks:
    - name: "collecting facts from CVP {{inventory_hostname}}"
      arista.cvp.cv_facts:
        facts:
          containers
    - name: "Print out facts from CVP"
      debug:

        msg:
          - "CONTAINERS NAME is : {{item.name}}"
          - " IT HAS BELOW CONTAINER_CONFIGLETS :"
          - " {{item.configlets}}"
      with_items: "{{containers}}"
      loop_control:
        label: "{item.name}}"

***************************************************
[root@centos7 ansible]# ansible-playbook test_facts.yml 

PLAY [Build Switch Config] **************************************************************************************************************************************************************************************************************

TASK [collecting facts from CVP 172.16.91.3] ********************************************************************************************************************************************************************************************
ok: [172.16.91.3]

TASK [Print out facts from CVP] *********************************************************************************************************************************************************************************************************
ok: [172.16.91.3] => (item={item.name}}) => {
    "msg": [
        "CONTAINERS NAME is : Tenant", 
        " IT HAS BELOW CONTAINER_CONFIGLETS :", 
        " []"
    ]
}
ok: [172.16.91.3] => (item={item.name}}) => {
    "msg": [
        "CONTAINERS NAME is : Spine", 
        " IT HAS BELOW CONTAINER_CONFIGLETS :", 
        " [u'Mahmut_Leaf_Initial', u'SYS_TelemetryBuilderV2', u'Mahmut_Spine_Builder']"
    ]
}
ok: [172.16.91.3] => (item={item.name}}) => {
    "msg": [
        "CONTAINERS NAME is : Leaf", 
        " IT HAS BELOW CONTAINER_CONFIGLETS :", 
        " [u'Mahmut_Leaf_Initial', u'SYS_TelemetryBuilderV3', u'Mahmut_Leaf_Builder']"
    ]
}
ok: [172.16.91.3] => (item={item.name}}) => {
    "msg": [
        "CONTAINERS NAME is : Internet", 
        " IT HAS BELOW CONTAINER_CONFIGLETS :", 
        " [u'Mahmut_Leaf_Initial', u'SYS_TelemetryBuilderV2', u'Mahmut_Internet_Builderv2']"
    ]
}
ok: [172.16.91.3] => (item={item.name}}) => {
    "msg": [
        "CONTAINERS NAME is : Undefined", 
        " IT HAS BELOW CONTAINER_CONFIGLETS :", 
        " []"
    ]
}

Mahmut Aydın

unread,
Mar 20, 2020, 5:17:42 PM3/20/20
to ansible...@googlegroups.com
Hi

Any help please

Mahmut Aydın <mahmuta...@gmail.com>, 20 Mar 2020 Cum, 13:09 tarihinde şunu yazdı:
--
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/26717a7a-4c19-440a-9746-bc883dff934e%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages