Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community.general.dconf task fails if key does not exist #6271

Closed
1 task done
lsampaioweb opened this issue Apr 2, 2023 · 8 comments
Closed
1 task done

community.general.dconf task fails if key does not exist #6271

lsampaioweb opened this issue Apr 2, 2023 · 8 comments
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) system traceback

Comments

@lsampaioweb
Copy link

Summary

When I try to run the module "community.general.dconf" to insert a value on a key that has no previous value, it throws an error (Argument 1 does not allow None as a value).
** Any value and on any key. I even tried with the ones from the Ansible Docs.
** I installed the community.general and psutils.

If I set the value manually and then run the playbook, it works! I also tried become: true, but I get another error.

01 - Just run the playbook, it does not work.

  • name: "Setting the dark theme"
    become: false
    community.general.dconf:
    key: "/org/gnome/desktop/interface/color-scheme"
    value: "'prefer-dark'"
    state: "present"

02 - Set value manually and then run the playbook, it works!
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'"

  • name: "Setting the dark theme"
    become: false
    community.general.dconf:
    key: "/org/gnome/desktop/interface/color-scheme"
    value: "'prefer-dark'"
    state: "present"

dconf read /org/gnome/desktop/interface/color-scheme

It shows the correct value.

Issue Type

Bug Report

Component Name

dconf

Ansible Version

$ ansible --version
ansible [core 2.14.4]
  config file = None
  configured module search path = ['/home/<my_user>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/<my_user>/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/<my_user>/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/<my_user>/.local/bin/ansible
  python version = 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
# /home/<my_user>/.local/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 6.5.0  

# /usr/local/lib/python3.10/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 6.5.0  

# /home/<my_user>/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 6.5.0 

Configuration

$ ansible-config dump --only-changed

OS / Environment

Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy

Steps to Reproduce

- name: "Setting the dark theme"
  become: false
  community.general.dconf:
    key: "/org/gnome/desktop/interface/color-scheme"
    value: "'prefer-dark'"
    state: "present"

Expected Results

I expected to dconf change the value from the key, not to throw an error.

Actual Results

TASK [setup_user : Setting the dark theme] **********************************************************************************************************************************************
sábado 01 abril 2023  21:39:42 -0300 (0:00:00.356)       0:00:01.665 ********** 
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: Argument 1 does not allow None as a value
fatal: [temp-jump-server]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 192.168.0.125 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/<my_user>/.ansible/tmp/ansible-tmp-1680395982.7786345-15187-83724327666096/AnsiballZ_dconf.py\", line 107, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/<my_user>/.ansible/tmp/ansible-tmp-1680395982.7786345-15187-83724327666096/AnsiballZ_dconf.py\", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/<my_user>/.ansible/tmp/ansible-tmp-1680395982.7786345-15187-83724327666096/AnsiballZ_dconf.py\", line 47, in invoke_module\r\n    runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.dconf', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.dconf', _modlib_path=modlib_path),\r\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\r\n    _run_code(code, mod_globals, init_globals,\r\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_community.general.dconf_payload_z7s65u2n/ansible_community.general.dconf_payload.zip/ansible_collections/community/general/plugins/modules/dconf.py\", line 438, in <module>\r\n  File \"/tmp/ansible_community.general.dconf_payload_z7s65u2n/ansible_community.general.dconf_payload.zip/ansible_collections/community/general/plugins/modules/dconf.py\", line 430, in main\r\n  File \"/tmp/ansible_community.general.dconf_payload_z7s65u2n/ansible_community.general.dconf_payload.zip/ansible_collections/community/general/plugins/modules/dconf.py\", line 338, in write\r\n  File \"/tmp/ansible_community.general.dconf_payload_z7s65u2n/ansible_community.general.dconf_payload.zip/ansible_collections/community/general/plugins/modules/dconf.py\", line 292, in variants_are_equal\r\nTypeError: Argument 1 does not allow None as a value\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) system traceback labels Apr 2, 2023
@felixfontein
Copy link
Collaborator

CC @jikamens

@jikamens
Copy link
Contributor

jikamens commented Apr 2, 2023

This is fixed in #6206.

@LorenzoBettini
Copy link

@jikamens thanks! Any estimation concerning the release of the fixed version?

@jikamens
Copy link
Contributor

jikamens commented Apr 3, 2023

The fix will be in the next release of community.general, though I don't know when that will be, and if you're using community.general from a third-party vendor repo rather than straight from the Ansible repo then it could be some time after Ansible releases the new version before your vendor updates to it.
In the meantime if you'd like you can create a "library" directory in the same directory as the playbook that uses dconf that is encountering this issue and save https://raw.githubusercontent.com/jikamens/community.general/a37589cebd5d6ca1b0e1ea963c0ed26eb5019f7b/plugins/modules/dconf.py in that directory and Ansible will automatically use your fixed copy of the module rather than the one in the distro.

@felixfontein
Copy link
Collaborator

The fix will be in the next release of community.general, though I don't know when that will be

The next minor release will happen on ~April 24th (see #582).

@felixfontein
Copy link
Collaborator

Closing since a PR fixing this has been merged (and will get released ~tomorrow).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) system traceback
Projects
None yet
Development

No branches or pull requests

5 participants