Try to group things by common properties.
Create a role that deploys ntpd, and use those common properties to
construct a configuration file using a jinja2 template. That's in
general the approach I take.
When I found my templates getting crazy complex, it sometimes meant my
infrastructure was in fact too complex.
I think you can get away with three types of configs:
1. the GPS based master server
2. the machines that use the master and each other to peer with: 'peers'
3. clients that use all/any of the above
You can then define a few groups
[ntp-servers]
master
peer1
peer2
peer3
peer4
[slaves]
ec2-a
ec2-b
ec2-c
ec3-d
You can then define a var that contains the list of all the ntp-server
except the one that the host in question:
- set_fact:
peers: "{{ groups['ntp-server'] | difference(inventory_hostname) }}"
Set up a template task:
- name: ntpd config file
template:
dest: /etc/ntp.conf
src: ntp.conf.j2
Where the template looks like for the ntp-servers:
# Use all NTP peers except myself ({{ inventory_hostname }})
{% for peer in peers %}
server {{ hostvars[peer]['ansible_fqdn'] }}
{% endfor %}
Regarding the Amazon specific settings, it's probably easiest to use a
group variable that holds a list of NTP servers, based on the
ec2_region var.
There are many ways to expand this.
BTW - what do you mean by "Locally I have one GPS enabled NTP server"?
If that means that it sits at your home, and you want your ec2
instances to source their clock from it, then that's defeating the
purpose of cloud infrastructure I think...
Dick
> --
> 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
ansible-proje...@googlegroups.com.
> To post to this group, send email to
ansible...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/ansible-project/b371f7c4-b432-47f1-a5ae-80d4ff287ccc%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
--
Dick Visser
Sr. System & Network Engineer
GÉANT
Want to join us? We're hiring:
https://www.geant.org/jobs