Ansible JIRA query fails because of JQL deprecation

Hello. I am new to Ansible, JIRA and Atlassian products. I have an Output Ansible playbook that is supposed to query my trial JIRA for all task metadata under a project named "PROJ’. It fails with a notice of JQL deprecation.

#############ANSIBLE CODE#######################

---
    - name: Get all task metadata for project PROJ
      hosts: localhost
      connection: local
      gather_facts: true
      vars_files:
        - vars/main.yml

      tasks:

        - name: Create a new Jira issue
          community.general.jira:
            uri: "{{ jira_url }}"
            username: "{{ jira_user }}"
            password: "{{ jira_api_token }}"
            operation: search
            jql: "project = 'PROJ' AND issuetype = 'Task' AND status != 'Done'"
            maxresults: 50
          register: jira_tasks

        - name: Display task keys
          ansible.builtin.debug:
            msg: "Found task: {{ item.key }}"
          loop: "{{ jira_tasks.meta.issues }}"
############END OF ANSIBLE CODE#############

Output:

[ansible_admin@ctrl ansible]$ time ansible-playbook ./playbooks/jira.findalltasks.yml
[WARNING]: Collection community.general does not support Ansible version 2.16.3

PLAY [Create JIRA ID 2872.56] *************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************
ok: [localhost]

TASK [Create a new Jira issue] ************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "['The requested API has been removed. Please migrate to the /rest/api/3/search/jql API. A full migration guideline is available at https://developer.atlassian.com/changelog/#CHANGE-2046']"}

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

Here is the link to the JIRA Ansible collection: https://docs.ansible.com/projects/ansible/latest/collections/community/general/jira_module.html#parameter-issuetype
When I go to the link https://developer.atlassian.com/changelog/#CHANGE-2046 it gives me a lot of information I do not understand how to turn into a solution to this problem. Usually, if something is deprecated, there is a superseding replacement module (for example, something like “jql.2.0”, of course, it doesnt exist). So, how do I alter my Ansible playbook above to get the query results with a different jql module?
It doesnt have to be Ansible code, could be any CLI code I will be able to run from a LINUX box. I will code it into a shell script and have Ansible execute it, instead of the deprecated jql.
Examples will be greatly appreciated. Thanks.
Nestor Kandinsky-Clerambeau.

This deprecation comes from Jira itself, the module is not deprecated, that is why an alternative module is not suggested.

This either requires the module to be updated or an alternate module be used (or created if it does not exist).

I checked in the repo and I cannot see a new module, nor an issue or PR addressing this issue, you might want to open one there. Issues · ansible-collections/community.general · GitHub

1 Like

@bcoca thank you. I posted this question in the JIRA internal board. They say I need to update the Python code in the Ansible module itself. I found an Ansible internal way to query JIRA without JQL in the meantime. Closing this thread. Thank you for taking the time to answer.

---
    - name: Get all task metadata for the DDI project 
      hosts: localhost
      connection: local
      gather_facts: true
      vars_files:
        - vars/main.yml

      tasks:

        - name: Set fact for Ansible date_time 
          delegate_to: localhost
          run_once: true
          set_fact: 
            currenttime: "{{ ansible_date_time.date }}"
          tags: linux

        - name: Display Ansible date fact
          ansible.builtin.debug:   
            var: currenttime          

        - name: Check the Status and the Assignment of the DDI Refresh project
          community.general.jira:
            uri: "{{ jira_url }}"
            username: "{{ jira_user }}"
            password: "{{ jira_api_token }}"
            project: DDI
            operation: fetch
#            issue: KAN-53
            issue: KAN-51
          register: jira_tasks

        - name: Display DDI Refresh task Status
          ansible.builtin.debug:   
            var: jira_tasks.meta.fields.status.name

        - name: Display DDI Refresh task Assignee
          ansible.builtin.debug:   
            var: jira_tasks.meta.fields.assignee.displayName

        - name: Display DDI Refresh Task Due Date
          ansible.builtin.debug:   
            var: jira_tasks.meta.fields.duedate

        - name: Announce Task launch if DDI Status is in Implementation, Assigned to Automation and Due Date is today
          debug:
            msg: "Status has changed to 'In Progress', the Task is now assigned to 'Automation API' and Due Date is today. Proceeding with DDI tasks automation at {{ ansible_date_time.iso8601 }}."
          when: >
            "In Progress" in jira_tasks.meta.fields.status.name and 
            "Automation API" in jira_tasks.meta.fields.assignee.displayName and 
            "{{ now(fmt='%Y-%m-%d') }}" in jira_tasks.meta.fields.duedate

####ADD MOVE TO IMPLEMETED, READY FOR REVIEW, UPLOAD RUN LOG TO JIRA
####ADD ACONDITIONAL TO IMPORT DIFFERENT DDI ROUTES BASED ON THE FORM DROPDOWN

        - name: Run Task if DDI Status is in Implementation, Assigned to Automation and Due Date is today
          ansible.builtin.import_tasks: ddi.yml
          when: >
            "In Progress" in jira_tasks.meta.fields.status.name and 
            "Automation API" in jira_tasks.meta.fields.assignee.displayName and 
            "{{ now(fmt='%Y-%m-%d') }}" in jira_tasks.meta.fields.duedate
          register: running_ddi_launch

        - name: Display DDI Refresh Task launch output
          ansible.builtin.debug:   
            var: running_ddi_launch

Output:

[ansible_admin@ctrl ansible]$ time ansible-playbook ./playbooks/jira.yml 
[WARNING]: Collection community.general does not support Ansible version 2.16.3

PLAY [Get all task metadata for the DDI project] **************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost]
[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 [Set fact for Ansible date_time] *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Display Ansible date fact] ******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "currenttime": "2026-04-19"
}

TASK [Check the Status and the Assignment of the DDI Refresh project] *****************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Display DDI Refresh task Status] ************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "jira_tasks.meta.fields.status.name": "In Progress"
}

TASK [Display DDI Refresh task Assignee] **********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "jira_tasks.meta.fields.assignee.displayName": "Automation API"
}

TASK [Display DDI Refresh Task Due Date] **********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "jira_tasks.meta.fields.duedate": "2026-04-19"
}
[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: "In Progress" in jira_tasks.meta.fields.status.name and  "Automation API" in jira_tasks.meta.fields.assignee.displayName and  "{{ now(fmt='%Y-%m-%d') }}" in jira_tasks.meta.fields.duedate

TASK [Announce Task launch if DDI Status is in Implementation, Assigned to Automation and Due Date is today] **************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "Status has changed to 'In Progress', the Task is now assigned to 'Automation API' and Due Date is today. Proceeding with DDI tasks automation at 2026-04-19T11:21:40Z."
}

TASK [Run the included DDI refresh route tasks on 2026-04-19T11:21:40Z | ddi.yml] *****************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "Starting the DDI refresh now 2026-04-19T11:21:40Z, it is expected to run 1hr07mins"
}

TASK [Display DDI Refresh Task launch output] *****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "Automation completed the DDI refresh successfully on 2026-04-19T11:21:40Z, moved the Task to Validation and uploaded all run logs to the JIRA. There are no more tasks. Thank you."
}

PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=10   changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   


real    0m2.686s
user    0m0.909s
sys     0m0.215s
[ansible_admin@ctrl ansible]$