“Ansible基础”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
第94行: 第94行:
 
</pre>
 
</pre>
 
[https://blog.csdn.net/wszll_Alex/article/details/77688224  ansible批量传输文件]
 
[https://blog.csdn.net/wszll_Alex/article/details/77688224  ansible批量传输文件]
 +
 +
[https://zdyxry.github.io/2019/11/22/%E4%BD%BF%E7%94%A8-Ansible-%E4%BC%A0%E8%BE%93%E6%96%87%E4%BB%B6%E7%9A%84%E5%87%A0%E7%A7%8D%E6%96%B9%E5%BC%8F/ 使用 Ansible 传输文件的几种方式]
  
 
=see also=
 
=see also=
 
[[category:devops]]
 
[[category:devops]]

2021年9月23日 (四) 07:43的版本

ins

#on master
pip3 install --user ansible

ssh-copy-id  -i  id_ecdsa.pub [email protected]
ssh-copy-id  -i  id_ecdsa.pub [email protected]
ssh-copy-id  -i  id_ecdsa.pub [email protected]



mkdir   /etc/ansible
vi /etc/ansible/hosts

192.168.88.50
192.168.88.51
192.168.88.52

[intra]
192.168.10.120
192.168.10.121

 ansible  all  -b -u root  -a "hostname"
192.168.88.51 | CHANGED | rc=0 >>
k8s-node1
192.168.88.50 | CHANGED | rc=0 >>
k8s-master
192.168.88.52 | CHANGED | rc=0 >>
k8s-node2


 ansible all -m ping

配置文件




ansible在使用配置文件时按照以下顺序优先配置:

export ANSIBLE_CONFIG

./ansible.cfg

~/.ansible.cfg

/etc/ansible/ansible.cfg

如果以上顺序没有找到配置文件ansible会自动使用默认配置

可以去github上把默认配置拿下来:

https://raw.githubusercontent.com/ansible/ansible/devel/examples/ansible.cfg
# To generate an example config file (a "disabled" one with all default settings, commented out):
#               $ ansible-config init --disabled > ansible.cfg

# Also you can now have a more complete file by including existing plugins:
# ansible-config init --disabled -t all > ansible.cfg

把它放到/etc/ansible/目录


ansible配合shell脚本批量编译安装python3.7

https://github.com/evan886/my-ansible

具体安排脚本here https://github.com/evan886/my-ansible/tree/main/ansible4py3.7ins

git clone [email protected]:evan886/my-ansible.git

cd ansible4py3.7ins/


ansible配合shell脚本批量编译安装python3.6.6

分发文件

 

 cat /etc/ansible/hosts
[intra]
192.168.10.120
192.168.10.121



ansible intra -m copy -a "src=/home/evan/data/devops/node-v14.17.6-linux-x64.tar.xz  dest=/root/"


ansible批量传输文件

使用 Ansible 传输文件的几种方式

see also