foreman-ansible-modules icon indicating copy to clipboard operation
foreman-ansible-modules copied to clipboard

theforeman.foreman.setting doesn't handle default value (null) correctly

Open gvde opened this issue 2 years ago • 0 comments

SUMMARY

theforeman.foreman.setting in 3.4.0 doesn't set null, if null is default and settings is supposed to be reset but sets empty string "" instead. For example:

State before:

$ curl -s -n https://foreman8.example.com/api/settings/remote_execution_cockpit_url | jq
{
  "description": "Where to find the Cockpit instance for the Web Console button.  By default, no button is shown.",
  "settings_type": "string",
  "default": null,
  "updated_at": "2022-06-15 08:34:53 UTC",
  "id": "remote_execution_cockpit_url",
  "name": "remote_execution_cockpit_url",
  "full_name": "Cockpit URL",
  "value": null,
  "category": "remote_execution",
  "category_name": "Remote Execution",
  "readonly": false,
  "config_file": null,
  "encrypted": false,
  "select_values": null
}

running ansible

TASK [theforeman.foreman.settings : Create Settings] **************************************************
--- before
+++ after
@@ -2,7 +2,8 @@
     "settings": [
         {
             "id": "remote_execution_cockpit_url",
-            "name": "remote_execution_cockpit_url"
+            "name": "remote_execution_cockpit_url",
+            "value": ""
         }
     ]
 }

changed: [foreman8.dkrz.de] => (item={'name': 'remote_execution_cockpit_url'})

state after:

$ curl -s -n https://foreman8.example.com/api/settings/remote_execution_cockpit_url | jq
{
  "description": "Where to find the Cockpit instance for the Web Console button.  By default, no button is shown.",
  "settings_type": "string",
  "default": null,
  "updated_at": "2022-06-15 08:34:53 UTC",
  "id": "remote_execution_cockpit_url",
  "name": "remote_execution_cockpit_url",
  "full_name": "Cockpit URL",
  "value": "",
  "category": "remote_execution",
  "category_name": "Remote Execution",
  "readonly": false,
  "config_file": null,
  "encrypted": false,
  "select_values": null
}
ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible [core 2.12.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/k/k111111/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /home/k/k111111/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.12 (default, Apr 21 2022, 07:55:08) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]
  jinja version = 3.0.2
  libyaml = False
COLLECTION VERSION
$ ansible-galaxy collection list

# /usr/share/ansible/collections/ansible_collections
Collection         Version
------------------ -------
redhat.rhel_mgmt   1.0.0  
theforeman.foreman 3.1.0  

# /home/k/k111111/.ansible/collections/ansible_collections
Collection         Version
------------------ -------
theforeman.foreman 3.4.0  

KATELLO/FOREMAN VERSION
$ rpm -q katello foreman
katello-4.4.1-1.el8.noarch
foreman-3.2.1-1.el8.noarch
STEPS TO REPRODUCE
---
- name: configure foreman server
  hosts: foreman
  gather_facts: false

  roles:
    - role: theforeman.foreman.settings
      vars:
        foreman_settings:
          - "name": "remote_execution_cockpit_url"

No value parameter set!

EXPECTED RESULTS

It shouldn't insert an empty string but use null instead.

ACTUAL RESULTS

Setting value it set to empty string "" instead of null.

gvde avatar Jun 15 '22 08:06 gvde