如何为我的剧本中的每个主机指定不同的 ansible_password?
How can I specify different ansible_password for each host in my playbook?
在清单文件 (.ini) 中,我们可以使用 :
app-server-1 ansible_host="123.45.67.8" ansible_user=abcd ansible_password=mypwd
但是因为我想用ansible vault加密密码,所以我需要把它放在
一个 .yml
文件。
非常感谢示例示例,因为我已尝试在 hosts: 部分和 vars: 部分中指定,但不能当每个主机有不同的密码时执行此操作。
Here's example of yaml inventory with generating encrypted password under the group. Here 带有主机变量的 yaml 清单示例:
all:
hosts:
test1:
ansible_password: !vault |
$ANSIBLE_VAULT;1.2;AES256;my_user
66386134653765386232383236303063623663343437643766386435663632343266393064373933
3661666132363339303639353538316662616638356631650a316338316663666439383138353032
63393934343937373637306162366265383461316334383132626462656463363630613832313562
3837646266663835640a313164343535316666653031353763613037656362613535633538386539
65656439626166666363323435613131643066353762333232326232323565376635
在清单文件 (.ini) 中,我们可以使用 :
app-server-1 ansible_host="123.45.67.8" ansible_user=abcd ansible_password=mypwd
但是因为我想用ansible vault加密密码,所以我需要把它放在
一个 .yml
文件。
非常感谢示例示例,因为我已尝试在 hosts: 部分和 vars: 部分中指定,但不能当每个主机有不同的密码时执行此操作。
Here's example of yaml inventory with generating encrypted password under the group. Here 带有主机变量的 yaml 清单示例:
all:
hosts:
test1:
ansible_password: !vault |
$ANSIBLE_VAULT;1.2;AES256;my_user
66386134653765386232383236303063623663343437643766386435663632343266393064373933
3661666132363339303639353538316662616638356631650a316338316663666439383138353032
63393934343937373637306162366265383461316334383132626462656463363630613832313562
3837646266663835640a313164343535316666653031353763613037656362613535633538386539
65656439626166666363323435613131643066353762333232326232323565376635