Commit 561d29f5 authored by nanahira's avatar nanahira

add ntpdate cron

parent 8f0c125f
...@@ -8,15 +8,7 @@ set site_name MyCard Boot ...@@ -8,15 +8,7 @@ set site_name MyCard Boot
set self_address {{services.address}} set self_address {{services.address}}
# ntp address # ntp address
{% if dnsmasq.ntp is defined and dnsmasq.ntp %} set ntp_address {{ntp_server}}
{% 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 boot domain # set boot domain
set boot_domain ${self_address}:16980 set boot_domain ${self_address}:16980
......
...@@ -84,7 +84,7 @@ services: ...@@ -84,7 +84,7 @@ services:
restart: always restart: always
image: cturra/ntp image: cturra/ntp
environment: 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: cap_add:
- SYS_TIME - SYS_TIME
ports: ports:
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
tasks: tasks:
- name: apt - name: apt
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 update_cache: true
- name: Ubuntu things - name: Ubuntu things
apt: apt:
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
template: template:
src: ./files/services/docker-compose.yml.j2 src: ./files/services/docker-compose.yml.j2
dest: '{{ansible_user_dir}}/nextgen-router/services/others/docker-compose.yml' dest: '{{ansible_user_dir}}/nextgen-router/services/others/docker-compose.yml'
- name: ntp server
import_tasks: ./tasks/set-ntp-server.yaml
- name: pxe things - name: pxe things
include_tasks: ./tasks/pxe.yaml include_tasks: ./tasks/pxe.yaml
when: dnsmasq.pxe is defined and (dnsmasq.pxe == "localhost" or (dnsmasq.pxe.localhost is defined and dnsmasq.pxe.localhost)) when: dnsmasq.pxe is defined and (dnsmasq.pxe == "localhost" or (dnsmasq.pxe.localhost is defined and dnsmasq.pxe.localhost))
...@@ -18,6 +20,13 @@ ...@@ -18,6 +20,13 @@
docker_compose: docker_compose:
project_src: '{{ansible_user_dir}}/nextgen-router/services/others' project_src: '{{ansible_user_dir}}/nextgen-router/services/others'
remove_orphans: true 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: handlers:
- name: restart_pxe_nginx - name: restart_pxe_nginx
docker_compose: 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