Skip to content

Instantly share code, notes, and snippets.

@tjheeta
Last active August 29, 2015 14:08
Show Gist options
  • Save tjheeta/022e890c77385a9e435f to your computer and use it in GitHub Desktop.
Save tjheeta/022e890c77385a9e435f to your computer and use it in GitHub Desktop.
Chef recipe for fixing ssh errors on centos lxc by modifying udev
SSH to the host times out.
Errors seen in /var/log/messages:
Oct 30 14:11:44 mon1 init: tty (/dev/lxc/tty[1-4]) main process (23809) terminated with status 1
Oct 30 14:11:44 mon1 init: tty (/dev/lxc/tty[1-4]) main process ended, respawning
Oct 30 14:11:46 mon1 init: runsvdir main process (133) terminated with status 111
Oct 30 14:11:46 mon1 init: tty (/dev/lxc/tty[1-4]) main process (23812) killed by TERM signal
dev_file = "/etc/rc.d/rc.sysinit"
sed_change = /^\/sbin\/start_udev/
ruby_block "change rc.sysinit for lxc" do
block do
sed = Chef::Util::FileEdit.new(udev_file)
sed.search_file_replace(sed_change, '\1')
sed.write_file
end
only_if { ::File.readlines(udev_file).grep(sed_change).any? }
end if node.key?('virtualization') && node['virtualization']['system'] == 'lxc'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment