Linux aliases in shell...

35 views
Skip to first unread message

Sonny Chee

unread,
Oct 24, 2016, 9:52:15 PM10/24/16
to Ansible Project
Hey Guys,

Is there a way to make aliases available in a shell?  I tried sourcing a file with aliases before invoking my alias with no luck... ie:

shell:  . ~/.bash_aliases && my_command args

Any help would be appreciated.

Paul Tötterman

unread,
Oct 25, 2016, 4:29:18 AM10/25/16
to Ansible Project
Is there a way to make aliases available in a shell?  I tried sourcing a file with aliases before invoking my alias with no luck


 Aliases  are  not  expanded  when  the shell is not interactive, unless the expand_aliases shell option is set using shopt

Cheers,
Paul 

Sonny Chee

unread,
Oct 26, 2016, 7:55:30 PM10/26/16
to Ansible Project
Thanks Paul, that makes sense.

Is it possible to set this behavior within Ansible?  I tried the following without any luck...

  shell: rs -z blah_blah
  args:
    creates: "{{ current_flags }}/{{ item }}_{{ ansible_date_time.date }}"
    executable: /bin/bash +O expand_aliases

Paul Tötterman

unread,
Oct 27, 2016, 10:44:00 AM10/27/16
to Ansible Project
Is it possible to set this behavior within Ansible?  I tried the following without any luck...

I would recommend that you don't use aliases in non-interactive shells. If the script grows, maybe use the script-module instead  https://docs.ansible.com/ansible/script_module.html . Another option is to use shell functions instead of aliases.

Cheers,
Paul
Reply all
Reply to author
Forward
0 new messages