# Passing a VAR Between Playbook Tasks

**URL:** <https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203>\
**Category:** Get Help\
**Created:** [January 27, 2026, 8:23pm UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203 "2026-01-27T20:23:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![clerambeau370](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/clerambeau370/32/10260_2.png) [@clerambeau370](https://forum.ansible.com/u/clerambeau370)\
**Post date:** [January 27, 2026, 8:23pm UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/1 "2026-01-27T20:23:24Z")

</div>

Hello. The community here has been outstanding. There is always someone to help. That is very much appreciated.  
I have a problem. I need to pas a part of a long variable to another task withing the same playbook.  
Here is the logic:

> Go to ServiceNow, get a Change Request SYS\_ID for any new change request with the word DCR (Data Change Request). Pass its SYS\_ID (which is a unique identifier for an Incident or a Task or a Change Request) to the following task which is to download the attachment to disk

If I run it with the first task getting the SYS\_ID , then debugging it out, then manually pasting it into the second task, that works fine:

```auto
---
    - name: Oracle database Data Change Request Process ID 2872.56
      hosts: dbservers
      gather_facts: true
      vars_files:
        - vars/main.yml

      tasks:

        - name: Display Ansible date_time fact and register | itsm_dcr
          delegate_to: localhost
          run_once: true
          set_fact: 
            currenttime: "{{ ansible_date_time.iso8601 }}"
          tags: linux

        - name: Retrieve new DCR change requestso
          servicenow.itsm.change_request_info:
             instance:
               host: "{{ sn_instance}}"
               username: "{{ sn_username }}"
               password: "{{ sn_password }}"
             query:
              - state: = new
                short_description: LIKE DCR
# - state: = new
# assigned_to: = bertie.luby
          register: dcr_new_cr_request_found_out
          delegate_to: localhost

        - name: Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr
          debug: var=dcr_new_cr_request_found_out

############################### lockfile####################################

        - name: Download the DCR scripts to server on {{ ansible_date_time.date }}
          servicenow.itsm.attachment:
            instance:
              host: "{{ sn_instance}}"
              username: "{{ sn_username }}"
              password: "{{ sn_password }}"
            dest: /runtime/dcr/dcr5.sql
            sys_id: fbc38e4483b6f210f28198c6feaad3c3
# sys_id: "{{ dcr_new_cr_request_found_out.record.sys_id }}"
          register: dcr_new_change_request_download_status_out
# delegate_to: localhost

        - name: Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr
          debug: var=dcr_new_change_request_download_status_out

```

The output is:

```auto
[ansible_admin@ctrl ansible]$ ansible-playbook ./playbooks/dcr_download_attachment4.yml 

PLAY [Oracle database Data Change Request Process ID 2872.56] *****************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [192.168.1.112]
[WARNING]: Using run_once with the free strategy is not currently supported. This task will still be executed for every host in the inventory list.

TASK [Display Ansible date_time fact and register | itsm_dcr] *****************************************************************************************************************************************************
ok: [192.168.1.112 -> localhost]

TASK [Retrieve new DCR change requestso] **************************************************************************************************************************************************************************
[WARNING]: Encountered unknown value while mapping field risk.
[WARNING]: Encountered unknown value Software while mapping field category.
ok: [192.168.1.112 -> localhost]

TASK [Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr] *********************************************************************************************************************************
ok: [192.168.1.112] => {
    "dcr_new_cr_request_found_out": {
        "changed": false,
        "failed": false,
        "records": [
            {
                "active": "true",
                "activity_due": "",
                "additional_assignee_list": "",
                "approval": "approved",
                "approval_history": "",
                "approval_set": "2026-01-27 19:29:50",
                "assigned_to": "3c589a008334f210f28198c6feaad375",
                "assignment_group": "db53580b0a0a0a6501aa37c294a2ba6b",
                "attachments": [
                    {
                        "average_image_color": "",
                        "chunk_size_bytes": "700000",
                        "compressed": "true",
                        "content_type": "text/x-sql",
                        "download_link": "https://dev276659.service-now.com/api/now/attachment/33c38e4483b6f210f28198c6feaad3c1/file",
                        "file_name": "DCR_001.sql",
                        "hash": "be2477f129a827a656c0b76392edbfa4b10568341786837b5f67ba7a25abb359",
                        "image_height": "",
                        "image_width": "",
                        "size_bytes": "141",
                        "size_compressed": "146",
                        "state": "available",
                        "sys_created_by": "admin",
                        "sys_created_on": "2026-01-27 19:29:41",
                        "sys_id": "33c38e4483b6f210f28198c6feaad3c1",
                        "sys_mod_count": "1",
                        "sys_tags": "",
                        "sys_updated_by": "system",
                        "sys_updated_on": "2026-01-27 19:29:43",
                        "table_name": "change_request",
                        "table_sys_id": "34a34e0883f6f210f28198c6feaad380"
                    },
                    {
                        "average_image_color": "",
                        "chunk_size_bytes": "700000",
                        "compressed": "true",
                        "content_type": "text/x-sql",
                        "download_link": "https://dev276659.service-now.com/api/now/attachment/fbc38e4483b6f210f28198c6feaad3c2/file",
                        "file_name": "DCR_002.sql",
                        "hash": "495a9dfd6868afb81786f3edb5183ebbde68fe136395373d7bacabb1fa36c24a",
                        "image_height": "",
                        "image_width": "",
                        "size_bytes": "76",
                        "size_compressed": "92",
                        "state": "available",
                        "sys_created_by": "admin",
                        "sys_created_on": "2026-01-27 19:29:41",
                        "sys_id": "fbc38e4483b6f210f28198c6feaad3c2",
                        "sys_mod_count": "1",
                        "sys_tags": "",
                        "sys_updated_by": "system",
                        "sys_updated_on": "2026-01-27 19:29:43",
                        "table_name": "change_request",
                        "table_sys_id": "34a34e0883f6f210f28198c6feaad380"
                    },
                    {
                        "average_image_color": "",
                        "chunk_size_bytes": "700000",
                        "compressed": "true",
                        "content_type": "text/x-sql",
                        "download_link": "https://dev276659.service-now.com/api/now/attachment/fbc38e4483b6f210f28198c6feaad3c3/file",
                        "file_name": "DCR_003.sql",
                        "hash": "468948ef7571706b68865cb9617fa979decc5664d30353742f03c024c0e6f3c5",
                        "image_height": "",
                        "image_width": "",
                        "size_bytes": "148",
                        "size_compressed": "141",
                        "state": "available",
                        "sys_created_by": "admin",
                        "sys_created_on": "2026-01-27 19:29:42",
                        "sys_id": "fbc38e4483b6f210f28198c6feaad3c3",
                        "sys_mod_count": "1",
                        "sys_tags": "",
                        "sys_updated_by": "system",
                        "sys_updated_on": "2026-01-27 19:29:43",
                        "table_name": "change_request",
                        "table_sys_id": "34a34e0883f6f210f28198c6feaad380"
                    },
                    {
                        "average_image_color": "",
                        "chunk_size_bytes": "700000",
                        "compressed": "true",
                        "content_type": "text/x-sql",
                        "download_link": "https://dev276659.service-now.com/api/now/attachment/c8d38e4483b6f210f28198c6feaad3c4/file",
                        "file_name": "DCR_004_controlled_failure.sql",
                        "hash": "5d48a20d5bd0003a1d3bad56aa43127b33b4274f55978e6404aeb1b49d602aa1",
                        "image_height": "",
                        "image_width": "",
                        "size_bytes": "264",
                        "size_compressed": "198",
                        "state": "available",
                        "sys_created_by": "admin",
                        "sys_created_on": "2026-01-27 19:29:42",
                        "sys_id": "c8d38e4483b6f210f28198c6feaad3c4",
                        "sys_mod_count": "1",
                        "sys_tags": "",
                        "sys_updated_by": "system",
                        "sys_updated_on": "2026-01-27 19:29:43",
                        "table_name": "change_request",
                        "table_sys_id": "34a34e0883f6f210f28198c6feaad380"
                    }
                ],
                "backout_plan": "",
                "business_duration": "",
                "business_service": "281a4d5fc0a8000b00e4ba489a83eedc",
                "cab_date_time": "",
                "cab_delegate": "",
                "cab_recommendation": "",
                "cab_required": "false",
                "calendar_duration": "",
                "category": "Software",
                "change_plan": "",
                "chg_model": "007c4001c343101035ae3f52c1d3aeb2",
                "close_code": "",
                "close_notes": "",
                "closed_at": "",
                "closed_by": "",
                "cmdb_ci": "0c43d5e2c61122750182c132a8b9e2d9",
                "comments": "",
                "comments_and_work_notes": "",
                "company": "",
                "conflict_last_run": "",
                "conflict_status": "Not Run",
                "contact_type": "",
                "contract": "",
                "copied_from": "",
                "correlation_display": "",
                "correlation_id": "",
                "delivery_plan": "",
                "delivery_task": "",
                "description": "--- Managed by r-able.com hyperautomation (TurboCharged, V2.2.2). Do not change manually. Do not deviate. ---\r\n--- This Change Request adds a new deployment to an already installed GoldenGate hub binaries ---\r\n--- Enter the required parameters on the right side of the \":\" below ---\r\nRun dcr\r\n",
                "due_date": "",
                "end_date": "",
                "escalation": "0",
                "expected_start": "",
                "follow_up": "",
                "group_list": "",
                "impact": "low",
                "implementation_plan": "",
                "justification": "",
                "knowledge": "false",
                "location": "",
                "made_sla": "true",
                "number": "CHG0030971",
                "on_hold": false,
                "on_hold_reason": "",
                "on_hold_task": "",
                "opened_at": "2026-01-27 19:28:56",
                "opened_by": "6816f79cc0a8016401c5a33be04be441",
                "order": "",
                "outside_maintenance_schedule": "false",
                "parent": "",
                "phase": "requested",
                "phase_state": "open",
                "priority": "low",
                "production_system": "false",
                "reason": "",
                "reassignment_count": "0",
                "requested_by": "6816f79cc0a8016401c5a33be04be441",
                "requested_by_date": "",
                "review_comments": "",
                "review_date": "",
                "review_status": "",
                "risk": "",
                "risk_impact_analysis": "",
                "route_reason": "",
                "scope": "3",
                "service_offering": "04b89573835e7210f28198c6feaad3f0",
                "short_description": "DCR",
                "sla_due": "",
                "start_date": "",
                "state": "new",
                "std_change_producer_version": "",
                "sys_class_name": "change_request",
                "sys_created_by": "admin",
                "sys_created_on": "2026-01-27 19:29:50",
                "sys_domain": "global",
                "sys_domain_path": "/",
                "sys_id": "34a34e0883f6f210f28198c6feaad380",
                "sys_mod_count": "0",
                "sys_tags": "",
                "sys_updated_by": "admin",
                "sys_updated_on": "2026-01-27 19:29:50",
                "task_effective_number": "CHG0030971",
                "test_plan": "",
                "time_worked": "",
                "type": "normal",
                "unauthorized": "false",
                "universal_request": "",
                "upon_approval": "proceed",
                "upon_reject": "cancel",
                "urgency": "low",
                "user_input": "",
                "watch_list": "",
                "work_end": "",
                "work_notes": "",
                "work_notes_list": "",
                "work_start": ""
            }
        ],
        "warnings": [
            "Encountered unknown value while mapping field risk.",
            "Encountered unknown value Software while mapping field category."
        ]
    }
}

TASK [Download the DCR scripts to server on 2026-01-27] ***********************************************************************************************************************************************************
changed: [192.168.1.112]

TASK [Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr] *********************************************************************************************************************************
ok: [192.168.1.112] => {
    "dcr_new_change_request_download_status_out": {
        "changed": true,
        "failed": false,
        "record": {
            "elapsed": 0.21,
            "msg": "OK",
            "size": 148,
            "status_code": 200
        }
    }
}

PLAY RECAP ********************************************************************************************************************************************************************************************************
192.168.1.112 : ok=6 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   

```

However, when I change the playbook to the desired state, with the SYS\_ID being passed between the tasks as a “sys\_id: “{{ dcr\_new\_cr\_request\_found\_out.record.sys\_id }}””, it fails.

The desired, but error state:

```auto
---
    - name: Oracle database Data Change Request Process ID 2872.56
      hosts: dbservers
      gather_facts: true
      vars_files:
        - vars/main.yml

      tasks:

        - name: Display Ansible date_time fact and register | itsm_dcr
          delegate_to: localhost
          run_once: true
          set_fact: 
            currenttime: "{{ ansible_date_time.iso8601 }}"
          tags: linux

        - name: Retrieve new DCR change requestso
          servicenow.itsm.change_request_info:
             instance:
               host: "{{ sn_instance}}"
               username: "{{ sn_username }}"
               password: "{{ sn_password }}"
             query:
              - state: = new
                short_description: LIKE DCR
# - state: = new
# assigned_to: = bertie.luby
          register: dcr_new_cr_request_found_out
          delegate_to: localhost

        - name: Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr
          debug: var=dcr_new_cr_request_found_out

############################### lockfile####################################

        - name: Download the DCR scripts to server on {{ ansible_date_time.date }}
          servicenow.itsm.attachment:
            instance:
              host: "{{ sn_instance}}"
              username: "{{ sn_username }}"
              password: "{{ sn_password }}"
            dest: /runtime/dcr/dcr3.sql
# sys_id: fbc38e4483b6f210f28198c6feaad3c3
            sys_id: "{{ dcr_new_cr_request_found_out.record.sys_id }}"
          register: dcr_new_change_request_download_status_out
# delegate_to: localhost

        - name: Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr
          debug: var=dcr_new_change_request_download_status_out

```

The output:

```auto
[ansible_admin@ctrl ansible]$ ansible-playbook ./playbooks/dcr_download_attachment5.yml 

PLAY [Oracle database Data Change Request Process ID 2872.56] *****************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [192.168.1.112]
[WARNING]: Using run_once with the free strategy is not currently supported. This task will still be executed for every host in the inventory list.

TASK [Display Ansible date_time fact and register | itsm_dcr] *****************************************************************************************************************************************************
ok: [192.168.1.112 -> localhost]

TASK [Retrieve new DCR change requestso] **************************************************************************************************************************************************************************
[WARNING]: Encountered unknown value while mapping field risk.
[WARNING]: Encountered unknown value Software while mapping field category.
ok: [192.168.1.112 -> localhost]

TASK [Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr] *********************************************************************************************************************************
ok: [192.168.1.112] => {
    "dcr_new_cr_request_found_out": {
        "changed": false,
        "failed": false,
        "records": [
            {
                "active": "true",
                "activity_due": "",
                "additional_assignee_list": "",
                "approval": "approved",
                "approval_history": "",
                "approval_set": "2026-01-27 19:29:50",
                "assigned_to": "3c589a008334f210f28198c6feaad375",
                "assignment_group": "db53580b0a0a0a6501aa37c294a2ba6b",
                "attachments": [
                    {
                        "average_image_color": "",
                        "chunk_size_bytes": "700000",
                        "compressed": "true",
                        "content_type": "text/x-sql",
                        "download_link": "https://dev276659.service-now.com/api/now/attachment/33c38e4483b6f210f28198c6feaad3c1/file",
                        "file_name": "DCR_001.sql",
                        "hash": "be2477f129a827a656c0b76392edbfa4b10568341786837b5f67ba7a25abb359",
                        "image_height": "",
                        "image_width": "",
                        "size_bytes": "141",
                        "size_compressed": "146",
                        "state": "available",
                        "sys_created_by": "admin",
                        "sys_created_on": "2026-01-27 19:29:41",
                        "sys_id": "33c38e4483b6f210f28198c6feaad3c1",
                        "sys_mod_count": "1",
                        "sys_tags": "",
                        "sys_updated_by": "system",
                        "sys_updated_on": "2026-01-27 19:29:43",
                        "table_name": "change_request",
                        "table_sys_id": "34a34e0883f6f210f28198c6feaad380"
                    },
                    {
                        "average_image_color": "",
                        "chunk_size_bytes": "700000",
                        "compressed": "true",
                        "content_type": "text/x-sql",
                        "download_link": "https://dev276659.service-now.com/api/now/attachment/fbc38e4483b6f210f28198c6feaad3c2/file",
                        "file_name": "DCR_002.sql",
                        "hash": "495a9dfd6868afb81786f3edb5183ebbde68fe136395373d7bacabb1fa36c24a",
                        "image_height": "",
                        "image_width": "",
                        "size_bytes": "76",
                        "size_compressed": "92",
                        "state": "available",
                        "sys_created_by": "admin",
                        "sys_created_on": "2026-01-27 19:29:41",
                        "sys_id": "fbc38e4483b6f210f28198c6feaad3c2",
                        "sys_mod_count": "1",
                        "sys_tags": "",
                        "sys_updated_by": "system",
                        "sys_updated_on": "2026-01-27 19:29:43",
                        "table_name": "change_request",
                        "table_sys_id": "34a34e0883f6f210f28198c6feaad380"
                    },
                    {
                        "average_image_color": "",
                        "chunk_size_bytes": "700000",
                        "compressed": "true",
                        "content_type": "text/x-sql",
                        "download_link": "https://dev276659.service-now.com/api/now/attachment/fbc38e4483b6f210f28198c6feaad3c3/file",
                        "file_name": "DCR_003.sql",
                        "hash": "468948ef7571706b68865cb9617fa979decc5664d30353742f03c024c0e6f3c5",
                        "image_height": "",
                        "image_width": "",
                        "size_bytes": "148",
                        "size_compressed": "141",
                        "state": "available",
                        "sys_created_by": "admin",
                        "sys_created_on": "2026-01-27 19:29:42",
                        "sys_id": "fbc38e4483b6f210f28198c6feaad3c3",
                        "sys_mod_count": "1",
                        "sys_tags": "",
                        "sys_updated_by": "system",
                        "sys_updated_on": "2026-01-27 19:29:43",
                        "table_name": "change_request",
                        "table_sys_id": "34a34e0883f6f210f28198c6feaad380"
                    },
                    {
                        "average_image_color": "",
                        "chunk_size_bytes": "700000",
                        "compressed": "true",
                        "content_type": "text/x-sql",
                        "download_link": "https://dev276659.service-now.com/api/now/attachment/c8d38e4483b6f210f28198c6feaad3c4/file",
                        "file_name": "DCR_004_controlled_failure.sql",
                        "hash": "5d48a20d5bd0003a1d3bad56aa43127b33b4274f55978e6404aeb1b49d602aa1",
                        "image_height": "",
                        "image_width": "",
                        "size_bytes": "264",
                        "size_compressed": "198",
                        "state": "available",
                        "sys_created_by": "admin",
                        "sys_created_on": "2026-01-27 19:29:42",
                        "sys_id": "c8d38e4483b6f210f28198c6feaad3c4",
                        "sys_mod_count": "1",
                        "sys_tags": "",
                        "sys_updated_by": "system",
                        "sys_updated_on": "2026-01-27 19:29:43",
                        "table_name": "change_request",
                        "table_sys_id": "34a34e0883f6f210f28198c6feaad380"
                    }
                ],
                "backout_plan": "",
                "business_duration": "",
                "business_service": "281a4d5fc0a8000b00e4ba489a83eedc",
                "cab_date_time": "",
                "cab_delegate": "",
                "cab_recommendation": "",
                "cab_required": "false",
                "calendar_duration": "",
                "category": "Software",
                "change_plan": "",
                "chg_model": "007c4001c343101035ae3f52c1d3aeb2",
                "close_code": "",
                "close_notes": "",
                "closed_at": "",
                "closed_by": "",
                "cmdb_ci": "0c43d5e2c61122750182c132a8b9e2d9",
                "comments": "",
                "comments_and_work_notes": "",
                "company": "",
                "conflict_last_run": "",
                "conflict_status": "Not Run",
                "contact_type": "",
                "contract": "",
                "copied_from": "",
                "correlation_display": "",
                "correlation_id": "",
                "delivery_plan": "",
                "delivery_task": "",
                "description": "--- Managed by r-able.com hyperautomation (TurboCharged, V2.2.2). Do not change manually. Do not deviate. ---\r\n--- This Change Request adds a new deployment to an already installed GoldenGate hub binaries ---\r\n--- Enter the required parameters on the right side of the \":\" below ---\r\nRun dcr\r\n",
                "due_date": "",
                "end_date": "",
                "escalation": "0",
                "expected_start": "",
                "follow_up": "",
                "group_list": "",
                "impact": "low",
                "implementation_plan": "",
                "justification": "",
                "knowledge": "false",
                "location": "",
                "made_sla": "true",
                "number": "CHG0030971",
                "on_hold": false,
                "on_hold_reason": "",
                "on_hold_task": "",
                "opened_at": "2026-01-27 19:28:56",
                "opened_by": "6816f79cc0a8016401c5a33be04be441",
                "order": "",
                "outside_maintenance_schedule": "false",
                "parent": "",
                "phase": "requested",
                "phase_state": "open",
                "priority": "low",
                "production_system": "false",
                "reason": "",
                "reassignment_count": "0",
                "requested_by": "6816f79cc0a8016401c5a33be04be441",
                "requested_by_date": "",
                "review_comments": "",
                "review_date": "",
                "review_status": "",
                "risk": "",
                "risk_impact_analysis": "",
                "route_reason": "",
                "scope": "3",
                "service_offering": "04b89573835e7210f28198c6feaad3f0",
                "short_description": "DCR",
                "sla_due": "",
                "start_date": "",
                "state": "new",
                "std_change_producer_version": "",
                "sys_class_name": "change_request",
                "sys_created_by": "admin",
                "sys_created_on": "2026-01-27 19:29:50",
                "sys_domain": "global",
                "sys_domain_path": "/",
                "sys_id": "34a34e0883f6f210f28198c6feaad380",
                "sys_mod_count": "0",
                "sys_tags": "",
                "sys_updated_by": "admin",
                "sys_updated_on": "2026-01-27 19:29:50",
                "task_effective_number": "CHG0030971",
                "test_plan": "",
                "time_worked": "",
                "type": "normal",
                "unauthorized": "false",
                "universal_request": "",
                "upon_approval": "proceed",
                "upon_reject": "cancel",
                "urgency": "low",
                "user_input": "",
                "watch_list": "",
                "work_end": "",
                "work_notes": "",
                "work_notes_list": "",
                "work_start": ""
            }
        ],
        "warnings": [
            "Encountered unknown value while mapping field risk.",
            "Encountered unknown value Software while mapping field category."
        ]
    }
}

TASK [Download the DCR scripts to server on 2026-01-27] ***********************************************************************************************************************************************************
fatal: [192.168.1.112]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'record'. 'dict object' has no attribute 'record'\n\nThe error appears to be in '/etc/ansible/playbooks/dcr_download_attachment5.yml': line 36, column 11, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Download the DCR scripts to server on {{ ansible_date_time.date }}\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n"}

PLAY RECAP ********************************************************************************************************************************************************************************************************
192.168.1.112 : ok=4 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0   

[ansible_admin@ctrl ansible]$ 

```

This has worked for passing Incidents, but fails for Change Requests.  
Please help.  
Thanks in advance.  
Nestor Kandinsky-Clerambeau.

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [January 27, 2026, 9:09pm UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/2 "2026-01-27T21:09:53Z")

</div>

The problem is pointed out pretty clearly in the job log:

```auto
The error was: 'dict object' has no attribute 'record'.

```

You’re trying to access `dcr_new_cr_request_found_out.record.sys_id`. But `dcr_new_cr_request_found_out` doesn’t have a `record` attribute. It has a `records` attribute, though, which is a list with only one dict in it, and that dict does contain a `sys_id` attribute.

Try accessing `dcr_new_cr_request_found_out.records[0].sys_id` and let us know how that works out for you.

---

<div class="post-metadata">

**Author:** ![clerambeau370](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/clerambeau370/32/10260_2.png) [@clerambeau370](https://forum.ansible.com/u/clerambeau370)\
**Post date:** [January 27, 2026, 9:44pm UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/3 "2026-01-27T21:44:00Z")

</div>

> [@utoddl](#):
>
> dcr\_new\_cr\_request\_found\_out.records[0].sys\_id

Could it be that easy?

---

<div class="post-metadata">

**Author:** ![clerambeau370](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/clerambeau370/32/10260_2.png) [@clerambeau370](https://forum.ansible.com/u/clerambeau370)\
**Post date:** [January 27, 2026, 9:51pm UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/4 "2026-01-27T21:51:50Z")

</div>

No luck , sorry.

```auto
---
    - name: Oracle database Data Change Request Process ID 2872.56
      hosts: dbservers
      gather_facts: true
      vars_files:
        - vars/main.yml

      tasks:

        - name: Display Ansible date_time fact and register | itsm_dcr
          delegate_to: localhost
          run_once: true
          set_fact: 
            currenttime: "{{ ansible_date_time.iso8601 }}"
          tags: linux

        - name: Retrieve new DCR change requestso
          servicenow.itsm.change_request_info:
             instance:
               host: "{{ sn_instance}}"
               username: "{{ sn_username }}"
               password: "{{ sn_password }}"
             query:
              - state: = new
                short_description: LIKE DCR
# - state: = new
# assigned_to: = bertie.luby
          register: dcr_new_cr_request_found_out
# delegate_to: localhost

        - name: Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr
          debug: var=dcr_new_cr_request_found_out

        - name: Cache the CR SYS_ID {{ ansible_date_time.iso8601 }} itsm_ogg_resync.yml 
          ansible.builtin.set_fact:
            sys_id: "{{ dcr_new_cr_request_found_out.record.sys_id }}"
# cacheable: yes

############################### lockfile####################################

        - name: Download the DCR scripts to server on {{ ansible_date_time.date }}
          servicenow.itsm.attachment:
            instance:
              host: "{{ sn_instance}}"
              username: "{{ sn_username }}"
              password: "{{ sn_password }}"
            dest: /runtime/dcr/dcr5.sql
# sys_id: fbc38e4483b6f210f28198c6feaad3c3
# sys_id: "{{ dcr_new_cr_request_found_out.record.sys_id }}"
            sys_id: "{{ dcr_new_cr_request_found_out.records[0].sys_id }}"
          register: dcr_new_change_request_download_status_out
# delegate_to: localhost

        - name: Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr
          debug: var=dcr_new_change_request_download_status_out

```

```auto
[ansible_admin@ctrl ansible]$ ansible-playbook ./playbooks/dcr_download_attachment5.yml 

PLAY [Oracle database Data Change Request Process ID 2872.56] *************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************
ok: [192.168.1.112]
[WARNING]: Using run_once with the free strategy is not currently supported. This task will still be executed for every host in the inventory list.

TASK [Display Ansible date_time fact and register | itsm_dcr] *************************************************************************************************************************************************
ok: [192.168.1.112 -> localhost]

TASK [Retrieve new DCR change requestso] **********************************************************************************************************************************************************************
[WARNING]: Encountered unknown value while mapping field risk.
[WARNING]: Encountered unknown value Software while mapping field category.
ok: [192.168.1.112]

TASK [Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr] *****************************************************************************************************************************
ok: [192.168.1.112] => {
    "dcr_new_cr_request_found_out": {
        "changed": false,
        "failed": false,
        "records": [
            {
                "active": "true",
                "activity_due": "",
                "additional_assignee_list": "",
                "approval": "approved",
                "approval_history": "",
                "approval_set": "2026-01-27 19:29:50",
                "assigned_to": "3c589a008334f210f28198c6feaad375",
                "assignment_group": "db53580b0a0a0a6501aa37c294a2ba6b",
                "attachments": [
                    {
                        "average_image_color": "",
                        "chunk_size_bytes": "700000",
                        "compressed": "true",
                        "content_type": "text/x-sql",
                        "download_link": "https://dev276659.service-now.com/api/now/attachment/33c38e4483b6f210f28198c6feaad3c1/file",
                        "file_name": "DCR_001.sql",
                        "hash": "be2477f129a827a656c0b76392edbfa4b10568341786837b5f67ba7a25abb359",
                        "image_height": "",
                        "image_width": "",
                        "size_bytes": "141",
                        "size_compressed": "146",
                        "state": "available",
                        "sys_created_by": "admin",
                        "sys_created_on": "2026-01-27 19:29:41",
                        "sys_id": "33c38e4483b6f210f28198c6feaad3c1",
                        "sys_mod_count": "1",
                        "sys_tags": "",
                        "sys_updated_by": "system",
                        "sys_updated_on": "2026-01-27 19:29:43",
                        "table_name": "change_request",
                        "table_sys_id": "34a34e0883f6f210f28198c6feaad380"
                    }
                ],
                "backout_plan": "",
                "business_duration": "",
                "business_service": "281a4d5fc0a8000b00e4ba489a83eedc",
                "cab_date_time": "",
                "cab_delegate": "",
                "cab_recommendation": "",
                "cab_required": "false",
                "calendar_duration": "",
                "category": "Software",
                "change_plan": "",
                "chg_model": "007c4001c343101035ae3f52c1d3aeb2",
                "close_code": "",
                "close_notes": "",
                "closed_at": "",
                "closed_by": "",
                "cmdb_ci": "0c43d5e2c61122750182c132a8b9e2d9",
                "comments": "",
                "comments_and_work_notes": "",
                "company": "",
                "conflict_last_run": "",
                "conflict_status": "Not Run",
                "contact_type": "",
                "contract": "",
                "copied_from": "",
                "correlation_display": "",
                "correlation_id": "",
                "delivery_plan": "",
                "delivery_task": "",
                "description": "--- Managed by r-able.com hyperautomation (TurboCharged, V2.2.2). Do not change manually. Do not deviate. ---\r\n--- This Change Request adds a new deployment to an already installed GoldenGate hub binaries ---\r\n--- Enter the required parameters on the right side of the \":\" below ---\r\nRun dcr\r\n",
                "due_date": "",
                "end_date": "",
                "escalation": "0",
                "expected_start": "",
                "follow_up": "",
                "group_list": "",
                "impact": "low",
                "implementation_plan": "",
                "justification": "",
                "knowledge": "false",
                "location": "",
                "made_sla": "true",
                "number": "CHG0030971",
                "on_hold": false,
                "on_hold_reason": "",
                "on_hold_task": "",
                "opened_at": "2026-01-27 19:28:56",
                "opened_by": "6816f79cc0a8016401c5a33be04be441",
                "order": "",
                "outside_maintenance_schedule": "false",
                "parent": "",
                "phase": "requested",
                "phase_state": "open",
                "priority": "low",
                "production_system": "false",
                "reason": "",
                "reassignment_count": "0",
                "requested_by": "6816f79cc0a8016401c5a33be04be441",
                "requested_by_date": "",
                "review_comments": "",
                "review_date": "",
                "review_status": "",
                "risk": "",
                "risk_impact_analysis": "",
                "route_reason": "",
                "scope": "3",
                "service_offering": "04b89573835e7210f28198c6feaad3f0",
                "short_description": "DCR",
                "sla_due": "",
                "start_date": "",
                "state": "new",
                "std_change_producer_version": "",
                "sys_class_name": "change_request",
                "sys_created_by": "admin",
                "sys_created_on": "2026-01-27 19:29:50",
                "sys_domain": "global",
                "sys_domain_path": "/",
                "sys_id": "34a34e0883f6f210f28198c6feaad380",
                "sys_mod_count": "3",
                "sys_tags": "",
                "sys_updated_by": "admin",
                "sys_updated_on": "2026-01-27 21:11:45",
                "task_effective_number": "CHG0030971",
                "test_plan": "",
                "time_worked": "",
                "type": "normal",
                "unauthorized": "false",
                "universal_request": "",
                "upon_approval": "proceed",
                "upon_reject": "cancel",
                "urgency": "low",
                "user_input": "",
                "watch_list": "",
                "work_end": "",
                "work_notes": "",
                "work_notes_list": "",
                "work_start": ""
            }
        ],
        "warnings": [
            "Encountered unknown value while mapping field risk.",
            "Encountered unknown value Software while mapping field category."
        ]
    }
}

TASK [Cache the CR SYS_ID 2026-01-27T21:49:37Z itsm_ogg_resync.yml] *******************************************************************************************************************************************
fatal: [192.168.1.112]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'record'. 'dict object' has no attribute 'record'\n\nThe error appears to be in '/etc/ansible/playbooks/dcr_download_attachment5.yml': line 34, column 11, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Cache the CR SYS_ID {{ ansible_date_time.iso8601 }} itsm_ogg_resync.yml\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n"}

PLAY RECAP ****************************************************************************************************************************************************************************************************
192.168.1.112 : ok=4 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0   

```

---

<div class="post-metadata">

**Author:** ![bvitnik](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bvitnik/32/4132_2.png) [@bvitnik](https://forum.ansible.com/u/bvitnik)\
**Post date:** [January 27, 2026, 10:46pm UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/5 "2026-01-27T22:46:44Z")

</div>

You missed this:

> [@clerambeau370](#):
>
> ```auto
> - name: Cache the CR SYS_ID {{ ansible_date_time.iso8601 }} itsm_ogg_resync.yml 
> ansible.builtin.set_fact:
> sys_id: "{{ dcr_new_cr_request_found_out.record.sys_id }}" # <- this!
> # cacheable: yes
> 
> ```

---

<div class="post-metadata">

**Author:** ![clerambeau370](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/clerambeau370/32/10260_2.png) [@clerambeau370](https://forum.ansible.com/u/clerambeau370)\
**Post date:** [January 27, 2026, 11:46pm UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/6 "2026-01-27T23:46:33Z")

</div>

> [@clerambeau370](#):
>
> ```auto
> - name: Cache the CR SYS_ID {{ ansible_date_time.iso8601 }} itsm_ogg_resync.yml 
> ansible.builtin.set_fact:
> sys_id: "{{ dcr_new_cr_request_found_out.record.sys_id }}"
> # cacheable: yes
> 
> ```

Thanks, but i added it after the first post. See line 30 above your last reply:

```auto
        - name: Cache the CR SYS_ID {{ ansible_date_time.iso8601 }} itsm_ogg_resync.yml 
          ansible.builtin.set_fact:
            sys_id: "{{ dcr_new_cr_request_found_out.record.sys_id }}"
# cacheable: yes

```

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [January 27, 2026, 11:50pm UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/7 "2026-01-27T23:50:48Z")

</div>

I’m confused. (Or you’re confused.)  
You fixed line 50, but the broken expression remains unfixed in line 36.

---

<div class="post-metadata">

**Author:** ![clerambeau370](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/clerambeau370/32/10260_2.png) [@clerambeau370](https://forum.ansible.com/u/clerambeau370)\
**Post date:** [January 27, 2026, 11:54pm UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/8 "2026-01-27T23:54:17Z")

</div>

LOL. It has got to be me who is confused, as always!

---

<div class="post-metadata">

**Author:** ![clerambeau370](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/clerambeau370/32/10260_2.png) [@clerambeau370](https://forum.ansible.com/u/clerambeau370)\
**Post date:** [January 28, 2026, 12:00am UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/9 "2026-01-28T00:00:36Z")

</div>

You were right. But now another issue, more complex:

```auto
---
    - name: Oracle database Data Change Request Process ID 2872.56
      hosts: dbservers
      gather_facts: true
      vars_files:
        - vars/main.yml

      tasks:

        - name: Display Ansible date_time fact and register | itsm_dcr
          delegate_to: localhost
          run_once: true
          set_fact: 
            currenttime: "{{ ansible_date_time.iso8601 }}"
          tags: linux

        - name: Retrieve new DCR change requestso
          servicenow.itsm.change_request_info:
             instance:
               host: "{{ sn_instance}}"
               username: "{{ sn_username }}"
               password: "{{ sn_password }}"
             query:
              - state: = new
                short_description: LIKE DCR
# - state: = new
# assigned_to: = bertie.luby
          register: dcr_new_cr_request_found_out
# delegate_to: localhost

        - name: Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr
          debug: var=dcr_new_cr_request_found_out

############################### lockfile####################################

        - name: Cache the CR SYS_ID {{ ansible_date_time.iso8601 }} itsm_ogg_resync.yml 
          ansible.builtin.set_fact:
            sys_id: "{{ dcr_new_cr_request_found_out.records[0].sys_id }}"

        - name: Download the DCR scripts to server on {{ ansible_date_time.date }}
          servicenow.itsm.attachment:
            instance:
              host: "{{ sn_instance}}"
              username: "{{ sn_username }}"
              password: "{{ sn_password }}"
            dest: /runtime/dcr/dcr5.sql
# sys_id: fbc38e4483b6f210f28198c6feaad3c3
# sys_id: "{{ dcr_new_cr_request_found_out.record.sys_id }}"
            sys_id: "{{ dcr_new_cr_request_found_out.records[0].sys_id }}"
          register: dcr_new_change_request_download_status_out
# delegate_to: localhost

        - name: Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr
          debug: var=dcr_new_change_request_download_status_out

```

```auto
[ansible_admin@ctrl ~]$ cd /etc/ansible
[ansible_admin@ctrl ansible]$ ansible-playbook ./playbooks/dcr_download_attachment6.yml 

PLAY [Oracle database Data Change Request Process ID 2872.56] *************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************
ok: [192.168.1.112]
[WARNING]: Using run_once with the free strategy is not currently supported. This task will still be executed for every host in the inventory list.

TASK [Display Ansible date_time fact and register | itsm_dcr] *************************************************************************************************************************************************
ok: [192.168.1.112 -> localhost]

TASK [Retrieve new DCR change requestso] **********************************************************************************************************************************************************************
[WARNING]: Encountered unknown value while mapping field risk.
[WARNING]: Encountered unknown value Software while mapping field category.
ok: [192.168.1.112]

TASK [Debug the Oracle DBA Incident details to resolve the DCR errors | itsm_dcr] *****************************************************************************************************************************
ok: [192.168.1.112] => {
    "dcr_new_cr_request_found_out": {
        "changed": false,
        "failed": false,
        "records": [
            {
                "active": "true",
                "activity_due": "",
                "additional_assignee_list": "",
                "approval": "approved",
                "approval_history": "",
                "approval_set": "2026-01-27 19:29:50",
                "assigned_to": "3c589a008334f210f28198c6feaad375",
                "assignment_group": "db53580b0a0a0a6501aa37c294a2ba6b",
                "attachments": [
                    {
                        "average_image_color": "",
                        "chunk_size_bytes": "700000",
                        "compressed": "true",
                        "content_type": "text/x-sql",
                        "download_link": "https://dev276659.service-now.com/api/now/attachment/33c38e4483b6f210f28198c6feaad3c1/file",
                        "file_name": "DCR_001.sql",
                        "hash": "be2477f129a827a656c0b76392edbfa4b10568341786837b5f67ba7a25abb359",
                        "image_height": "",
                        "image_width": "",
                        "size_bytes": "141",
                        "size_compressed": "146",
                        "state": "available",
                        "sys_created_by": "admin",
                        "sys_created_on": "2026-01-27 19:29:41",
                        "sys_id": "33c38e4483b6f210f28198c6feaad3c1",
                        "sys_mod_count": "1",
                        "sys_tags": "",
                        "sys_updated_by": "system",
                        "sys_updated_on": "2026-01-27 19:29:43",
                        "table_name": "change_request",
                        "table_sys_id": "34a34e0883f6f210f28198c6feaad380"
                    }
                ],
                "backout_plan": "",
                "business_duration": "",
                "business_service": "281a4d5fc0a8000b00e4ba489a83eedc",
                "cab_date_time": "",
                "cab_delegate": "",
                "cab_recommendation": "",
                "cab_required": "false",
                "calendar_duration": "",
                "category": "Software",
                "change_plan": "",
                "chg_model": "007c4001c343101035ae3f52c1d3aeb2",
                "close_code": "",
                "close_notes": "",
                "closed_at": "",
                "closed_by": "",
                "cmdb_ci": "0c43d5e2c61122750182c132a8b9e2d9",
                "comments": "",
                "comments_and_work_notes": "",
                "company": "",
                "conflict_last_run": "",
                "conflict_status": "Not Run",
                "contact_type": "",
                "contract": "",
                "copied_from": "",
                "correlation_display": "",
                "correlation_id": "",
                "delivery_plan": "",
                "delivery_task": "",
                "description": "--- Managed by r-able.com hyperautomation (TurboCharged, V2.2.2). Do not change manually. Do not deviate. ---\r\n--- This Change Request adds a new deployment to an already installed GoldenGate hub binaries ---\r\n--- Enter the required parameters on the right side of the \":\" below ---\r\nRun dcr\r\n",
                "due_date": "",
                "end_date": "",
                "escalation": "0",
                "expected_start": "",
                "follow_up": "",
                "group_list": "",
                "impact": "low",
                "implementation_plan": "",
                "justification": "",
                "knowledge": "false",
                "location": "",
                "made_sla": "true",
                "number": "CHG0030971",
                "on_hold": false,
                "on_hold_reason": "",
                "on_hold_task": "",
                "opened_at": "2026-01-27 19:28:56",
                "opened_by": "6816f79cc0a8016401c5a33be04be441",
                "order": "",
                "outside_maintenance_schedule": "false",
                "parent": "",
                "phase": "requested",
                "phase_state": "open",
                "priority": "low",
                "production_system": "false",
                "reason": "",
                "reassignment_count": "0",
                "requested_by": "6816f79cc0a8016401c5a33be04be441",
                "requested_by_date": "",
                "review_comments": "",
                "review_date": "",
                "review_status": "",
                "risk": "",
                "risk_impact_analysis": "",
                "route_reason": "",
                "scope": "3",
                "service_offering": "04b89573835e7210f28198c6feaad3f0",
                "short_description": "DCR",
                "sla_due": "",
                "start_date": "",
                "state": "new",
                "std_change_producer_version": "",
                "sys_class_name": "change_request",
                "sys_created_by": "admin",
                "sys_created_on": "2026-01-27 19:29:50",
                "sys_domain": "global",
                "sys_domain_path": "/",
                "sys_id": "34a34e0883f6f210f28198c6feaad380",
                "sys_mod_count": "3",
                "sys_tags": "",
                "sys_updated_by": "admin",
                "sys_updated_on": "2026-01-27 21:11:45",
                "task_effective_number": "CHG0030971",
                "test_plan": "",
                "time_worked": "",
                "type": "normal",
                "unauthorized": "false",
                "universal_request": "",
                "upon_approval": "proceed",
                "upon_reject": "cancel",
                "urgency": "low",
                "user_input": "",
                "watch_list": "",
                "work_end": "",
                "work_notes": "",
                "work_notes_list": "",
                "work_start": ""
            }
        ],
        "warnings": [
            "Encountered unknown value while mapping field risk.",
            "Encountered unknown value Software while mapping field category."
        ]
    }
}

TASK [Cache the CR SYS_ID 2026-01-27T23:59:17Z itsm_ogg_resync.yml] *******************************************************************************************************************************************
ok: [192.168.1.112]

TASK [Download the DCR scripts to server on 2026-01-27] *******************************************************************************************************************************************************
fatal: [192.168.1.112]: FAILED! => {"changed": false, "msg": "Status code: 404, Details: Record doesn't exist or ACL restricts the record retrieval"}

PLAY RECAP ****************************************************************************************************************************************************************************************************
192.168.1.112 : ok=5 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0   

```

---

<div class="post-metadata">

**Author:** ![clerambeau370](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/clerambeau370/32/10260_2.png) [@clerambeau370](https://forum.ansible.com/u/clerambeau370)\
**Post date:** [January 28, 2026, 12:01am UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/10 "2026-01-28T00:01:32Z")

</div>

With -vvv, the last task output:

```auto
TASK [Download the DCR scripts to server on 2026-01-27] *******************************************************************************************************************************************************
task path: /etc/ansible/playbooks/dcr_download_attachment6.yml:41
The full traceback is:
  File "/tmp/ansible_servicenow.itsm.attachment_payload_1f4eu0aa/ansible_servicenow.itsm.attachment_payload.zip/ansible_collections/servicenow/itsm/plugins/modules/attachment_info.py", line 146, in main
    record = run(module, attachment_client)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/ansible_servicenow.itsm.attachment_payload_1f4eu0aa/ansible_servicenow.itsm.attachment_payload.zip/ansible_collections/servicenow/itsm/plugins/modules/attachment_info.py", line 105, in run
    raise errors.ServiceNowError("Status code: 404, Details: " + error)
fatal: [192.168.1.112]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "dest": "/runtime/dcr/dcr5.sql",
            "instance": {
                "access_token": null,
                "api_key": null,
                "api_path": "api/now",
                "client_certificate_file": null,
                "client_id": null,
                "client_key_file": null,
                "client_secret": null,
                "custom_headers": null,
                "grant_type": null,
                "host": "https://dev276659.service-now.com",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "refresh_token": null,
                "timeout": 10.0,
                "username": "admin",
                "validate_certs": true
            },
            "sys_id": "34a34e0883f6f210f28198c6feaad380"
        }
    },
    "msg": "Status code: 404, Details: Record doesn't exist or ACL restricts the record retrieval"
}

PLAY RECAP ****************************************************************************************************************************************************************************************************
192.168.1.112 : ok=5 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0   

[ansible_admin@ctrl ansible]$ 

```

---

<div class="post-metadata">

**Author:** ![clerambeau370](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/clerambeau370/32/10260_2.png) [@clerambeau370](https://forum.ansible.com/u/clerambeau370)\
**Post date:** [January 28, 2026, 12:19am UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/11 "2026-01-28T00:19:52Z")

</div>

@utoddl oh, I see. you did great. I was confused once more. Here lies the problem. There is a difference between a Change Request SYS\_ID and each of its attachments SYS\_ID. When we pass the first while looking for the second, Ansible says “doesnt exist”. My bad.

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [January 28, 2026, 2:13am UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/12 "2026-01-28T02:13:21Z")

</div>

Yes. And `.records[0].attachments` is also a list, so you may need to loop over it to get them all. Or loop over a filtered subset where `content_type = 'text/x-sql'` or something like that.

Kudos for using `ansible.builtin.debug` to see what you’ve registered. Also for including the `debug` output in the thread. You’d be amazed how often people ask for help with this type of problem without including crucial info like that. Nice asking on your part!

Cheers!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 27, 2026, 2:13am UTC](https://forum.ansible.com/t/passing-a-var-between-playbook-tasks/45203/13 "2026-02-27T02:13:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
