strange issue when using variable in shell module

43 views
Skip to first unread message

Cai Elvis

unread,
Mar 28, 2016, 9:57:59 AM3/28/16
to Ansible Project
Hi guys

i met a wield issue in ansible when using variable including '@' sign, if my variable including @, it will turn to empty totally and the debug infomation is hello world, when i  remove @ sign, the result is normal, is there anyone could help? thanks in advance! :-)

TASK: [vas | debug username] ************************************************** 

ok: [cnshget04.xxx] => {
    "msg": "Hello world!"

TASK: [vas | vas installing...] *********************************************** 
failed: [cnshget04.xxx] => {"cmd": "/opt/quest/bin/vastool -u ''

task file:
- name: vas installing...
  shell: >
    "{{vastool_binary}}" -u "{{username}}"

default file:
-sh-4.1$ cat defaults/main.yml  | grep username
username: 'username'

my playbook:
    - role: vas
      username: a...@eapac.abc.se

my ansible version is 1.9.4





Brian Coca

unread,
Mar 28, 2016, 11:09:38 AM3/28/16
to ansible...@googlegroups.com
@ is special in bash, use single quotes to avoid interpolation `-u '{{username}}'`

--
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/7b1de730-7594-4f82-aa73-813d0830bafe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
----------
Brian Coca

Cai Elvis

unread,
Mar 28, 2016, 9:56:44 PM3/28/16
to Ansible Project
thanks for your quick replay, unfortunately, it works the same like before. 

TASK: [vas | vas installing...] *********************************************** 
failed: [cnshget04.xxx] => {"cmd": "/opt/quest/bin/vastool -u '' 

task file:
  shell: >
    "{{vastool_binary}}" -u '{{username}}'



在 2016年3月28日星期一 UTC+8下午11:09:38,Brian Coca写道:

Johannes Kastl

unread,
Mar 29, 2016, 4:03:12 AM3/29/16
to ansible...@googlegroups.com
Am 29.03.16 schrieb Cai Elvis:
> thanks for your quick replay, unfortunately, it works the same like before.

>>> my playbook:
>>> - role: vas
>>> username: a...@eapac.abc.se <javascript:>

Shouldn't this be like this:

- role: vas
vars:
- username: foobar

Johannes

signature.asc
Message has been deleted

Cai Elvis

unread,
Mar 30, 2016, 6:20:01 AM3/30/16
to Ansible Project
I think it works, please see my whole yml file.
---
# file: test.yml
- hosts: mytest
  gather_facts: yes
  roles:
    - role: dnsclient
      nameservers:
        - 1.1.1.1
        - 2.2.2.2
        - 3.3.3.3
      search:
        - sh.cn.ao.abcompany.se
        - cn.ao.abcompany.se
        - ao.abcompany.se
        - abcompany.se
        - rnd.abcompany.se
#    - role: ntp
    - role: nsswitch
      ensure_vas: present
    - role: proxy
      group: root
      port: '8080'
      https_server: 'http://hubproxy.sh.cn.ao.abcompany.se'
      https_port: '8080'
      no_proxy:
        - localhost
        - 127.0.0.1
#    - role: ssh
    - role: pam
      ensure_vas: present
      allowed_users:
        - root
        - user123
        - ALL
      limits_fragments:
        msdp:
          list:
            - "* hard nofile 65535"
            - "* soft nofile 65535"
            - "drutt hard nproc 65535"
            - "drutt soft nproc 65535"
    - role: vas
      username: instc...@eapac.abcompany.se
      package_version: '4.1.0-22002'
      keytab_source: 'vasinst.key'
      vas_conf_update_process: '/opt/quest/libexec/vas/mapupdate_2307'
      users_allow_entries:
        - cnsh...@abcompany.se
        - ABC\cnshrndithub
        - ABC\hub-adm-cnsh
      computers_ou: 'OU=UNIX,OU=ABC,OU=HUB,OU=P006,OU=SVC,OU=Data,DC=abcompany,DC=se'
      users_ou: 'ou=sh,ou=China,ou=users,ou=eunix,dc=eapac,dc=abcompany,dc=se'
      nismaps_ou: 'OU=NIS,OU=ABC,OU=HUB,OU=P006,OU=SVC,OU=Data,DC=abcompany,DC=se'
      realm: 'ABC.SE'
      sitenameoverride: Sapac09
      vas_conf_upm_computerou_attr: 'department'
      vas_conf_libvas_auth_helper_timeout: '120'
      vas_conf_vasd_cross_domain_user_groups_member_search: 'true'
      vas_conf_preload_nested_memberships: 'false'
      symlink_vastool_binary: 'true'

在 2016年3月29日星期二 UTC+8下午4:03:12,Johannes Kastl写道:
Reply all
Reply to author
Forward
0 new messages