diff --git a/group_vars/all.yml b/group_vars/all.yml index 884f190b..91ae7113 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -55,7 +55,7 @@ - username: mg password: "{{ lookup('keepass', 'mg_linux_password_hash', 'password') }}" update_password: on_create - ssh_key: "{{ lookup('keepass', 'mg_ssh_pubkey', 'password') }}" #generieren: ssh-keygen -o; für putty andern https://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/ggcs/Change_private_key_format_for_Putty/Change_private_key_format_for_Putty.html#section2 + ssh_key: "{{ lookup('keepass', 'mg_ssh_pubkey', 'password') }}" #generieren: ssh-keygen -o; für putty ändern https://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/ggcs/Change_private_key_format_for_Putty/Change_private_key_format_for_Putty.html#section2 use_sudo: yes use_sudo_nopass: yes user_state: present diff --git a/playbooks/base/3_base.yml b/playbooks/base/3_base.yml index 8597424c..08a3802d 100644 --- a/playbooks/base/3_base.yml +++ b/playbooks/base/3_base.yml @@ -1,6 +1,6 @@ --- - hosts: all roles: - - { role: mgrote.set_timezone, tags: "timezone" } + - { role: mgrote.ntp, tags: "ntp" } - { role: mgrote.restic, tags: "restic" } - { role: ryandaniels.create_users, tags: "user", become: yes } diff --git a/roles/mgrote.ntp/README.md b/roles/mgrote.ntp/README.md new file mode 100644 index 00000000..d150bf93 --- /dev/null +++ b/roles/mgrote.ntp/README.md @@ -0,0 +1,10 @@ +## mgrote.ntp + +### Beschreibung +Installiert ntp-client, setzt die Zeitserver und konfiguriert die Zeitzone. +### Funktioniert auf +- [x] Ubuntu (>=18.04) +- [x] ProxMox ()>=6.1) + +### Variablen + Defaults +see [defaults](./defaults/main.yml) diff --git a/roles/mgrote.ntp/defaults/main.yml b/roles/mgrote.ntp/defaults/main.yml new file mode 100644 index 00000000..b53f3c8d --- /dev/null +++ b/roles/mgrote.ntp/defaults/main.yml @@ -0,0 +1,16 @@ +--- + ntp_timezone: "Europe/Berlin" #Zeitzone in der sich der Cpmputer befindet + ntp_driftfile_directory: "/var/lib/ntp" # Ordner für das driftfile + ntp_servers: # welche Server sollen befragt werden + - address: ptbtime1.ptb.de + options: iburst #optionaler parameter + - address: ptbtime2.ptb.de + options: iburst + - address: ptbtime3.ptb.de + options: iburst + - address: time3.google.com + options: iburst + - address: ntp0.fau.de + options: iburst + ntp_daemon_user: ntp # Nutzer + Gruppe für den Dienst + ntp_daemon_group: ntp # Nutzer + Gruppe für den Dienst diff --git a/roles/mgrote.ntp/handlers/main.yml b/roles/mgrote.ntp/handlers/main.yml new file mode 100644 index 00000000..749e22c8 --- /dev/null +++ b/roles/mgrote.ntp/handlers/main.yml @@ -0,0 +1,7 @@ +--- + - name: restart ntpd + become: yes + systemd: + name: ntp + enabled: yes + state: restarted diff --git a/roles/mgrote.ntp/tasks/main.yml b/roles/mgrote.ntp/tasks/main.yml new file mode 100644 index 00000000..552b9318 --- /dev/null +++ b/roles/mgrote.ntp/tasks/main.yml @@ -0,0 +1,31 @@ +--- + - name: install ntp packages + become: yes + ansible.builtin.package: + name: + - ntp + - ntpdate + state: present + + - name: Create ntp driftfile folder + become: yes + file: + state: directory + path: "{{ ntp_driftfile_directory }}" + mode: 0644 + owner: "{{ ntp_daemon_user }}" + group: "{{ ntp_daemon_group }}" + + - name: create ntp.conf + become: yes + template: + src: "ntp.conf.j2" + dest: "/etc/ntp.conf" + mode: 0644 + notify: + - restart ntpd + + - name: set Zeitzone to {{ ntp_timezone }} + become: yes + ansible.builtin.timezone: + name: "{{ ntp_timezone }}" diff --git a/roles/mgrote.ntp/templates/ntp.conf.j2 b/roles/mgrote.ntp/templates/ntp.conf.j2 new file mode 100644 index 00000000..d1c48e31 --- /dev/null +++ b/roles/mgrote.ntp/templates/ntp.conf.j2 @@ -0,0 +1,7 @@ +# Servers +{% for item in ntp_servers %} +server {{ item.address }} {{ item.options |default() }} +{% endfor %} + +# Drift file +driftfile {{ ntp_driftfile_directory }}/drift diff --git a/roles/mgrote.set_timezone/README.md b/roles/mgrote.set_timezone/README.md deleted file mode 100644 index 348614c3..00000000 --- a/roles/mgrote.set_timezone/README.md +++ /dev/null @@ -1,12 +0,0 @@ -## mgrote.set_timezone - -### Beschreibung -setzt die Zeitzone -### Funktioniert auf -- [x] Ubuntu (>=18.04) -- [x] Debian - - -### Variablen + Defaults -##### Zeitzone: -base_timezone: "Europe/Berlin" diff --git a/roles/mgrote.set_timezone/defaults/main.yml b/roles/mgrote.set_timezone/defaults/main.yml deleted file mode 100644 index 178d952f..00000000 --- a/roles/mgrote.set_timezone/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- - base_timezone: "Europe/Berlin" diff --git a/roles/mgrote.set_timezone/handlers/main.yml b/roles/mgrote.set_timezone/handlers/main.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/roles/mgrote.set_timezone/tasks/main.yml b/roles/mgrote.set_timezone/tasks/main.yml deleted file mode 100644 index 4b50fcd1..00000000 --- a/roles/mgrote.set_timezone/tasks/main.yml +++ /dev/null @@ -1,4 +0,0 @@ - - name: Setze Zeitzone auf {{ base_timezone }} - become: yes - ansible.builtin.timezone: - name: "{{ base_timezone }}"