我想帮助创建一个新的数据结构,比较两个字典,
然后用字典创建一个列表。这个想法是,在更改的情况下,保留旧版本,并添加修改后的用户名/密码。
目标:
list: [{"username": "a1", "password": "apass1"}, {"username": "a2", "password": "apass2"}, {"username": "b1", "password": "bpass1"}, {"username": "c1", "password": "cpass1"}, {"c_username": "c1", "c_password" : "cpass1"} , {"c_username": "c2", "c2_password" : "cpass1"}]
---
name: "Username/Password version 1"
set_fact:
dict1: {"a_username": "a1", "a_password" : "apass1", "b_username": "b1", "b_password" : "bpass1", "c_username": "c1", "c_password" : "cpass1"}
name: "Username/Password version 2"
set_fact:
dict2: {"a_username": "a2", "a_password" : "apass2", "b_username": "b1", "b_password" : "bpass1", "c_username": "c2", "c2_password" : "cpass1"}
我希望这对管理我的PostgreSQL数据库中的服务中断有用。我还从Vault中检索用户名/密码数据
1条答案
按热度按时间monwx1rj1#
鉴于字典
Q:***“保留旧版本,添加修改后的用户名/密码。”***
A:下面的模板
给予
下一个选项是获取唯一的用户名/密码对并创建字典
给予
把字典转换成列表,你会得到同样的结果