shell module failing for grep

Greetings,

I'm running ansible 2.9 (2.9.4+dfsg-1) and I've searched the mailing
list archives regarding this issue, but I haven't found out why I'm
seeing what I am seeing.

shell module is failing when I'm not expecting it to.

I run this command manually on my system:

$ dconf dump /org/mate/desktop/keybindings/ | grep "action='chromium'"
action='chromium'

but in ansible:

- name: get dconf desktop/keybindings for chromium
  shell: dconf dump /org/mate/desktop/keybindings/ | grep "action='chromium'"
  register: dconf_desktop_keybindings
  ignore_errors: True

and the output:

fatal: [zipper]: FAILED! => {"changed": true, "cmd": "dconf dump
/org/mate/desktop/keybindings/ | grep \"action='chromium'\"", "delta":
"0:00:00.005304", "end": "2020-02-21 14:24:31.441719", "msg":
"non-zero return code", "rc": 1, "start": "2020-02-21 14
:24:31.436415", "stderr": "", "stderr_lines": , "stdout": "",
"stdout_lines": }

Any ideas why it is failing?

Thanks for any help!

-m

SOLVED.

Ansible is using the root account, but dconf is using my user account.

Sorry for the noise!

-m

Hi,

Did you submit the shell command with the same user ?

Regards,

Thanks for the reply!

You are correct. It was the user that I ran the command as that was the issue.

For solving it, instead of:

become: yes
become_user: foo

I opted for:

su - foo -c

because it was a single point of entry for ansible into the target
system. That is the root account.

Thanks for the help!

-m