github.com/swiftstack/proxyfs@v0.0.0-20201223034610-5434d919416e/cookbooks/swift/recipes/data.rb (about) 1 # Copyright (c) 2015 SwiftStack, Inc. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 # implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 17 # setup up some disk 18 19 [ 20 "/var/lib/swift", 21 "/mnt/swift-disk", 22 ].each do |d| 23 directory d do 24 action :create 25 end 26 end 27 28 execute "create sparse file" do 29 command "truncate -s #{node['loopback_gb']}GB /var/lib/swift/disk" 30 creates "/var/lib/swift/disk" 31 action :run 32 end 33 34 execute "create file system" do 35 command "mkfs.xfs /var/lib/swift/disk" 36 not_if "xfs_admin -l /var/lib/swift/disk" 37 action :run 38 39 notifies :run, "execute[set xfs uuid]", :immediately 40 end 41 42 execute "set xfs uuid" do 43 # the string "generate" is treated specially by xfs_admin and means 44 # "make one up for me" 45 command "xfs_admin -U generate /var/lib/swift/disk" 46 action :nothing 47 end 48 49 execute "update fstab" do 50 command "echo '/var/lib/swift/disk /mnt/swift-disk xfs " \ 51 "loop,noatime,nouuid,nodiratime,nobarrier,logbufs=8 0 0' >> /etc/fstab" 52 not_if "grep swift-disk /etc/fstab" 53 action :run 54 end 55 56 execute "mount" do 57 command "mount /mnt/swift-disk" 58 not_if "mountpoint /mnt/swift-disk" 59 end 60 61 if node['ec_policy'].empty? then 62 num_disks = node['disks'] 63 else 64 num_disks = [node['disks'], node['ec_disks']].max 65 end 66 67 (1..num_disks).each do |i| 68 j = ((i - 1) % node['nodes']) + 1 69 disk_path = "/mnt/swift-disk/sdb#{i}" 70 node_path = "/srv/node#{j}" 71 srv_path = node_path + "/sdb#{i}" 72 directory disk_path do 73 owner "#{node['swift_user']}" 74 group "#{node['swift_group']}" 75 action :create 76 end 77 directory node_path do 78 owner "#{node['swift_user']}" 79 group "#{node['swift_group']}" 80 action :create 81 end 82 link srv_path do 83 to disk_path 84 end 85 end 86 87 # run dirs 88 89 [ 90 "/var/run/swift", 91 "/var/cache/swift", 92 ].each do |d| 93 directory d do 94 owner "#{node['swift_user']}" 95 group "#{node['swift_group']}" 96 action :create 97 end 98 end 99 100 (1..node['nodes']).each do |i| 101 recon_cache_path = "/var/cache/swift/node#{i}" 102 directory recon_cache_path do 103 owner "#{node['swift_user']}" 104 group "#{node['swift_group']}" 105 recursive true 106 end 107 end 108 109 # make $swift_user able to read /var/log/syslog 110 group "adm" do 111 action :modify 112 members "#{node['swift_user']}" 113 append true 114 end