背景:当我们Linux机器的环境没办法链接外网时可以使用离线安装的方式进行。
前提:python环境
一、离线包安装
setuptools模块安装
https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz
tar xvzf setuptools-7.0.tar.gz
cd setuptools-7.0
python setup.py install
pycrypto模块安装
https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz
tar xvzf pycrypto-2.6.1.tar.gz
cd pycrypto-2.6.1
python setup.py install
PyYAML模块安装
http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
tar xvzf yaml-0.1.5.tar.gz
cd yaml-0.1.5
./configure --prefix=/usr/local
make --jobs=`grep processor /proc/cpuinfo | wc -l`
make install
https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz
tar xvzf PyYAML-3.11.tar.gz
cd PyYAML-3.11
python setup.py install
Jinja2模块安装
https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.9.3.tar.gz
tar xvzf MarkupSafe-0.9.3.tar.gz
cd MarkupSafe-0.9.3
python setup.py install
https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz
tar xvzf Jinja2-2.7.3.tar.gz
cd Jinja2-2.7.3
python setup.py install
paramiko模块安装
https://pypi.python.org/packages/source/e/ecdsa/ecdsa-0.11.tar.gz
tar xvzf ecdsa-0.11.tar.gz
cd ecdsa-0.11
python setup.py install
https://pypi.python.org/packages/source/p/paramiko/paramiko-1.15.1.tar.gz
tar xvzf paramiko-1.15.1.tar.gz
cd paramiko-1.15.1
python setup.py install
simplejson模块安装
https://pypi.python.org/packages/source/s/simplejson/simplejson-3.6.5.tar.gz
tar xvzf simplejson-3.6.5.tar.gz
cd simplejson-3.6.5
python setup.py install
ansible安装
https://github.com/ansible/ansible/archive/v1.7.2.tar.gz
tar xvzf ansible-1.7.2.tar.gz
cd ansible-1.7.2
python setup.py install
二、Ansible配置
1. 配置SSH远程登录功能
注,如果之前已经执行过跳过这部
ssh-keygen
将 id_rsa 拷贝到目标节点机器上去,执行以下命令:
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
2. ansible配置
管理主机上面执行
mkdir -p /etc/ansible
# 进入ansible安装包,将example文件夹下的ansible.cfg拷贝到新建的文件夹下
cp examples/ansible.cfg /etc/ansible/
# 接下来定义目标节点机器:
vim /etc/ansible/hosts
localhost
三、ansible功能测试
1. ping所有目标机器
ansible all -m ping
2. 将本地文件复制到远程服务器
ansible all -m copy -a "src=/home/test/test.sh dest=/home/target/target.sh owner=root group=root mode=0755"
3. 远程执行脚本
ansible all -m shell -a "/home/target/target.sh"
Ansible GitHub地址:https://github.com/ansible/ansible
参考:https://www.jianshu.com/p/8ed33efa0139?tdsourcetag=s_pcqq_aiomsg
标签:install,tar,python,离线,gz,Ansible,https,安装,ansible From: https://www.cnblogs.com/Mercury-linux/p/16599890.html