This commit is contained in:
2024-09-01 22:27:07 +03:00
parent 9108e5f4d7
commit 1b0d5ff144
6 changed files with 37 additions and 9 deletions

View File

@@ -7,10 +7,10 @@
changed_when: false
when: disable_ipv6_reload_sysctl_if_changed
- name: Restart NetworkManager
- name: Reload NetworkManager
service:
name: NetworkManager
state: restarted
state: reloaded
- name: Restart hostapd
service:

View File

@@ -35,12 +35,29 @@
state: stopped
enabled: false
- name: Get physical interfaces names
- name: Configure dnsmasq
template:
src: dnsmasq.conf.j2
dest: /etc/dnsmasq.conf
- name: Configure NetworkManager
template:
src: NetworkManager.conf.j2
dest: /etc/NetworkManager/NetworkManager.conf
notify: Reload NetworkManager
- name: Get physical interfaces names WIFI modems
command: find /sys/class/net -type l -lname '*wlp*' -printf '%f\n'
register: wifi_int
changed_when: false
check_mode: false
- name: Get physical interfaces names LTE modems
command: find /sys/class/net -type l -lname '*wwp*' -printf '%f\n'
register: lte_int
changed_when: false
check_mode: false
- name: Run nmcli to check if wifi access point connection has already been added
shell: /usr/bin/nmcli c | grep {{ wifi_ssid }}
register: nmcli_result
@@ -54,6 +71,9 @@
command: /usr/bin/nmcli c add autoconnect yes save yes con-name {{ wifi_ssid }} ifname {{ wifi_int.stdout }} type wifi ssid {{ wifi_ssid }} mode ap ip4 {{ wifi_int_ip }}
when: nmcli_failed
- name: Run nmcli to add a connection LTE
command: /usr/bin/nmcli c add autoconnect yes save yes con-name TLE ifname {{ lte_int.stdout }} type gsm apn "internet"
- name: Run nmcli to add WPA-PSK security to the wifi connection
command: /usr/bin/nmcli c mod {{ wifi_ssid }} \
802-11-wireless.band bg \

View File

@@ -0,0 +1,2 @@
[main]
dns=dnsmasq

View File

@@ -1,5 +0,0 @@
interface={{ wifi_int.stdout_lines | first }}
dhcp-range={{ range_start }},{{ range_end }},2h
log-queries
#log-dhcp
log-facility=/var/log/dnsmasq.log

View File

@@ -0,0 +1,10 @@
interface={{ wifi_int.stdout_lines | first }}
dhcp-range={{ range_start }},{{ range_end }},2h
dhcp-option=1,{{ netmask }}
dhcp-option=2,{{ lease_time }} # время аренды в секундах
dhcp-option=3,{{ wifi_int_ip }} # шлюз по умолчанию
dhcp-option=6,{{ dns1 }}
dhcp-authoritative
log-queries
#log-dhcp
log-facility=/var/log/dnsmasq.log