diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9cef971 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +salt/pillars/local.sls diff --git a/salt/pillars/chrony.sls b/salt/pillars/chrony.sls new file mode 100644 index 0000000..bfddbd3 --- /dev/null +++ b/salt/pillars/chrony.sls @@ -0,0 +1,6 @@ +chrony: + pool: + - 0.se.pool.ntp.org + - 1.se.pool.ntp.org + - 2.se.pool.ntp.org + - 3.se.pool.ntp.org diff --git a/salt/pillars/network.sls b/salt/pillars/network.sls new file mode 100644 index 0000000..db4f0c5 --- /dev/null +++ b/salt/pillars/network.sls @@ -0,0 +1,8 @@ +network: + domain: suse.lan + address: 192.168.0.0 + netmask: 24 + + interface: + internal: eth0 + external: eth0.1000 diff --git a/salt/pillars/top.sls b/salt/pillars/top.sls new file mode 100644 index 0000000..f2e3e36 --- /dev/null +++ b/salt/pillars/top.sls @@ -0,0 +1,7 @@ +base: + '*': + - network + - chrony +{% if salt['file.file_exists']('local.sls') %} + - local +{% endif %} diff --git a/salt/states/chrony/files/local.conf.jinja b/salt/states/chrony/files/local.conf.jinja new file mode 100644 index 0000000..3d565e0 --- /dev/null +++ b/salt/states/chrony/files/local.conf.jinja @@ -0,0 +1,2 @@ +local stratum 10 +allow {{ pillar['network']['address'] }}/{{ pillar['network']['netmask'] }} diff --git a/salt/states/chrony/files/pool.conf.jinja b/salt/states/chrony/files/pool.conf.jinja new file mode 100644 index 0000000..e5a3427 --- /dev/null +++ b/salt/states/chrony/files/pool.conf.jinja @@ -0,0 +1,3 @@ +{% for pool in pillar['chrony']['pool'] -%} +server {{ pool }} iburst +{% endfor %} diff --git a/salt/states/chrony/init.sls b/salt/states/chrony/init.sls new file mode 100644 index 0000000..d3a58e6 --- /dev/null +++ b/salt/states/chrony/init.sls @@ -0,0 +1,31 @@ +install chrony: + pkg.installed: + - name: chrony + +create chrony pool configuration: + file.managed: + - name: /etc/chrony.d/pool.conf + - source: salt://chrony/files/pool.conf.jinja + - template: jinja + - user: root + - group: chrony + - mode: "0640" + +create chrony local configuration: + file.managed: + - name: /etc/chrony.d/local.conf + - source: salt://chrony/files/local.conf.jinja + - template: jinja + - user: root + - group: chrony + - mode: "0640" + +start chronyd: + service.running: + - name: chronyd + - enable: True + - require: + - pkg: install chrony + - watch: + - file: create chrony pool configuration + - file: create chrony local configuration diff --git a/salt/states/top.sls b/salt/states/top.sls new file mode 100644 index 0000000..a00987a --- /dev/null +++ b/salt/states/top.sls @@ -0,0 +1,3 @@ +base: + '*': + - chrony