当前位置:网站首页>Ansible practical series I_ introduction

Ansible practical series I_ introduction

2022-07-06 11:01:00 hyh123a

Preface

 A need : Need to operate on multiple hosts .
 ok    frank , It's actually for the use of kubespray Deploy kubernetes Do matting 

Environmental Science

Ubuntu 20.04

1、 install

sudo apt install ansible

2、 Generate configuration ssh Secret key

ssh-keygen
ssh-copy-id [email protected]
ssh-copy-id [email protected]
ssh-copy-id [email protected]

3、 Example

sudo nano /etc/ansible/hosts

Revised as follows Define user name and password Not set up The default user name is root

[web]
172.16.106.20 ansible_ssh_user='ubuntu20' ansible_ssh_pass='AAbb0101' 
172.16.106.21 ansible_ssh_user='ubuntu20' ansible_ssh_pass='AAbb0101'
172.16.106.22 ansible_ssh_user='ubuntu20' ansible_ssh_pass='AAbb0101'
ansible web -m command -a 'uptime' 

Output is as follows

172.16.106.20 | CHANGED | rc=0 >>
 10:11:57 up 17 days,  5:13,  3 users,  load average: 0.47, 0.77, 1.21
172.16.106.22 | CHANGED | rc=0 >>
 10:11:57 up 17 days,  6:08,  1 user,  load average: 1.34, 1.13, 1.25
172.16.106.21 | CHANGED | rc=0 >>
 10:11:57 up 17 days,  5:45,  1 user,  load average: 1.44, 1.92, 1.99

other

If there is any omission, please add
If you have any questions, please leave a message
If it works, please like it

原网站

版权声明
本文为[hyh123a]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060912154661.html