【问题标题】:Unable to execute bashrc function using ANSIBLE无法使用 ANSIBLE 执行 bashrc 函数
【发布时间】:2019-09-20 13:18:04
【问题描述】:

我正在尝试使用 ANSIBLE 执行 bashrc 函数“enableSsh”。我正在使用下面的 ANSIBLE 代码来完成此操作,但出现错误:找不到 enableSsh 命令。

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

注意:我测试它删除 enableSsh 并重新加载 bashrc 工作正常。 enableSsh 是远程服务器的 bashrc 文件中定义的函数,如果直接从命令行执行,则可以正常工作。

【问题讨论】:

标签: ansible ansible-2.x


【解决方案1】:

这不是 Ansible 的问题,这是别名命令的缺点,如 here 所述。

【讨论】:

  • @Zeitounator OP 确实这么说,但我不认为他的意思是别名,因为我也无法重现函数的问题。在这方面,他的意见将受到欢迎。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-29
  • 2017-03-12
  • 1970-01-01
  • 2020-09-17
  • 2017-06-21
相关资源
最近更新 更多