diff --git a/playbook.yaml b/playbook.yaml index ad42ae5..6f28411 100644 --- a/playbook.yaml +++ b/playbook.yaml @@ -16,11 +16,12 @@ wifi_psk: "test12345" wifi_int_ip: 10.1.10.1 # dhcpd + lease_time: 10800 subnet: 10.1.10.0 netmask: 255.255.255.0 range_start: 10.1.10.10 range_end: 10.1.10.200 default_lease_time: 600 - max_lease_time: 7200 + max_lease_time: 10800 dns1: 77.88.8.8 dns2: 77.88.8.1 diff --git a/roles/configure/handlers/main.yml b/roles/configure/handlers/main.yml index 982b68c..68a5614 100644 --- a/roles/configure/handlers/main.yml +++ b/roles/configure/handlers/main.yml @@ -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: diff --git a/roles/configure/tasks/main.yaml b/roles/configure/tasks/main.yaml index cd5ae04..c1aa701 100644 --- a/roles/configure/tasks/main.yaml +++ b/roles/configure/tasks/main.yaml @@ -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 \ diff --git a/roles/configure/templates/NetworkManager.conf.j2 b/roles/configure/templates/NetworkManager.conf.j2 new file mode 100644 index 0000000..53a8b17 --- /dev/null +++ b/roles/configure/templates/NetworkManager.conf.j2 @@ -0,0 +1,2 @@ +[main] +dns=dnsmasq diff --git a/roles/configure/templates/dns b/roles/configure/templates/dns deleted file mode 100644 index 0823a5d..0000000 --- a/roles/configure/templates/dns +++ /dev/null @@ -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 \ No newline at end of file diff --git a/roles/configure/templates/dnsmasq.conf.j2 b/roles/configure/templates/dnsmasq.conf.j2 new file mode 100644 index 0000000..11cd496 --- /dev/null +++ b/roles/configure/templates/dnsmasq.conf.j2 @@ -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 \ No newline at end of file