From c3a7ed97dd34e883547ba2f5e891346c76a3657d Mon Sep 17 00:00:00 2001 From: John Burwell Date: Fri, 25 Apr 2025 19:56:20 -0500 Subject: [PATCH] First fixes --- ansible/playbook.yml | 51 +++++++++++++++++++ .../{desired-state.yml => desired_state.yml} | 1 + handlers/main.yml | 18 +++++++ systemd/kisstnc@.service | 2 +- systemd/unblock-wlan.service | 12 +++++ templates/direwolf.conf.j2 | 1 - 6 files changed, 83 insertions(+), 2 deletions(-) rename config/{desired-state.yml => desired_state.yml} (95%) create mode 100644 handlers/main.yml create mode 100644 systemd/unblock-wlan.service diff --git a/ansible/playbook.yml b/ansible/playbook.yml index 8f1eae7..259578f 100644 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -2,10 +2,14 @@ - name: Ham Hotspot Bootstrap hosts: localhost become: yes + connection: local vars_files: - ../config/desired_state.yml + handlers: + - import_tasks: ../handlers/main.yml + tasks: - name: Install base apt packages apt: @@ -19,6 +23,8 @@ - build-essential - cmake - git + - alsa-utils + - libasound2-dev state: present update_cache: yes @@ -54,6 +60,14 @@ owner: root group: root + - name: Create /etc/ham-hotspot directory + file: + path: /etc/ham-hotspot + state: directory + mode: '0755' + owner: root + group: root + - name: Deploy Direwolf configuration template: src: ../templates/direwolf.conf.j2 @@ -65,12 +79,14 @@ src: ../templates/hostapd.conf.j2 dest: /etc/hostapd/hostapd.conf mode: '0644' + notify: Restart hostapd - name: Deploy dnsmasq configuration template: src: ../templates/dnsmasq.conf.j2 dest: /etc/dnsmasq.d/ham-hotspot.conf mode: '0644' + notify: Restart dnsmasq - name: Deploy axports configuration template: @@ -85,10 +101,45 @@ net.ipv4.ip_forward=1 mode: '0644' + - name: Unmask hostapd service + systemd: + name: hostapd + masked: no + + - name: Ensure /etc/wpa_supplicant/wpa_supplicant.conf exists + file: + path: /etc/wpa_supplicant/wpa_supplicant.conf + state: touch + owner: root + group: root + mode: '0644' + + - name: Ensure Wi-Fi country is set in wpa_supplicant.conf + blockinfile: + path: /etc/wpa_supplicant/wpa_supplicant.conf + marker: "# {mark} ANSIBLE MANAGED BLOCK - Wi-Fi Country Setting" + block: | + country={{ wifi.country }} + when: ansible_facts['distribution'] in ['Debian', 'Raspbian'] + + - name: Install unblock-wlan.service + copy: + src: ../systemd/unblock-wlan.service + dest: /etc/systemd/system/unblock-wlan.service + mode: '0644' + owner: root + group: root + - name: Reload systemd daemon systemd: daemon_reload: yes + - name: Enable and start unblock-wlan.service + systemd: + name: unblock-wlan.service + enabled: yes + state: started + - name: Enable and start Direwolf instance systemd: name: direwolf@radio0.service diff --git a/config/desired-state.yml b/config/desired_state.yml similarity index 95% rename from config/desired-state.yml rename to config/desired_state.yml index 7910984..bf62858 100644 --- a/config/desired-state.yml +++ b/config/desired_state.yml @@ -1,6 +1,7 @@ # Configuration state for Ham Hotspot wifi: + country: US ssid: HamHotspot password: change_me_now channel: 6 diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..dc84165 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,18 @@ +--- +- name: Restart hostapd + systemd: + name: hostapd + state: restarted + enabled: yes + +- name: Restart dnsmasq + systemd: + name: dnsmasq + state: restarted + enabled: yes + +- name: Restart unblock-wlan service + systemd: + name: unblock-wlan.service + state: restarted + enabled: yes diff --git a/systemd/kisstnc@.service b/systemd/kisstnc@.service index f990c37..9e496d1 100644 --- a/systemd/kisstnc@.service +++ b/systemd/kisstnc@.service @@ -5,7 +5,7 @@ After=direwolf@%i.service AssertPathExists=/run/direwolf/%i [Service] -Type=oneshot +Type=simple ExecStart=/usr/sbin/kissattach /run/direwolf/%i %i ExecStartPost=/usr/sbin/kissparms -c 1 -p %i RemainAfterExit=true diff --git a/systemd/unblock-wlan.service b/systemd/unblock-wlan.service new file mode 100644 index 0000000..4b2bc35 --- /dev/null +++ b/systemd/unblock-wlan.service @@ -0,0 +1,12 @@ +[Unit] +Description=Unblock WiFi on boot +After=network-pre.target +Before=network.target + +[Service] +Type=oneshot +ExecStart=/usr/sbin/rfkill unblock wlan +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/templates/direwolf.conf.j2 b/templates/direwolf.conf.j2 index 1b429bb..24ff132 100644 --- a/templates/direwolf.conf.j2 +++ b/templates/direwolf.conf.j2 @@ -16,7 +16,6 @@ TXTAIL 10 DWAIT 0 SLOTTIME 100 PERSIST 63 -FIX_BITS 1 AX25 # Log settings LOGDIR /var/log/direwolf