VARIABLE IS NOT DEFINED when trying to register output in playbook

15,935

You are using the debug: module with the option var: and this expects a variable, not a jinja2 template.

So either change it to:

debug:
  var: item.members

or

debug:
  msg: "{{ item.members }}"
Share:
15,935
Jota
Author by

Jota

Updated on June 28, 2022

Comments

  • Jota
    Jota almost 2 years

    I'm trying to register a variable with the output to a query of a F5 pool and I'm getting this error:

    "<type 'list'>": "VARIABLE IS NOT DEFINED!", 
    

    What is that I'm doing wrong? Any help appreciated. Thanks!

    ---
    - name: GRAB F5 FACTS
      hosts: f5
      connection: local
      gather_facts: no
      tasks:
        - name: Collect BIG-IP facts
          bigip_device_facts:
            gather_subset: ltm-pools
            provider: "{{ prov }}"
          register: bigip_device_facts
    
        - name: FACTS OUTPUT
          debug:
            var: "{{ item.members | rejectattr('state', 'match', '^present$') | map(attribute='name') | list }}"
          register: jkout
          with_items: "{{ bigip_device_facts.ltm_pools }}" 
          when: item.full_path  == "/Common/mypool"
    
        - name: Set a variable
          debug:
            msg: "jkvar={{ jkout }}"