Skip to content

Wrong "changed state" with some value (postgresql_set) #110

@skilyazhnev

Description

@skilyazhnev
SUMMARY

track_activity_query_size the parameter incorrectly processes the dimension of the value in bytes.
When I define track_activity_query_size in bytes (2048B) it is incorrectly defined in kilobytes (2kB),
and call changed state in step

ISSUE TYPE
  • Bug Report
COMPONENT NAME

postgresql_set

ANSIBLE VERSION
ansible [core 2.11.2] 
  config file = /home/user/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.local/bin/ansible
  python version = 3.8.10 (default, Jun  2 2021, 10:49:15) [GCC 9.4.0]
  jinja version = 2.10.1
  libyaml = True
COLLECTION VERSION
$ ansible-galaxy collection list

# /home/user/.ansible/collections/ansible_collections
Collection           Version
-------------------- -------
community.postgresql 1.3.0  
CONFIGURATION
$ ansible-config dump --only-changed
$
OS / ENVIRONMENT

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

STEPS TO REPRODUCE

just run playbook

---
- hosts: localhost
  vars:

  tasks:
    - name: change config
      community.postgresql.postgresql_set: 
            name: track_activity_query_size
            value: 2048B
      become_user: postgres
      notify: postgresql__restart_service

  handlers:
    - name: postgresql__restart_service
      ansible.builtin.service:
        name: postgresql@12-main.service
        state: restarted
      become: true
EXPECTED RESULTS

i expected right comparison with kB and B. Maybe it can reproduce for other parameters.
I think module doesn't must call change state for real equal values, because this makes the module useless (in this case).

ACTUAL RESULTS
changed: [localhost] => {
    "changed": true,
    "context": "postmaster",
    "invocation": {
        "module_args": {
            "ca_cert": null,
            "db": null,
            "login_host": "",
            "login_password": "",
            "login_unix_socket": "",
            "login_user": "postgres",
            "name": "track_activity_query_size",
            "port": 5432,
            "reset": false,
            "session_role": null,
            "ssl_mode": "prefer",
            "trust_input": true,
            "value": "2048B"
        }
    },
    "name": "track_activity_query_size",
    "prev_val_pretty": "2kB",
    "restart_required": true,
    "value_pretty": "2048B"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions