I'm new to Ansible and want use it to configure a NTP service. here is my
situation:
my hosts file:
[ntp_servers]
s1.aaa.com
s2.aaa.com
s3.aaa.com
s4.aaa.com
The "/taskts/mail.yaml" for role "ntp_server":
- name: install ntp
apt: name=ntp state=present
- name: config ntpd
template: src=ntp.conf dest=/etc/ntp.conf
The "templates/ntp.conf" for role "ntp_server":
...
restrict {{ ntp_net }} mask {{ ntp_netmask }} nomodify notrap
{% for svr in servers %}
peer svr
{% endfor %}
...
My questions are about for loop in the template file (please leave along
the NTP specific things):
1. How to refer the hosts defined in the hosts file from within the
template file? In another words, I need the value of "servers" variable in
the for loop to be a list of "s1.aaa.com", "s2.aaa.com" ...
2. How to know the current host so that the for loop could exclude it(it
should not be peer to itself) ?
Thanks and Regards
John
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/684a949d-05c9-4be7-8a66-0558f84a6979%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.