client.rb 3.13 KB
Newer Older
Christopher Huhn's avatar
Christopher Huhn committed
1
#
Victor Penso's avatar
Victor Penso committed
2
# Cookbook Name:: cernvm-fs
3
# Recipe:: client
Christopher Huhn's avatar
Christopher Huhn committed
4
#
5
# Copyright 2013-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
Christopher Huhn's avatar
Christopher Huhn committed
6
7
#
# Authors:
8
9
10
#  Matteo Dessalvi   <m.dessalvi@gsi.de>
#  Christopher Huhn  <c.huhn@gsi.de>
#  Walter Karig
Christopher Huhn's avatar
Christopher Huhn committed
11
#  Bastian Neuburger <b.neuburger@gsi.de>
12
13
#  Matthias Pausch   <m.pausch@gsi.de>
#  Victor Penso      <v.penso@gsi.de>
14
15
16
17
18
19
20
21
22
23
24
25
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
26
#
Victor Penso's avatar
Victor Penso committed
27

28
29
case node['platform_version'].to_i
when 7
30
  node.default['sys']['autofs']['maps']['cvmfs'] = {}
Victor Penso's avatar
Victor Penso committed
31
  include_recipe 'sys::autofs'
32
when 9,10
33
34
  directory '/etc/auto.master.d'

35
36
  file '/etc/auto.master.d/cvmfs.autofs' do
    content <<-EOF
37
38
39
# generated by Chef, cernvm-fs cookbook
/cvmfs program:/etc/auto.cvmfs
EOF
40
41
42
43
44
    notifies :reload, 'service[autofs]'
  end

  service 'autofs' do
    action :nothing
45
  end
Victor Penso's avatar
Victor Penso committed
46
end
47

48

49
50
# Make sure the CMVFS user can use FUSE
# to mount a repositories
51
52
node.default['sys']['fuse']['config']['mount_max'] = 1000
node.default['sys']['fuse']['config']['user_allow_other'] = ''
53
54
55
56
57
58
59
60
include_recipe 'sys::fuse'

user 'cvmfs' do
  shell '/bin/bash'
  system true
end

group 'fuse' do
61
62
  # this should be a system group (ie. gid < 1000)
  system  true
63
  members 'cvmfs'
64
  append  true
65
66
end

67
68
69
execute 'modprobe fuse' do
  not_if 'grep -q "^fuse\>" /proc/modules'
end
b.neuburger's avatar
b.neuburger committed
70

m.pausch's avatar
m.pausch committed
71
directory node['cvmfs']['client']['default_local']['cache_base'] do
72
73
74
75
76
77
  owner 'cvmfs'
  group 'cvmfs'
  mode '0755'
  recursive true
end

78
# make sure CVMFS_HTTP_PROXY is defined:
79
node.default_unless['cvmfs']['client']['default_local']['http_proxy'] = 'DIRECT'
80

81
82
83
template '/etc/cvmfs/default.local' do
  source 'etc_cvmfs_default.local.erb'
  mode "0644"
m.pausch's avatar
m.pausch committed
84
85
86
  variables(
    :repos => node['cvmfs']['client']['config_d'].keys,
    :config => node['cvmfs']['client']['default_local']
87
88
89
90
  )
end


91
92
93
94
95
#
# Domain configs:
#
directory '/etc/cvmfs/domain.d'

96
node['cvmfs']['client']['domain_d'].each do |repo, config|
97
98
99
100
101
102

  template "/etc/cvmfs/domain.d/#{repo}.conf" do
    source 'etc_cvmfs_config.d_generic.conf.erb'
    mode "0644"
    variables(config: config)
  end
103

104
105
106
107
108
109
110
end


#
# Repository configs
#
directory '/etc/cvmfs/config.d'
111

112
113
114
115
116
117
118
119
120
121
122
123
# delete repo configs not managed by this cookbook:
Dir.glob('/etc/cvmfs/config.d/*.conf').each do |f|
  file f do
    action :delete
    only_if { node['cvmfs']['client']['config_d_cleanup'] == true }
    # keep files with a correspoming attribute:
    not_if do
      node['cvmfs']['client']['config_d'].key?(File.basename(f,'.conf'))
    end
  end
end

124
# Each repository needs its configuration file
125
node['cvmfs']['client']['config_d'].each do |repo, config|
126
127
128
129
  template "/etc/cvmfs/config.d/#{repo}.conf" do
    source 'etc_cvmfs_config.d_generic.conf.erb'
    mode "0644"
    variables(config: config)
130
131
  end
end