Compare commits

...

3 Commits

8 changed files with 158 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ namespace: dede
name: common
# The version of the collection. Must be compatible with semantic versioning
version: 0.2.3
version: 0.3.0
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md

View File

@@ -0,0 +1,8 @@
---
apt_sources_debian_repos_list: |
deb https://ftp-stud.hs-esslingen.de/debian/ bookworm main non-free-firmware
deb-src https://ftp-stud.hs-esslingen.de/debian/ bookworm main non-free-firmware
deb https://ftp-stud.hs-esslingen.de/debian-security/ bookworm-security main non-free-firmware
deb-src https://ftp-stud.hs-esslingen.de/debian-security/ bookworm-security main non-free-firmware
deb https://ftp-stud.hs-esslingen.de/debian/ bookworm-updates main non-free-firmware
deb-src https://ftp-stud.hs-esslingen.de/debian/ bookworm-updates main non-free-firmware

View File

@@ -0,0 +1,6 @@
---
- name: update apt sources
listen: apt_sources_update
become: true
ansible.builtin.apt:
update_cache: true

View File

@@ -0,0 +1,35 @@
---
- name: ensure custom repositories in apt sources
become: true
notify: apt_sources_update
ansible.builtin.copy:
dest: /etc/apt/sources.list.d/debian.list
mode: '0644'
owner: root
group: root
backup: true
content: |
#
# this file was modified by ansible on {{ ansible_date_time.iso8601 }}
#
{{ apt_sources_debian_repos_list }}
- name: disable default apt repos
become: true
notify: apt_sources_update
register: apt_sources_disable
ansible.builtin.replace:
path: /etc/apt/sources.list
backup: true
regexp: '^(deb(?:\-src)?.*)$'
replace: '#\1'
- name: ensure info comment in default sources file
become: true
when: apt_sources_disable is changed
ansible.builtin.lineinfile:
state: present
path: /etc/apt/sources.list
insertbefore: BOF
search_string: '# this file was modified by ansible on '
line: '# this file was modified by ansible on {{ ansible_date_time.iso8601 }}'

View File

@@ -1,3 +1,3 @@
---
locale_config_locale: 'de_DE.UTF-8'
locale_config_locale: 'en_US.UTF-8'
locale_config_language: 'en_US.UTF-8'

View File

@@ -0,0 +1,7 @@
---
timesyncd_setup_timezone: Europe/Berlin
timesyncd_setup_ntp_servers:
- rustime02.rus.uni-stuttgart.de
- ntp2.fau.de
- rustime01.rus.uni-stuttgart.de
- ntp1.fau.de

View File

@@ -0,0 +1,35 @@
---
# handlers file for systemd-timesyncd
- name: reload ntp
become: true
listen: reload_ntp
ansible.builtin.shell:
timedatectl set-ntp false || true;
timedatectl set-ntp true || true;
- name: reload timesyncd
become: true
listen: reload_timesyncd
ansible.builtin.service:
name: systemd-timesyncd
state: reloaded
- name: restart timesyncd
become: true
listen: restart_timesyncd
ansible.builtin.service:
name: systemd-timesyncd
state: restarted
- name: reconfigure timezone
become: true
listen: reconfigure_timezone
ansible.builtin.shell:
DEBIAN_FRONTEND=noninteractive \
dpkg-reconfigure --frontend noninteractive tzdata
- name: sync rtc
become: true
listen: sync_rtc
ansible.builtin.command:
timedatectl set-local-rtc 0

View File

@@ -0,0 +1,65 @@
---
- name: set timezone in /etc/localtime
become: true
ansible.builtin.file:
src: /usr/share/zoneinfo/{{ timesyncd_setup_timezone }}
dest: /etc/localtime
state: link
force: true
notify:
- reconfigure_timezone
- reload_ntp
- name: set timezone in /etc/timezone
become: true
ansible.builtin.lineinfile:
state: present
dest: /etc/timezone
regexp: '.*'
line: '{{ timesyncd_setup_timezone }}'
insertbefore: EOF
create: true
mode: '0644'
notify:
- reconfigure_timezone
- reload_ntp
- name: set timezone via systemd
become: true
ansible.builtin.command:
timedatectl set-timezone {{ timesyncd_setup_timezone }}
- name: set ntp config in /etc/systemd/timesyncd.conf
become: true
community.general.ini_file:
path: /etc/systemd/timesyncd.conf
section: Time
option: NTP
value: '{{ timesyncd_setup_ntp_servers | join(" ") }}'
backup: true
notify:
- reload_ntp
- restart_timesyncd
- sync_rtc
- name: enable systemd-timesyncd unit
become: true
service:
name: systemd-timesyncd
enabled: true
notify:
- reload_ntp
- restart_timesyncd
- sync_rtc
- name: flush handlers
ansible.builtin.meta: flush_handlers
# - name: wait for timesyncd to synchronize
# ansible.builtin.command: systemctl status systemd-timesyncd
# retries: 60
# delay: 3
# register: task_result
# until:
# - task_result.rc == 0
# - task_result.stdout is search('[Ss]ynchroniz.* to time server')