Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Allow server configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
holmesb committed Apr 12, 2021
1 parent eff2fec commit 191b3d7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ None
| `chrony_pkg_state` | No | `present` | Set pkg `enabled`, `disabled`, `latest` |
| `chrony_service_state` | No | `started` | Set service state, started, enabled or disabled |
| `chrony_service_enabled` | No | `yes` | A list of NTP servers to use. |
| `chrony_config_server` | No | `["0.pool.ntp.org","1.pool.ntp.org","2.pool.ntp.org", "3.pool.ntp.org"]` | A list of NTP servers to use. |
| `chrony_config_server` | No | `[{"0.pool.ntp.org", "options": [{"option":"iburst"}]}, {"1.pool.ntp.org", "options": [{"option":"iburst"}]}, {"2.pool.ntp.org", "options": [{"option":"iburst"}]}, {"3.pool.ntp.org", "options": [{"option":"iburst"}]}]` | A list of NTP servers, or list of maps of NTP servers and options to use (see example in defaults/main.yml). |
| `chrony_config_logdir` | No | `/var/log/chrony` | A list of NTP servers to use. |
| `chrony_config_extra_options` | No | `{}` | A dict of extra config options. |

Expand Down
39 changes: 35 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,40 @@ chrony_pkg_state: present
chrony_service_state: started
chrony_service_enabled: yes
chrony_config_server:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
- 3.pool.ntp.org
- server: 0.pool.ntp.org
options:
- option: iburst
- server: 1.pool.ntp.org
options:
- option: iburst
- server: 2.pool.ntp.org
options:
- option: iburst
- server: 3.pool.ntp.org
options:
- option: iburst

# See also an example of chrony_config_server with options in option\val pairs:
#chrony_config_server:
# - server: 0.pool.ntp.org
# options:
# - option: iburst
# - option: minpoll
# val: 8
# - server: 1.pool.ntp.org
# options:
# - option: iburst
# - option: minpoll
# val: 8
# - server: 2.pool.ntp.org
# options:
# - option: iburst
# - option: minpoll
# val: 8
# - server: 3.pool.ntp.org
# options:
# - option: iburst
# - option: minpoll
# val: 8
chrony_config_logdir: /var/log/chrony
chrony_config_extra_options: {}
9 changes: 7 additions & 2 deletions templates/chrony.conf.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# {{ ansible_managed }}

# List of NTP servers to use.
{% for server in chrony_config_server %}
server {{ server }} iburst
{% for item in chrony_config_server %}
{% if item['options'] is not defined %}
server {{ item['server'] }}
{% elif item['options'] is defined %}
server {{ item['server'] }}{% for opt in item['options'] %} {{ opt['option'] }}{% if opt['val'] is defined %} {{ opt['val'] }}{% endif %}{% endfor %}

{% endif %}
{% endfor %}

# This directive specify the location of the file containing ID/key pairs for
Expand Down

0 comments on commit 191b3d7

Please sign in to comment.