HI team,

I have a output as below. but still I need to pick the right value fro this 
output. I need only the change no as in record field, it working fine for 
single run but it failing when in loop. can some one help me. needed filed 
in "number": "CHG0030428",  I will have multiple change no through out the 
debug module.
I tried with selectattr and map to it was not working

msg: "{{test.results.record| selectattr('number','match','^CH$')}}"
and 
msg: "{{test.record| selectattr('number','match','^CH$')|list}}"

msg: "{{test.results.record| selectattr('number','match','^CH$')}}"


output is:

ok: [localhost] => {
    "msg": "<generator object _select_or_reject at 0x7f11a00bf2d0>"


full output:

ok: [localhost] => {
    "msg": "<generator object _select_or_reject at 0x7f11a00bf2d0>"

ok: [localhost] => {
    "msg": "<generator object _select_or_reject at 0x7f11a00bf2d0>"

ok: [localhost] => {
    "msg": "<generator object _select_or_reject at 0x7f11a00bf2d0>"

TASK [servicenow : debug] 
*****************************************************************************************************************************************************
ok: [localhost] => {
    "msg": {
        "changed": true, 
        "msg": "All items completed", 
        "results": [
            {
                "_ansible_ignore_errors": null, 
                "_ansible_item_label": [
                    "DEV_4", 
                    "Acrobat", 
                    "2", 
                    "3", 
                    "", 
                    "2018-01-02 14:00:00", 
                    "Network", 
                    "David Loo"
                ], 
                "_ansible_item_result": true, 
                "_ansible_no_log": false, 
                "_ansible_parsed": true, 
                "changed": true, 
                "failed": false, 
                "instance": "dev71301", 
                "invocation": {
                    "module_args": {
                        "attachment": null, 
                        "data": {
                            "assigned_to": "David Loo", 
                            "assignment_group": "Network", 
                            "cmdb_ci": "Acrobat", 
                            "end_date": "2018-01-02 14:00:00", 
                            "impact": "3", 
                            "priority": "2", 
                            "short_description": "DEV_4 change has ben 
created succesfully with Acrobat configuration item via ansible", 
                            "start_date": "", 
                            "work_notes": "Testing with change creation"
                        }, 
                        "instance": "dev71301", 
                        "lookup_field": "number", 
                        "number": null, 
                        "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                        "state": "present", 
                        "table": "change_request", 
                        "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                    }
                }, 
                "item": [
                    "DEV_4", 
                    "Acrobat", 
                    "2", 
                    "3", 
                    "", 
                    "2018-01-02 14:00:00", 
                    "Network", 
                    "David Loo"
                ], 
                "lookup_field": "number", 
                "number": null, 
                "record": {
                    "active": "true", 
                    "activity_due": "", 
                    "additional_assignee_list": "", 
                    "approval": "not requested", 
                    "approval_history": "", 
                    "approval_set": "", 
                    "assigned_to": {
                        "link": "
https://dev71301.service-now.com/api/now/table/sys_user/5137153cc611227c000bbd1bd8cd2007";,
 

                        "value": "5137153cc611227c000bbd1bd8cd2007"
                    }, 
                    "assignment_group": {
                        "link": "
https://dev71301.service-now.com/api/now/table/sys_user_group/287ebd7da9fe198100f92cc8d1d2154e";,
 

                        "value": "287ebd7da9fe198100f92cc8d1d2154e"
                    }, 
                    "backout_plan": "", 
                    "business_duration": "", 
                    "business_service": "", 
                    "cab_date": "", 
                    "cab_delegate": "", 
                    "cab_recommendation": "", 
                    "change_plan": "", 
                    "close_code": "", 
                    "close_notes": "", 
                    "closed_at": "", 
                    "closed_by": "", 
                    "cmdb_ci": {
                        "link": "
https://dev71301.service-now.com/api/now/table/cmdb_ci/0c43d67fc61122750182c13265645d9d";,
 

                        "value": "0c43d67fc61122750182c13265645d9d"
                    }, 
                    "comments": "", 
                    "comments_and_work_notes": "", 
                    "company": "", 
                    "conflict_last_run": "", 
                    "conflict_status": "Not Run", 
                    "contact_type": "", 
                    "correlation_display": "", 
                    "correlation_id": "", 
                    "delivery_plan": "", 
                    "delivery_task": "", 
                    "description": "", 
                    "due_date": "", 
                    "end_date": "2018-01-02 14:00:00", 
                    "escalation": "0", 
                    "expected_start": "", 
                    "follow_up": "", 
                    "group_list": "", 
                    "impact": "3", 
                    "implementation_plan": "", 
                    "justification": "", 
                    "knowledge": "false", 
                    "location": "", 
                    "made_sla": "true", 
                    "number": "CHG0030428", 
                    "on_hold": "false", 
                    "on_hold_reason": "", 
                    "on_hold_task": "", 
                    "opened_at": "2019-01-21 08:49:56", 

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/df295007-0e12-4a72-bfa4-6396f41ffb16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to