Hi Dick,

Sure, Let me provide complete playbook  . 

---
- hosts: cimc
  connection: local
  gather_facts: no
  tasks:
  - name: Checking Local Users
    imc_rest:
      hostname: "{{ imc_hostname }}"
      username: "{{ imc_username }}"
      password: "{{ imc_password }}"
      protocol: https
      timeout: 60
      validate_certs: no
      content: |
         <configResolveClass inHierarchical="false" classId="aaaUser"/>
    register: result
  - set_fact:
      user: "{{ result.configResolveClass.children|json_query(my_query) }}"
    vars:
      my_query: "[].outConfigs.children[].aaaUser.attributes[].{id: id, 
name: name, priv: priv, accountStatus: accountStatus}"
  - debug:
      msg: "{{ user | rejectattr('accountStatus', 'eq', 'inactive')| list | 
to_yaml }}"

  - name: Comment on issue
    jira:
      uri: 'XXXX'
      username: 'XXXX'
      password: 'XXXX'
      issue: 'XXXX'
      operation: comment
      comment: "{{ user | rejectattr('accountStatus', 'eq', 'inactive')| 
list | to_yaml }}"
    delegate_to: localhost



PLAY [cimc] 
********************************************************************************************************************************

TASK [Checking Local Users] 
**********************************************************************************************************************
ok: [Host1]

TASK [set_fact] 
**********************************************************************************************************************************
ok: [Host1]

TASK [debug] 
*************************************************************************************************************************************
ok: [Host1] => {}

MSG:

- {accountStatus: active, id: '1', name: admin, priv: admin}
- {accountStatus: active, id: '2', name: VIPER_VIO, priv: admin}
- {accountStatus: active, id: '3', name: VIDEO_ENG, priv: admin}
- {accountStatus: active, id: '4', name: RIO-CDVR, priv: admin}
- {accountStatus: active, id: '5', name: viecdvr, priv: admin}
- {accountStatus: active, id: '6', name: op5admin, priv: read-only}
- {accountStatus: active, id: '7', name: DEUSER, priv: read-only}


TASK [Comment on issue] 
**************************************************************************************************************************
changed: [Host1 -> localhost]

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

jira module adding only the data's without the Host1,  not sure where to 
modify to include the host inventory 


Thank you,
Ramesh 


On Thursday, 14 January 2021 at 17:31:39 UTC-5 dick....@geant.org wrote:

> Correct. You didn't mention that at all, nor how that data looks like, nor 
> where it comes from.
>
> On Thu, 14 Jan 2021 at 21:35, Ramesh AR <rames...@gmail.com> wrote:
>
>> I'm able to comment the debug output but there's no host/IP details.. is 
>> there any way to take and comment as well . ?
>>
>> *Now*: commenting below format,
>>
>>  {accountStatus: active, id: '1', name: admin, priv: admin}
>> - {accountStatus: active, id: '2', name: VE, priv: admin}
>> - {accountStatus: active, id: '3', name: RIOR, priv: admin}
>> - {accountStatus: active, id: '4', name: VPIO, priv: admin}
>> - {accountStatus: active, id: '5', name: vie, priv: admin}
>> - {accountStatus: active, id: '6', name: p5work, priv: admin}
>> - {accountStatus: active, id: '7', name: DEU, priv: admin}
>>
>> *expecting comment*: should be with hostname / IP address
>>
>> ok: [test1] => {}
>>
>> MSG:
>>
>> - {accountStatus: active, id: '1', name: admin, priv: admin}
>> - {accountStatus: active, id: '2', name: VE, priv: admin}
>> - {accountStatus: active, id: '3', name: RIOR, priv: admin}
>> - {accountStatus: active, id: '4', name: VPIO, priv: admin}
>> - {accountStatus: active, id: '5', name: vie, priv: admin}
>> - {accountStatus: active, id: '6', name: p5work, priv: admin}
>> - {accountStatus: active, id: '7', name: DEU, priv: admin}
>>
>>
>>
>> On Thursday, 14 January 2021 at 13:26:47 UTC-5 Ramesh AR wrote:
>>
>>> HI Dick / Abhijeet,
>>>
>>> I want to pass the below variable data's to Jira comment section . 
>>>
>>> TASK [debug] 
>>> *************************************************************************************************************************************
>>> ok: [test1] => {}
>>>
>>> MSG:
>>>
>>> - {accountStatus: active, id: '1', name: admin, priv: admin}
>>> - {accountStatus: active, id: '2', name: VE, priv: admin}
>>> - {accountStatus: active, id: '3', name: RIOR, priv: admin}
>>> - {accountStatus: active, id: '4', name: VPIO, priv: admin}
>>> - {accountStatus: active, id: '5', name: vie, priv: admin}
>>> - {accountStatus: active, id: '6', name: p5work, priv: admin}
>>> - {accountStatus: active, id: '7', name: DEU, priv: admin}
>>>
>>> +++++++++++++++++++++++++++++++++++++++++++
>>>  - set_fact:
>>>       user: "{{ result.configResolveClass.children|json_query(my_query) 
>>> }}"
>>>     vars:
>>>       my_query: "[].outConfigs.children[].aaaUser.attributes[].{id: id, 
>>> name: name, priv: priv, accountStatus: accountStatus}"
>>>   - debug:
>>>       msg: "{{ user | rejectattr('accountStatus', 'eq', 'inactive')| 
>>> list | to_yaml }}"
>>> ++++++++++++++++++++++++++++++++++++++++++++
>>>
>>> Thanks,
>>> Ramesh
>>>
>>> On Thursday, 14 January 2021 at 03:18:46 UTC-5 Abhijeet Kasurde wrote:
>>>
>>>> Are you getting error messages? I am able to process the comment
>>>>
>>>> - name: Comment an issue
>>>> community.general.jira:
>>>> uri: '{{ jirauri }}'
>>>> username: '{{ jira_username }}'
>>>> password: "{{ lookup('file', '/Users/akasurde/.jira_api_token') }}"
>>>> project: scrum-project
>>>> operation: comment
>>>> issue: "SP-1"
>>>> comment: "In Progress"
>>>> register: issue_comment
>>>>
>>>> - debug:
>>>> msg: "{{ issue_comment }}"
>>>>
>>>>
>>>>
>>>> "meta": {
>>>>             "author": {
>>>>                 "accountId": 
>>>> "557079:f1799ad8-ab63-413a-a052-4e0cb738dfa9",
>>>>                 "accountType": "atlassian",
>>>>                 "active": true,
>>>>                 "avatarUrls": {},
>>>>                 "displayName": "Aab",
>>>>                 "emailAddress": "x...@gmail.com",
>>>>                 "self": "
>>>> https://ansi.atlassian.net/rest/api/2/user?accountId=557058%3Af1799ad8-ab63-413a-a052-4e0cb738dfa9
>>>> ",
>>>>                 "timeZone": "Asia/Kolkata"
>>>>             },
>>>>             "body": "In Progress",
>>>>             "created": "2021-01-14T13:44:12.521+0530",
>>>>             "id": "10000",
>>>>             "jsdPublic": true,
>>>>             "self": "
>>>> https://ansi.atlassian.net/rest/api/2/issue/10000/comment/10000";,
>>>>             "updateAuthor": {
>>>>                 "accountId": 
>>>> "557079:f1799ad8-ab63-413a-a052-4e0cb738dfa9",
>>>>                 "accountType": "atlassian",
>>>>                 "active": true,
>>>>                 "avatarUrls": {
>>>>                 },
>>>>                 "displayName": "aab",
>>>>                 "emailAddress": "x...@gmail.com",
>>>>                 "self": "
>>>> https://ansi.atlassian.net/rest/api/2/user?accountId=557058%3Af1799ad8-ab63-413a-a052-4e0cb738dfa9
>>>> ",
>>>>                 "timeZone": "Asia/Kolkata"
>>>>             }
>>>>             }
>>>>
>>>>
>>>> On Thu, Jan 14, 2021 at 1:02 PM Dick Visser <dick....@geant.org> wrote:
>>>>
>>>>> What does that "user" variable look like?
>>>>> What does "didn't work" mean exactly?
>>>>>
>>>>>
>>>>> On Thu, 14 Jan 2021 at 01:07, Ramesh AR <rames...@gmail.com> wrote:
>>>>>
>>>>>> Hi, 
>>>>>>
>>>>>> I have a playbook to retrieve user details and getting the output by 
>>>>>> using debug module. on same playbook second task to comment the user 
>>>>>> details in JIRA ticket. 
>>>>>>
>>>>>> any idea how to redirect the debug output to jira module . 
>>>>>>
>>>>>> - debug:
>>>>>>       msg: "{{ user | list | to_yaml }}"
>>>>>>
>>>>>>   - name: Commenting output to Jira
>>>>>>     hosts: 127.0.0.1
>>>>>>     connection: local
>>>>>>     tasks:
>>>>>>     - name: Comment on issue
>>>>>>       jira:
>>>>>>        uri: 'https://xxxxx'
>>>>>>        username: 'xxxx'
>>>>>>        password: 'xxxx'
>>>>>>        issue: 'xxxx'
>>>>>>        operation: comment
>>>>>>        comment: "{{ user | list | to_yaml }}" >>> i tried this way 
>>>>>> but didn't work
>>>>>>      delegate_to: localhost 
>>>>>>
>>>>>> Thank you,
>>>>>> Ramesh 
>>>>>>
>>>>>> -- 
>>>>>> 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/a0c47ffb-7a28-49f7-8000-022199a92b75n%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/ansible-project/a0c47ffb-7a28-49f7-8000-022199a92b75n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> -- 
>>>>> Sent from a mobile device - please excuse the brevity, spelling and 
>>>>> punctuation.
>>>>>
>>>>> -- 
>>>>> 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/CAL8fbwMRS2igX_O-%2BbkXqThg6jRa-Y_GcNP78aMtEttQJk_fcQ%40mail.gmail.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwMRS2igX_O-%2BbkXqThg6jRa-Y_GcNP78aMtEttQJk_fcQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>
>>>>
>>>> -- 
>>>> Thanks,
>>>> Abhijeet Kasurde
>>>>
>>> -- 
>> 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/848e3bf6-f7dc-42da-8b9c-e7742255ebfdn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/848e3bf6-f7dc-42da-8b9c-e7742255ebfdn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/008f946a-3ee8-4465-b45d-1b390df2d5bcn%40googlegroups.com.

Reply via email to