行业知识
ansible免密登陆脚本
2026-10-29 22:01:34
来源:互联网转载
ansiindex.php/tags-41973.html" >ble配置免密
()group_vars/└── all.yml #填写'k8s_cluster_info'变量信息inventory/ #填写主机信息├── hostsautossh/├── files│ └── ssh-key-gen.sh├── tasks│ └── main.yml└── templates └── distribute_ssh_pubkey.sh.j2
1.ssh-key-gen.sh
#!/bin/bashexpect { item }} state=absent with_items: - distribute_ssh_pubkey.sh - ssh-key-gen.sh% for item in k8s_cluster_info %}expect { item.ip }}expect {"*yes/no*" { send "yes\r"; exp_continue}"*password:" { send "{{ ansible_ssh_pass }}\r" }}expect eofEOF{% endfor %}