You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
New to Ansible, having trouble doing the following: shell command returns a "This is a test\u0000" string. I can't seem to find a way to trim the '\u0000'. Since it seem to be tricking to remove a backslash literal in Ansible?
The following would work in a shell command...
cat /proc/device-tree/model | cut -d '\' -f1
But Ansible chokes on the '\'? And even '\\' does not work since cut command can't handle more than one char. So the cut parsing trips or Ansible parsing trips. A bit of a catch-22.
Figure there has to be an Ansible elegant way to do this?
Any help appreciated.
Stefan Hornburg (Racke)
unread,
Jan 14, 2022, 2:49:54 PM1/14/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
- debug:
msg: "{{ input | regex_replace('\\\\u0000', '') }}"
vars:
input: 'This is a test\u0000'
You might need *four* backslashes to get rid of the original backslash.
But you can get away with *two" by swapping the quotes:
- debug:
msg: '{{ input | regex_replace("\\u0000", "") }}'
vars:
input: 'This is a test\u0000'
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
You haven't posted any Ansible for us to help you with. Could you include something you think should work but doesn't? Otherwise we're just guessing what you're trying to do, and that rarely works well for anybody.