请您帮我添加NTP地址作为变量,这是vmware ntp服务器更新,我正尝试将NTP服务器地址作为变量传递。
各种文件内容
cat var.yml
NTP_Servers:
- 192.168.10.20
- 192.168.10.21
剧本文件
- name: Add NTP to host on specified portgroup
local_action:
module: vmware_host_ntp
hostname: "{{ vcenter_ip}}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: False
esxi_hostname: "{{ item.value.mgmtip }}"
ntp_servers: <<<<<<<<<IP ADDRESS>
state: present
with_dict: "{{ PayloadNodes | default({}) }}"
ignore_errors: yes
tags: NTP
答案 0 :(得分:0)
如果要获取文件内容作为变量,则可以执行以下任一操作:在任务级别上使用include_vars
- name: Add NTP to host on specified portgroup
include_vars: var.yaml
或在剧本级别使用vars_file
---
hosts: netservers
vars_files:
- var.yml