ansible使用shell模块的环境变量问题

在本机写了一个shell脚本,关于操作mysql的,在本机执行脚本可以正常操作数据库,脚本运行正常。
但是使用ansible

ansible -i ./hosts test_teledb -m copy -a "src=/etc/ansible/scripts/check.sh dest=/tmp"

ansible -i ./hosts test_teledb -m shell  -a "sh /tmp/check.sh"    

却报错
mysql :command not found

解决办法
通过在脚本中输出 whoami 查看ansible推送的脚步执行用户,如果用户是正确的,在脚本的头部位置添加

source ~/.bash_profile

相关推荐

  1. ansible使用shell模块环境变量问题

    2024-04-12 06:16:02       35 阅读
  2. ansibleansible模块使用

    2024-04-12 06:16:02       38 阅读
  3. linux shell脚本不加载环境变量问题

    2024-04-12 06:16:02       36 阅读
  4. Ansible变量

    2024-04-12 06:16:02       51 阅读
  5. Mac shell 环境变量配置

    2024-04-12 06:16:02       36 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-12 06:16:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-12 06:16:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-12 06:16:02       87 阅读
  4. Python语言-面向对象

    2024-04-12 06:16:02       96 阅读

热门阅读

  1. g++ 13.2.0 编译 C++模块

    2024-04-12 06:16:02       42 阅读
  2. 数据结构(二)——链表的介绍以及单链表的实现

    2024-04-12 06:16:02       47 阅读
  3. Redis数据持久化的方式

    2024-04-12 06:16:02       77 阅读
  4. 代码随想录训练营-15day:二叉树4

    2024-04-12 06:16:02       35 阅读
  5. Css 和OpenCv.js 多种方式实现图像叠加 / 图像融合

    2024-04-12 06:16:02       34 阅读
  6. vue-指令v-for

    2024-04-12 06:16:02       137 阅读
  7. HTTP状态码大全:常见状态码一网打尽

    2024-04-12 06:16:02       38 阅读
  8. 构建CICD

    2024-04-12 06:16:02       28 阅读
  9. Binary Tree Mock

    2024-04-12 06:16:02       31 阅读
  10. 微服务支持平台--限流算法

    2024-04-12 06:16:02       34 阅读