如何检索在ansible中的with_sequence循环中使用的索引"{{ item }“值?我使用以下代码:
- name: Check if Route 53 DNS record exists
route53:
state: get
zone: zone_id
private_zone: true
record: testrecord{{ item }}.foo.com
type: A
register: dns_record
when: (dns_record is not defined) or (dns_record.s
我正在使用Ansible部署到Amazon上,并且已经设置了ec2.py和ec2.ini,这样我就可以从亚马逊检索服务器列表。我的服务器位于AWS标记的rvmdocker:production上,ansible all --list返回标记为ec2_tag_rvmdocker_production.,我也可以运行:
ansible -m ping tag_rvmdocker_production`
而且起作用了。但是如果我在静态库存文件中有这个标签,然后运行:
ansible all -m ping -i production
它返回:
tag_rvmdocker_production | U
我正在尝试使用kv2模块从ansible剧本中的hashi_vault hashicorp保险库中提取特定值。
- name: Return specific value from vault
ansible.builtin.set_fact:
secret: "{{ lookup('hashi_vault', 'secret=my.secrets/data/dev/heslo:value token=vault-plaintext-root-token url=http://10.47.0.235:8200/')}}" regi
有没有办法简化下面的json_query?在这里您可以看到,我正在尝试使用三个查询设置来提取三个值。由于我在列表中有三个项目,因此将根据项目列表生成三次值。有没有办法将每一项的值分开?
ClusterName: xxxx for dv-cn-c1
DomainName: xxxx for dv-cn-c1
ClusterName: xxxx for dv-cn-c2
DomainName: xxxx for dv-cn-c2
请看我的想法
- name: "set fact for policy pkg for list of devices"
set_
我正在学习Ansible,但我对在playbook中何时使用连字符以及何时不使用连字符感到困惑。据我所知,在Ansible中,list使用连字符。
例如,
--- # my first playbook
- hosts: webservers ( why did we use hyphen here it is not a list)
tasks:
- name: installing httpd
yum: name=httpd state=installed ( why we shouldn't use hy
简单的问题是,是否可以使用文件模块创建目录并注册新目录的路径,以便将其用作变量。
我很乐意这样做,因为我正在创建一个带有时间戳的目录,但是现在我想使用这个目录来存储一些数据,而且当我使用查找插件时,它似乎会失败,因为时间会在……
下面是我创建两个目录的前两个任务;
- name: Create Directory with timestamp to store the data if it doesn't exist
when: inventory_hostname in groups['local']
file:
path: "{{store_
dict.values()没有提供在for循环中检索到的所有值。我使用for循环从文本文件中检索值。
test = {}
with open(input_file, "r") as test:
for line in test:
value = line.split()[5]
value = int(value)
test[value] = value
print (value)
test_list = test.values()
print