regex_replace returning '\u0001'

212 views
Skip to first unread message

Guy Matz

unread,
Sep 19, 2014, 3:13:24 PM9/19/14
to ansible...@googlegroups.com
$ ansible-playbook --version
ansible-playbook 1.8 (devel 1d3a8bd39c) last updated 2014/09/18 10:33:54 (GMT -400)

Hello!  This is driving me bonkers . . .  can anyone see what I'm doing wrong here?

Setting a var, which is fine:
- name: Get VBox version for installing extension pack
  command: /usr/bin/VBoxManage --version
  register: vbox_ver

TASK: [workstation | debug msg={{ vbox_ver.stdout }}] ************************* 
ok: [localhost] => {
    "msg": "4.3.10_Ubuntur93012"
}

Then trying to set a fact based on that using regex_replace:
- name: Set major/minor number of vbox release
  set_fact: 
    vbox_ver_maj: "{{ vbox_ver.stdout | regex_replace('^(.*)_.*$','\\1') }}"

which gives me:
TASK: [workstation | debug msg={{ vbox_ver_maj }}] **************************** 
ok: [localhost] => {
    "msg": "\u0001"
}

when it should give me 4.3.10 . ..  any thoughts would be greatly appreciated!

Regards,
Guy

Matt Martz

unread,
Sep 19, 2014, 3:53:17 PM9/19/14
to ansible...@googlegroups.com
This happens when you do not have enough slashes.  There are a different number of slashes needed for escape based on if you are using complex args (YAML) as opposed to args (key=value)

complex args: \\\\
args: \\

So you need to increase your slashes to a total of 4

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CABnTgtWSv7hBvv1soiw1bA7S%3DGUBbL-bad%3D0gSBzxB%3DyZjH%2BNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Guy Matz

unread,
Sep 19, 2014, 4:19:55 PM9/19/14
to ansible...@googlegroups.com
Soooooo much better.  Thank you!!

Reply all
Reply to author
Forward
0 new messages