Linux - ansible 安装

时间:2023-03-10 06:42:18
Linux - ansible 安装

# 安装依赖

yum install rpm-build python2-devel sshpass PyYAML python-jinja2 python-paramiko python-six python2-cryptography

git clone git://github.com/ansible/ansible.git
cd ansible/
make rpm
cd rpm-build/
sudo rpm -Uvh ansible-*.noarch.rpm

# 添加host
vi /etc/ansible/hosts

# 查看服务器是否连通
ansible all -m ping

Linux - ansible 安装

# 远程执行本地脚本
$ ansible 172.16.10.15 -m script -a '~/shell/getSysInfo' -u huateng

Linux - ansible 安装

问题汇总:

1、远程服务器执行本地脚本时提示:command not found

具体现象如下

Linux - ansible 安装

解决方法:

在执行脚本的时候,加载当前的环境变量即可。