2

I am trying to execute a bashrc function "enableSsh" using ANSIBLE. I am using below ANSIBLE code to get this done but getting error: enableSsh command not found.

- name: Switch to user root and enable ssh
  become: yes
  become_user: root
  become_method: su
  shell: . .bashrc && enableSsh
  args:
    executable: /bin/bash

Note: I tested it removing enableSsh and reloading bashrc is working fine. enableSsh is a function defined in remote server's bashrc file and works fine if execute directly from command line.

Ujjawal Khare
  • 756
  • 2
  • 7
  • 20
  • 1
    Try to specify the complete path to the file you want to source. See [here](https://stackoverflow.com/a/27541856/1137055). – dgw Sep 20 '19 at 13:29
  • 1
    I cannot reproduce your problem: https://gist.github.com/zeitounator/c6c0e27a60c2a3ea1e430353153f19a3 – Zeitounator Sep 21 '19 at 10:27

1 Answers1

1

This is not an issue with Ansible, this is a shortcoming of the alias command as explained here.

Alassane Ndiaye
  • 4,427
  • 1
  • 10
  • 19
  • 1
    @Zeitounator OP did say that but I don't think it's out of question that he meant aliases since I can't reproduce the problem with functions either. On that note, his input would be welcome. – Alassane Ndiaye Sep 21 '19 at 11:10