PeterMosmans / ansible-role-customize-gnome

Ansible role that customizes the GNOME desktop. It installs fonts and GNOME extensions from packages or zip files, copies files like desktop backgrounds and GNOME shell tweaks to a host, and modifies user settings.
GNU General Public License v3.0
74 stars 20 forks source link

Running `gnome-extensions list` makes the playbook fail if empty #28

Open LorenzoBettini opened 1 year ago

LorenzoBettini commented 1 year ago

Unfortunately, this commit https://github.com/PeterMosmans/ansible-role-customize-gnome/commit/9cc467351836d61a1708a998c2cb80dadf1c808c for fixing #25 broke my playbooks:

TASK [petermosmans.customize-gnome : Create a list of current enabled extensions] ***
fatal: [instance]: FAILED! => {"changed": true, "cmd": "gnome-extensions list --enabled > /tmp/before.txt", "delta": "0:00:00.020725", "end": "2023-02-23 10:07:43.979387", "msg": "non-zero return code", "rc": 2, "start": "2023-02-23 10:07:43.958662", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

I'm testing with with Molecule, and entering the container shows this:

[root@instance /]# gnome-extensions list
[root@instance /]# echo $?
2

So, you see that if the list of current extensions is empty, the command returns non zero code, making everything fail.

Maybe, it's enough to add a failed_when: false when running gnome-extensions list?

PeterMosmans commented 1 year ago

Hey @LorenzoBettini - Apologies for the regression there. That's a weird return code if the extension list is empty and yes, I think your solution is correct. Let me devise a fix...

PeterMosmans commented 1 year ago

Could you please check branch fix/28 to see whether that solves it? I haven't tested this locally

LorenzoBettini commented 1 year ago

@PeterMosmans I've just tested, again with Molecule, and now there's another problem:

TASK [petermosmans.customize-gnome : Restart Gnome Shell to ensure all extensions are visible] ***
fatal: [instance-arch]: FAILED! => {"changed": true, "cmd": ["killall", "-3", "gnome-shell"], "delta": "0:00:00.005887", "end": "2023-02-23 14:26:04.915698", "msg": "non-zero return code", "rc": 1, "start": "2023-02-23 14:26:04.909811", "stderr": "gnome-shell: no process found", "stderr_lines": ["gnome-shell: no process found"], "stdout": "", "stdout_lines": []}

Again, I think that gnome-shell should not be assumed to be up and running (failed_when: false), e.g., when running tests with Molecule.

On a side note, does this mean that if I run it instead from a currently running GNOME, the session will be restarted? Isn't that too dangerous?

mjbogusz commented 1 year ago

I'm hitting the same issue.

After installing the fix/28 branch I'm getting through the first 3 steps (download, create directories, unzip) but then it fails on the "restart shell" with a slightly different message:

TASK [petermosmans.customize-gnome : Restart Gnome Shell to ensure all extensions are visible] *************************************************************
fatal: [192.168.122.183]: FAILED! => {"changed": true, "cmd": ["killall", "-3", "gnome-shell"], "delta": "0:00:00.045724", "end": "2023-08-18 11:45:20.342190", "msg": "non-zero return code", "rc": 1, "start": "2023-08-18 11:45:20.296466", "stderr": "gnome-shell(7197): Operation not permitted\ngnome-shell: no process found", "stderr_lines": ["gnome-shell(7197): Operation not permitted", "gnome-shell: no process found"], "stdout": "", "stdout_lines": []}

This might be due to the fact that I'm trying to install some extensions for a non-sudoer user - do you think that #30 would help with this?

My target is Debian 12 (Gnome 43).

Edit: I've tried running this for a sudo-enabled user, restarting the shell worked but enabling extensions did not:

TASK [petermosmans.customize-gnome : Enable extensions] ****************************************************************************************************
failed: [192.168.122.183] (item=No overview at start-up) => {"ansible_loop_var": "item", "changed": false, "cmd": ["gnome-shell-extension-tool", "-e", "No","overview", "at", "start-up"], "delta": "0:00:00.023427", "end": "2023-08-18 12:00:50.172116", "failed_when_result": true, "item": {"enable": true, "id": 4099, "name": "No overview at start-up", "url": "https://extensions.gnome.org/download-extension/no-overview@fthx.shell-extension.zip?version_tag=39960"}, "msg": "non-zero return code", "rc": 1, "start": "2023-08-18 12:00:50.148689", "stderr": "", "stderr_lines": [], "stdout": "Usage: gnome-shell-extension-tool [options]", "stdout_lines": ["Usage: gnome-shell-extension-tool [options]"]}

This might be a separate issue though.

Edit2: the last bit indeed is a different issue - I've removed the "name" field from the gnome_extensions list as it contained spaces and now it works.

PeterMosmans commented 1 year ago

Thanks for reporting, and apologies for the bugs you're hitting. I'll try to look into this later next week

mjbogusz commented 1 year ago

No, thank you for the module ;) Even with the small problems it's quite helpful and I can see how many weird edge cases it already covers.

As I'm hitting some other weird behaviors (e.g. extensions being installed but not enabled) I'll try summarizing them in a separate issue(s) and/or creating PRs if I find fixes