setting debconf selections for keyboard-configuration fails... layout ends up as Afghani
Solution 1:
I understand your frustration on this one. Here is how I deal with this in similar context (vagrant provisions), so hopefully the day has come.
The key is to use debconf-utils in order to describe the configuration. First:
sudo apt-get install debconf-utils
You can see the current configuration with:
debconf-get-selections | grep keyboard-configuration
Dealing with all these configuration options can be a bit tedious, so you might want to perform an interactive dpkg-reconfigure keyboard-configuration
on one machine, as in the proposed solution. Then, export the new settings with the command above to a new file, say file.conf
.
Transfer the file to the machines that need configuration and:
debconf-set-selections < file.conf
dpkg-reconfigure keyboard-configuration -f noninteractive
That's it really.
BONUS: Ansible tasks
In case you use Ansible, here is a piece of my playbook for this matter:
- name: Configuring keyboard [creating file]
template: src=templates/deb-keyboard.conf.j2 dest=/home/vagrant/.deb-keybard.conf
register: debconf_template
- name: Configuring keyboard [setting selections]
shell: debconf-set-selections < /home/vagrant/.deb-keybard.conf
become: true
when: debconf_template.changed
# or use handlers
- name: Configuring keyboard [reconfiguring dpkg]
command: dpkg-reconfigure keyboard-configuration -f noninteractive
become: true
when: debconf_template.changed
Solution 2:
So ... hopefully some day someone else will have a proper answer, but here's what I ended up doing, which is the same thing I did years ago without preseed:
interactive keyboard setup on one node:
dpkg-reconfigure keyboard-configuration
Then when that's done, copy the console setup stuff
cd
tar czf console-setup.tgz /etc/console-setup
Then send that file to all nodes, or put it on http somewhere.
Then install it on every node with a script, rather than interactively one at a time:
cd
wget http://somewebserver/console-setup.gz -O ~/console-setup.tgz
cd /
mv /etc/console-setup /etc/console-setup.bak
tar xzf ~/console-setup.tgz
gunzip -c /etc/console-setup/cached.kmap.gz | loadkeys
And as long as you don't reconfigure the keyboard some other way, it'll probably remain this way (as it has for years on the previous install). But maybe there are some things that would mess again, such as:
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure keyboard-configuration