Linux脚本——for循环和array数组
#!/bin/sh NodeName=( k8s-master-1 k8s-master-2 k8s-master-3 k8s-node-1 k8s-node-2 k8s-node-3 k8s-node-4 k8s-node-5 ) ipv4=( 100.190.110.55 100.190.110.56 100.190.110.57 100.190.110.70 100.190.110.71 100.190.110.72 100.190.110.67 100.190.110.68 ) ipv6=( 2001:1:1:1::336/120 2001:1:1:1::337/120 2001:1:1:1::338/120 2001:1:1:1::345/120 2001:1:1:1::346/120 2001:1:1:1::347/120 2001:1:1:1::342/120 2001:1:1:1::343/120 ) for i in `seq(0 7)` do echo "${NodeName[$i]} ansible_host=${ipv4[$i]} ansible_ssh_user=root ansible_ssh_pass='BClinux@123' ip=\"${ipv4[$i]}\" ip6=\"${ipv6[$i]}\"" done
稳步前行,只争朝夕。