Configure wifi by config_light
Instead of the Customization tasks, it’s possible to use Ansible role vbotka.config_light to
configure the image. This example configures exactly the same parameters of the wireless network as
the example in Quick start guide. The playbook pb-wifi-basic.yml created in the Quick start guide will be used
to attach a memory disk and mount the partition.
Current directory
shell> ls -1 conf-light hosts pb-wifi-basic-cl.yml pb-wifi-basic.yml
Install the role vbotka.config_light
shell> ansible-galaxy install vbotka.config_light
Create the playbook
pb-wifi-basic-cl.ymlfor single host images.example.com (2). Configure connection (4-5) and privilege escalation (6-8). Configure the directory (11) with the configuration files and reuse the configuration (13-17) already prepared in Quick start guide (19-48).
1- name: Configure wireless network in the mounted system image
2 hosts: images.example.com
3
4 connection: ssh
5 remote_user: admin
6 become: true
7 become_user: root
8 become_method: ansible.builtin.sudo
9
10 vars:
11 cl_dird: "{{ playbook_dir }}/conf-light"
12 cl_assemble_validate: ansible-lint -x 205 %s
13 cl_loaderconf_modules: "{{ cimage_loaderconf_modules }}"
14 cl_loaderconf_data: "{{ cimage_loaderconf_data }}"
15 cl_loaderconf_sysctl: "{{ cimage_loaderconf_sysctl }}"
16 cl_wpasupconf_global: []
17 cl_wpasupconf_wlan0: "{{ cimage_wpasupconf_data| selectattr('dev', 'eq', 'wlan0')|first }}"
18
19 cimage_sanity: false
20 cimage_install: false
21 cimage_debug: true
22 cimage_debug_classified: true
23
24 cimage_mount_path: /mnt3
25
26 cimage_loaderconf_modules: [wlan, wlan_wep, wlan_ccmp, wlan_tkip, wlan_amrr, rtwn, if_rtwn_usb]
27 cimage_loaderconf_data:
28 - hw.usb.template=3
29 - umodem_load="YES"
30 - boot_multicons="YES"
31 - boot_serial="YES"
32 - beastie_disable="YES"
33 - loader_color="NO"
34 - legal.realtek.license_ack=1
35 cimage_loaderconf_sysctl: []
36 cimage_rcconf_data:
37 - { key: wlans_rtwn0, value: '"wlan0"' }
38 - { key: ifconfig_wlan0, value: '"WPA SYNCDHCP"' }
39
40 cimage_wpasupconf_data:
41 - dev: wlan0
42 network:
43 - conf:
44 - { key: ssid, value: '"my_access_point"' }
45 - { key: psk, value: '"my_password"' }
46 - { key: disabled, value: "0" }
47 cimage_wpasupconf_link: true
48 cimage_wpasupconf_link_dev: wlan0
49
50 roles:
51 - vbotka.config_light
Create the configuration files in the directory
cl_dirdshell> tree conf-light/ conf-light/ ├── files.d │ ├── loaderconf.yml │ ├── rcconf.yml │ └── wpasupconf.yml ├── handlers.d ├── packages.d ├── services.d └── states.d └── wpasupconf.yml
See also
How to configure Files in vbotka.config_light
1---
2loaderconf:
3 path: "{{ cimage_mount_path }}/boot/loader.conf"
4 force: true
5 owner: root
6 group: wheel
7 mode: "0644"
8 template:
9 path: loader.conf.j2
See also
The template templates/loader.conf.j2
1---
2revaliases:
3 path: "{{ cimage_mount_path }}/etc/rc.conf"
4 force: true
5 owner: root
6 group: wheel
7 mode: "0644"
8 dict: "{{ cimage_rcconf_data }}"
1---
2wpasupconf_wlan0:
3 path: "{{ cimage_mount_path }}/etc/wpa_supplicant.conf.wlan0"
4 force: true
5 owner: root
6 group: wheel
7 mode: "0640"
8 template:
9 path: wpa_supplicant.conf.wlan0.j2
See also
The template templates/wpa_supplicant.conf.wlan0.j2
1---
2wpasup_conf:
3 state: link
4 force: true
5 path: "{{ cimage_mount_path }}/etc/wpa_supplicant.conf"
6 src: wpa_supplicant.conf.wlan0
Create the inventory. Change the IP address (2) and fit the paths to Python (8) and Perl (9) if necessary
1 shell> cat hosts
2 images.example.com ansible_host=<ip-address>
3
4 [images]
5 images.example.com
6
7 [images:vars]
8 ansible_python_interpreter=/usr/local/bin/python3.11
9 ansible_perl_interpreter=/usr/local/bin/perl
Mount the image using the playbook prepared in Quick start guide
shell> ansible-playbook pb-wifi-basic.yml -t cimage_mount
Test the syntax
shell> ansible-playbook pb-wifi-basic-cl.yml --syntax-check
See what variables will be included
shell> ansible-playbook pb-wifi-basic-cl.yml -t cl_debug -e cl_debug=true
Run the playbook
shell> ansible-playbook pb-wifi-basic-cl.yml
Umount the partition and detach the memory disk
shell> ansible-playbook pb-wifi-basic.yml -t cimage_umount
Write the customized image to a disk and boot the system. See the details in Quick start guide.