Skip to content

k8s_drain ansible 2.19: Deprecation warning: Passing warnings to exit_json or fail_json is deprecated. #1031

@heinzelmannm

Description

@heinzelmannm
SUMMARY

Since upgrading to ansible 2.19 we receive deprecation warnings in our drain node playbook

ISSUE TYPE
  • Bug Report
COMPONENT NAME

k8s_drain

ANSIBLE VERSION
ansible [core 2.19.3]
  config file = None
  configured module search path = ['/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.12/site-packages/ansible
  ansible collection location = /runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.12.11 (main, Aug 14 2025, 00:00:00) [GCC 14.3.1 20250617 (Red Hat 14.3.1-2)] (/usr/bin/python3.12)
  jinja version = 3.1.6
  pyyaml version = 6.0.3 (with libyaml v0.2.5)
COLLECTION VERSION
Collection      Version
--------------- -------
kubernetes.core 6.2.0
CONFIGURATION
CONFIG_FILE() = None

GALAXY_SERVERS:
OS / ENVIRONMENT

ansible execution environment based on centros-stream:10 and python 3.12

STEPS TO REPRODUCE

Drain a k8s node

- name: Cordon Node
  kubernetes.core.k8s_drain:
    state: drain
    name: "{{ inventory_hostname_lower }}"
    delete_options:
      delete_emptydir_data: true
      ignore_daemonsets: true
      wait_sleep: 5
      wait_timeout: 180
      disable_eviction: true
      force: true
    pod_selectors:
      - 'app!=csi-attacher'
      - 'app!=csi-provisioner'
      - 'app!=rancher'
      - 'cnpg.io/podRole!=instance'
  retries: 20
  delay: 2
  when: "('control_plane' not in group_names) and updates_available"
  delegate_to: localhost
EXPECTED RESULTS

Drain works without any deprecation warning

ACTUAL RESULTS

Drain works with deprecation warning

[DEPRECATION WARNING]: Passing `warnings` to `exit_json` or `fail_json` is deprecated. This feature will be removed from ansible-core version 2.23. Use `AnsibleModule.warn` instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions