How to find out in which file a specific plasma setting is - and other ansible questions

So, I am currently starting to automize my postinstall script with Ansible. Most of it are easy tasks like copy a file, changing a line, adding a block or similar - I got this covered in time. But what is giving me headache is KDE, namely the plasma config.
The way to go is via community.general.kdeconfig ansible module, which calls (basically) kwriteconfig. But to use kwriteconfig properly I have to know which setting is in which file. My first task would be to change the default floating behaviour of the main panel to no, than change the menu to simple menu, and so on.
How do I find out where this setting is? Any help is appreciated.

I don’t know…but I would suggest a methodology if nothing else pans out. Take a ls -alR snapshot (redirect into a file).
Change the setting manually.
Take another snapshot of ls.
Diff the files.
You’ll get there.

1 Like

I’m using this reference

And just in case, here’s my playbook


This looks very promising @lorebett - I ow you!
will probably ask for further help later (which you can ignore ofc) but this is a GREAT starting point - TYVM!


I usually change the setting manually then use find in a terminal to search for all files changed in the last minute. Then just choose the one that looks kde related.

If you know the name of the setting, you could use grep -ri to find it.
See also man grep.

1 Like

So, after a week of vacation I am back to my ansible endevour, and boy am I struggling. Especially with finding the base KDE settings for my base panel.
In the meantime - due to all the struggeling - I came back to some more basic tasks: Installing and configuring programs. And one of those gives me headache. It is eza. To make eza work one has to install it and then add some aliases to bashrc. This will then look like this:

# ls to eza
alias ls='eza --color=always --group-directories-first --icons'     # ls
alias ll='eza -la --icons --octal-permissions --group-directories-first'
alias l='eza -albGF --header --git --color=always --group-directories-first --icons' # long list
alias llm='eza -lbGd --header --git --sort=modified --color=always --group-directories-first --icons' # long list, modified date sort
alias la='eza --long --all --group --group-directories-first'
alias lx='eza -lbhHigUmuSa@ --time-style=long-iso --git --color-scale --color=always --group-directories-first --icons' # all + extended list

When I start from a naked EOS installation there is already an ls alias present:

alias ls='ls --color=auto'

This has to be removed or better - outcommended. So I have to outcommend this line and add my own. Adding my own is kinda trivial, but replacing the already present one not so. Difficulty here seems to be the escaping, but boy makes Ansible this complicated, it seems. I tried this part in my playbook:

    - name: remove alias ls
        path: ~/.bashrc
        regexp: 'alias ls=ls --color=auto'
        replace: '#alias ls=ls --color=auto'

Which gives a strange error message:

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
  did not find expected key

The error appears to be in '/home/milkytwix/git/eos-ansible/playbook_eza.yml': line 16, column 29, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

        replace: "#alias ls^=ls --color=auto"
                            ^ here

There appears to be both 'k=v' shorthand syntax and YAML in this task. Only one syntax may be used.

I have tried to put the regexp and replace in " and ', I tried to escape the # and = with various escaping sequences like /, , ^, ^^, and so forth, to no avail… Anybody an Idea how to get rid of this line in my bashrc?

Haven’t used ansible, but they say ( in the beginning:

Ansible is a radically simple IT automation system.

Can you do

unalias ls 2>/dev/null


Also, why do you need to remove the ls alias? When you alias ls again, it just overwrites the old one.

1 Like

Well, “simple” is something I always find hillarious in such descriptions - no one would call his solution “overcomplicated”…

I just tried the unalias stuff, will not change anything in my bashrc, it leaves the setting as if I never shot the command.
On top of it not working, this would not be what I want to achieve - my approach regarding config files always is to leave the original setting and just commend it out, so that I know what I have changed. This can be perfectly achieved with other stuff I did with ansible, even the block is commented as “Changed by Ansible” - which I really like.
So: How to commend out that line? All I want is to add a simple “#” to a specific line… This can’t be so complicated, can it?

If I just add another alias to the file, which one is taken? The first? The last? Seems.-… wrong to me.

Yes, that’s the way. In bash files if the first non-space character on a line is #, then the line is commented out.

1 Like

I know that that is the way. I don’t know how to do it with ansible…

Not sure why you want to use ansible for that. The more moving parts you have in the system, the more complex it gets to maintain it.

And note, if the default .bashrc changes one day, you’d need to adjust your ansible stuff accordingly again.

Here’s a link that might help:
If that doesn’t help, hopefully some ansible guru here can chime in.

1 Like

Why I want to do that? Because I want to automate my whole installation. And yes, that would include maintaining it when I am done. I am perfectly fine with that - actually I see this as an advantage.
I allready tried the lineinfile module - the error stays the same, it gets offended by the “=”…

Just use double quotes for regex/replace lines, this works for me

# Test playbook
- hosts: localhost

  - name: Comment llx alias
      path: ~/.bashrc
      regexp: "^alias llx='ls -laX'"
      replace: "#alias llx='ls -laX'"
1 Like

This actually worked, tyvm - all examples I could find where with single quotes - yay!
Next up: changing the panel (floating is like fugly as hell imho), adding konsole profiles and maklng them default, adding yay to ansible, and so on and so on…

So, next issue I am facing, maybe @lorebett has an idea for that.
I have a working ansible playbook which is working on my development machine, but not on my test machine. When I fire the playbook I get the following error:

ansible-playbook --check playbook_kde.yml 
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [KDE settings] ****************************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************
ok: [localhost]

TASK [Change panel to non floating] ************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "kwriteconfig is not installed"}

PLAY RECAP *************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

But if I try kwriteconfig directly it is working:

kwriteconfig6 --help
Usage: kwriteconfig6 [options] value

  -h, --help       Displays help on commandline options.
  --help-all       Displays help, including generic Qt options.
  --file <file>    Use <file> instead of global config
  --group <group>  Group to look in. Use "<default>" for the root group, or use
                   repeatedly for nested groups.
  --key <key>      Key to look for
  --type <type>    Type of variable. Use "bool" for a boolean, otherwise it is
                   treated as a string
  --delete         Delete the designated key if enabled

  value            The value to write. Mandatory, on a shell use '' for empty

I have installed kconfig, so that is that - how do I get ansible to work with kwriteconfig? Any idea?

Another tip if anyone is reading this later on:
Ansible is using kwriteconfig, so during development time it is easier to test with kwriteconfig and when everything is working transfer it over to ansible. Example:

kwriteconfig6 --file ~/.config/plasmashellrc --group "PlasmaViews" --group "Panel 2" --key floating 0

is the same as in

- name: KDE settings
  hosts: localhost
  connection: local
    - name: Change panel to non floating
        path: ~/.config/plasmashellrc
          - groups: PlasmaViews, Panel 3
            key: floating
            value: 0

I’m not sure I understand; you have to install that program if you want to use it.

The programm is kwritconfig. It is used by ansible. Kwriteconfig works if used directly, so it is installed. But ansible says it ain’t…

I seem to understand that the name ends with 6, it should be an Arch choice, so the Ansible module might not find it because it expects the standard name. Maybe the Ansible module has a way to specify the name of the executable.

In my playbook I think I use another module for KDE configuration files.