Commit 561d29f5 authored by nanahira's avatar nanahira

add ntpdate cron

parent 8f0c125f
......@@ -8,15 +8,7 @@ set site_name MyCard Boot
set self_address {{services.address}}
# ntp address
{% if dnsmasq.ntp is defined and dnsmasq.ntp %}
{% if dnsmasq.ntp == "localhost" %}
set ntp_address ${self_address}
{% else %}
set ntp_address {{dnsmasq.ntp}}
{% endif %}
{% else %}
set ntp_address ntp.aliyun.com
{% endif %}
set ntp_address {{ntp_server}}
# set boot domain
set boot_domain ${self_address}:16980
......
......@@ -84,7 +84,7 @@ services:
restart: always
image: cturra/ntp
environment:
NTP_SERVERS: {{ services.ntp.upstream | default('ntp1.aliyun.com,ntp2.aliyun.com,ntp3.aliyun.com,ntp4.aliyun.com') }}
NTP_SERVERS: {{ dnsmasq.ntp.upstream | default('ntp1.aliyun.com,ntp2.aliyun.com,ntp3.aliyun.com,ntp4.aliyun.com') }}
cap_add:
- SYS_TIME
ports:
......
......@@ -10,7 +10,7 @@
tasks:
- name: apt
apt:
name: net-tools,bridge-utils,pppoe,iproute2,iptables,ipset,subnetcalc,ifupdown,ifenslave
name: net-tools,bridge-utils,pppoe,iproute2,iptables,ipset,subnetcalc,ifupdown,ifenslave,ntpdate,util-linux
update_cache: true
- name: Ubuntu things
apt:
......
......@@ -11,6 +11,8 @@
template:
src: ./files/services/docker-compose.yml.j2
dest: '{{ansible_user_dir}}/nextgen-router/services/others/docker-compose.yml'
- name: ntp server
import_tasks: ./tasks/set-ntp-server.yaml
- name: pxe things
include_tasks: ./tasks/pxe.yaml
when: dnsmasq.pxe is defined and (dnsmasq.pxe == "localhost" or (dnsmasq.pxe.localhost is defined and dnsmasq.pxe.localhost))
......@@ -18,6 +20,13 @@
docker_compose:
project_src: '{{ansible_user_dir}}/nextgen-router/services/others'
remove_orphans: true
- name: ntpdate update cron
become: true
blockinfile:
path: /etc/crontab
marker: '# {mark} MyCard NextGen Router block for ntpdate'
block: |
40 */2 * * * root /usr/sbin/ntpdate -u {{ntp_server}} ; /usr/sbin/hwclock -w
handlers:
- name: restart_pxe_nginx
docker_compose:
......
- name: default ntp server
set_fact:
ntp_server: ntp.aliyun.com
- name: ntp server from specific
set_fact:
ntp_server: '{{dnsmasq.ntp}}'
when: dnsmasq.ntp is defined and not (dnsmasq.ntp == "localhost" or (dnsmasq.ntp.localhost is defined and dnsmasq.ntp.localhost))
- name: ntp server from self
set_fact:
ntp_server: '{{services.address}}'
when: dnsmasq.ntp is defined and (dnsmasq.ntp == "localhost" or (dnsmasq.ntp.localhost is defined and dnsmasq.ntp.localhost))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment