ansible list from file as variable

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



ansible list from file as variable



could you please help me to add NTP address as variable , this is vmware ntp server update and i am trying to pass NTP server address as variable.



var file content


cat var.yml
NTP_Servers:
- 192.168.10.20
- 192.168.10.21



Playbook file


- 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: " default() "
ignore_errors: yes
tags: NTP





Have you tried to just pass the variable as you did for other keywords, anyway you are supposed to have at least tried something and provide what you tried with the result. Thanks
– Baptiste Mille-Mathias
Aug 7 at 18:35





1 Answer
1



If you want to get the contents of the file as a variable, you can either: use include_vars on the task level


- name: Add NTP to host on specified portgroup
include_vars: var.yaml



or use vars_file on the playbook level


---
hosts: netservers
vars_files:
- var.yml






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard