gpt4 book ai didi

ansible - 如何使用ansible生成单个可重复使用的随 secret 码

转载 作者:行者123 更新时间:2023-12-04 09:13:26 25 4
gpt4 key购买 nike

也就是说:如何只评估一次密码查找?

- name: Demo
hosts: localhost
gather_facts: False
vars:
my_pass: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}"
tasks:
- debug:
msg: "{{ my_pass }}"
- debug:
msg: "{{ my_pass }}"
- debug:
msg: "{{ my_pass }}"

每个调试语句将打印出不同的值,例如:
PLAY [Demo] *************

TASK [debug] ************
ok: [localhost] => {
"msg": "ZfyzacMsqZaYqwW"
}

TASK [debug] ************
ok: [localhost] => {
"msg": "mKcfRedImqxgXnE"
}

TASK [debug] ************
ok: [localhost] => {
"msg": "POpqMQoJWTiDpEW"
}

PLAY RECAP ************
localhost : ok=3 changed=0 unreachable=0 failed=0

安全的 2.3.2.0

最佳答案

使用 set_fact分配永久事实:

- name: Demo
hosts: localhost
gather_facts: False
vars:
pwd_alias: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}"
tasks:
- set_fact:
my_pass: "{{ pwd_alias }}"
- debug:
msg: "{{ my_pass }}"
- debug:
msg: "{{ my_pass }}"
- debug:
msg: "{{ my_pass }}"

关于ansible - 如何使用ansible生成单个可重复使用的随 secret 码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46732703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com