I'm trying to find the best way with Puppet to change the default editor on all machines(Ubuntu & RedHat) so that any user is constrained to use a type of editor. And to keep it possible to change editor for its own use.
The goal, avoid the message below When I invoke "crontab -e". and get vim instead :
$ crontab -e
Select an editor. To change later, run 'select-editor'.
1. /bin/ed
2. /bin/nano <---- easiest
3. /usr/bin/jove
4. /usr/bin/vim.basic
5. /usr/bin/vim.tiny
Here's a proposal via puppet:
class vim {
package { vim:
ensure => present,
}
file { "/etc/vim/vimrc":
owner => root,
group => root,
mode => 644,
source => "puppet:///vim/vimrc",
require => Package["vim"],
}
exec { "update-alternatives --set editor /usr/bin/vim.basic":
unless => "test /etc/alternatives/editor -ef /usr/bin/vim.basic"
}
}
Any comments or remarks are welcome. many thanks.