diff options
5 files changed, 49 insertions, 7 deletions
diff --git a/inventory/host_vars/ch-cm4-sensors0.yml b/inventory/host_vars/ch-cm4-sensors0.yml index dd4c649c..185cadbe 100644 --- a/inventory/host_vars/ch-cm4-sensors0.yml +++ b/inventory/host_vars/ch-cm4-sensors0.yml @@ -8,6 +8,10 @@ network: address: "{{ network_zones.iot.prefix | ansible.utils.ipaddr(network_zones.iot.offsets[inventory_hostname]) }}" interfaces: - *_network_primary_ + static_hostnames: + - address: "{{ network_zones.iot.prefix | ansible.utils.ipaddr(network_zones.iot.offsets['ch-iot']) | ansible.utils.ipaddr('address') }}" + names: + - apt.chaos-at-home.org raspios_boot_config: - regexp: '^#?dtparam=i2c_arm' @@ -26,3 +30,11 @@ raspios_boot_config: line: 'dtoverlay=gpio-shutdown,gpio_pin=4' base_entropy_generator: rngd + + +ntp_variant: systemd-timesyncd + +ntp_client: + servers: + - name: "{{ network_zones.iot.prefix | ansible.utils.ipaddr(network_zones.iot.offsets['ch-iot']) | ansible.utils.ipaddr('address') }}" + options: iburst diff --git a/inventory/host_vars/ch-cm4-sensors1.yml b/inventory/host_vars/ch-cm4-sensors1.yml index dd4c649c..185cadbe 100644 --- a/inventory/host_vars/ch-cm4-sensors1.yml +++ b/inventory/host_vars/ch-cm4-sensors1.yml @@ -8,6 +8,10 @@ network: address: "{{ network_zones.iot.prefix | ansible.utils.ipaddr(network_zones.iot.offsets[inventory_hostname]) }}" interfaces: - *_network_primary_ + static_hostnames: + - address: "{{ network_zones.iot.prefix | ansible.utils.ipaddr(network_zones.iot.offsets['ch-iot']) | ansible.utils.ipaddr('address') }}" + names: + - apt.chaos-at-home.org raspios_boot_config: - regexp: '^#?dtparam=i2c_arm' @@ -26,3 +30,11 @@ raspios_boot_config: line: 'dtoverlay=gpio-shutdown,gpio_pin=4' base_entropy_generator: rngd + + +ntp_variant: systemd-timesyncd + +ntp_client: + servers: + - name: "{{ network_zones.iot.prefix | ansible.utils.ipaddr(network_zones.iot.offsets['ch-iot']) | ansible.utils.ipaddr('address') }}" + options: iburst diff --git a/roles/installer/debian/preseed/templates/preseed_debian-bookworm.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_debian-bookworm.cfg.j2 index 3e86b048..f96231b0 100644 --- a/roles/installer/debian/preseed/templates/preseed_debian-bookworm.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_debian-bookworm.cfg.j2 @@ -23,15 +23,15 @@ d-i netcfg/disable_dhcp boolean true d-i netcfg/disable_autoconfig boolean true d-i netcfg/get_ipaddress string {{ network.primary.address | ansible.utils.ipaddr('address') }} d-i netcfg/get_netmask string {{ network.primary.address | ansible.utils.ipaddr('netmask') }} -d-i netcfg/get_gateway string {{ network.primary.gateway }} -d-i netcfg/get_nameservers string {{ network.nameservers | join(' ') }} +d-i netcfg/get_gateway string {{ network.primary.gateway | default('') }} +d-i netcfg/get_nameservers string {{ network.nameservers | default([]) | join(' ') }} d-i netcfg/confirm_static boolean true {% endif %} d-i netcfg/hostname string {{ host_name }} d-i netcfg/get_hostname string {{ host_name }} -d-i netcfg/domain string {{ network.domain }} -d-i netcfg/get_domain string {{ network.domain }} +d-i netcfg/domain string {{ network.domain | default('') }} +d-i netcfg/get_domain string {{ network.domain | default('') }} d-i netcfg/wireless_wep string diff --git a/roles/installer/raspios/image/templates/firstrun.sh.j2 b/roles/installer/raspios/image/templates/firstrun.sh.j2 index 96c74b39..05f9639d 100644 --- a/roles/installer/raspios/image/templates/firstrun.sh.j2 +++ b/roles/installer/raspios/image/templates/firstrun.sh.j2 @@ -76,8 +76,10 @@ EOF {% if not (install_dhcp | default(false)) %} cat <<EOF > /etc/resolv.conf # Generated by ansible +{% if 'domain' in network %} search {{ network.domain }} -{% for nameserver in network.nameservers %} +{% endif %} +{% for nameserver in (network.nameservers | default([])) %} nameserver {{ nameserver }} {% endfor %} EOF @@ -86,6 +88,9 @@ systemctl disable wpa_supplicant.service rfkill unblock wlan ifup {{ network.primary.name }} {% endif %} +{% for host in (network.static_hostnames | default([])) %} +echo "{{ host.address }} {{ host.names | join(' ') }}" >> /etc/hosts +{% endfor %} {% if ansible_port != 22 %} sed -e 's/^\s*#*\s*Port\s\s*[0-9][0-9]*$/Port {{ ansible_port }}/' -i /etc/ssh/sshd_config @@ -108,6 +113,13 @@ rm "$FW_LOC/firstrun.sh" rm -f /etc/sudoers.d/010_pi-nopasswd rm -f /etc/apt/sources.list.d/vscode.list rm -f /etc/apt/trusted.gpg.d/microsoft.gpg +rm -f /etc/apt/sources.list.d/raspi.list +cat <<EOF > /etc/apt/sources.list +deb http://{{ apt_repo_providers[apt_repo_provider].debian.host }}{{ apt_repo_providers[apt_repo_provider].debian.path }} {{ install_codename }} main non-free-firmware +deb http://{{ apt_repo_providers[apt_repo_provider].debian.host }}{{ apt_repo_providers[apt_repo_provider].debian.path }} {{ install_codename }}-updates main non-free-firmware +deb http://{{ apt_repo_providers[apt_repo_provider].debian_security.host }}{{ apt_repo_providers[apt_repo_provider].debian_security.path }} {{ install_codename }}-security main non-free-firmware +deb http://{{ apt_repo_providers[apt_repo_provider].raspios.host }}{{ apt_repo_providers[apt_repo_provider].raspios.path }} {{ install_codename }} main +EOF apt-get update -q apt-get dist-upgrade -y -q diff --git a/roles/installer/ubuntu/autoinstall/templates/autoinstall.yml.j2 b/roles/installer/ubuntu/autoinstall/templates/autoinstall.yml.j2 index 9911f654..af349e5c 100644 --- a/roles/installer/ubuntu/autoinstall/templates/autoinstall.yml.j2 +++ b/roles/installer/ubuntu/autoinstall/templates/autoinstall.yml.j2 @@ -19,10 +19,16 @@ autoinstall: {% else %} addresses: - {{ network.primary.address }} - gateway4: {{ network.primary.gateway }} +{% if 'gateway' in network %} + routes: + - to: default + via: {{ network.primary.gateway }} +{% endif %} {% if (network.nameservers | default([]) | length) > 0 %} nameservers: - search: [ {{ host_domain }} ] +{% if 'domain' in network %} + search: [ {{ network.domain }} ] +{% endif %} addresses: [ {{ network.nameservers | join(', ') }} ] {% endif %} {% endif %} |