Skip to content

Commit

Permalink
Merge pull request dev-sec#29 from TelekomLabs/restart
Browse files Browse the repository at this point in the history
  • Loading branch information
arlimus committed Jul 1, 2014
2 parents edeb510 + 09f8f75 commit 638011f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions attributes/default.rb
Expand Up @@ -33,6 +33,14 @@
# Define the server package name
default['sshserver']['package'] = 'openssh-server'

# Define the service name for sshd
case node['platform_family']
when 'rhel', 'fedora', 'suse', 'freebsd', 'gentoo'
default['sshserver']['service_name'] = 'sshd'
else
default['sshserver']['service_name'] = 'ssh'
end

default['config_disclaimer'] = '**Note:** This file was automatically created by Pinerolo configuration. If you use its automated setup, do not edit this file directly, but adjust the automation instead.'
default['network']['ipv6']['enable'] = false # sshd + ssh
default['ssh']['cbc_required'] = false # sshd + ssh
Expand Down
29 changes: 29 additions & 0 deletions recipes/server.rb
Expand Up @@ -19,10 +19,38 @@
# limitations under the License.
#

# installs package name
package 'openssh-server' do
package_name node['sshserver']['package']
end

# defines the sshd service
service 'sshd' do
# use upstart for ubuntu, otherwise chef uses init
# @see http://docs.opscode.com/resource_service.html#providers
case node['platform']
when 'ubuntu'
if node['platform_version'].to_f >= 12.04
provider Chef::Provider::Service::Upstart
end
end
service_name node['sshserver']['service_name']
supports value_for_platform(
'centos' => { 'default' => [:restart, :reload, :status] },
'redhat' => { 'default' => [:restart, :reload, :status] },
'fedora' => { 'default' => [:restart, :reload, :status] },
'scientific' => { 'default' => [:restart, :reload, :status] },
'arch' => { 'default' => [:restart] },
'debian' => { 'default' => [:restart, :reload, :status] },
'ubuntu' => {
'8.04' => [:restart, :reload],
'default' => [:restart, :reload, :status]
},
'default' => { 'default' => [:restart, :reload] }
)
action [:enable, :start]
end

directory '/etc/ssh' do
mode 0755
owner 'root'
Expand All @@ -40,6 +68,7 @@
kex: SshKex.get_kexs(node, node['ssh']['weak_kex']),
cipher: SshCipher.get_ciphers(node, node['ssh']['cbc_required'])
)
notifies :restart, 'service[sshd]'
end

def get_key_from(field)
Expand Down

0 comments on commit 638011f

Please sign in to comment.