Skip to content

Instantly share code, notes, and snippets.

@jdesboeufs
Last active February 14, 2017 22:09
Show Gist options
  • Save jdesboeufs/8eba2b96846a39de5348e4846a4835ef to your computer and use it in GitHub Desktop.
Save jdesboeufs/8eba2b96846a39de5348e4846a4835ef to your computer and use it in GitHub Desktop.
Example Ansible playbook for ovh/svfs

Containers are immediately available in /mnt/{vfs.name}

Related to issue #84

- hosts: myHosts
tasks:
- name: check installed package
shell: dpkg -s svfs || true
register: check_installed
become: yes
- name: install package
apt: deb=https://github.com/ovh/svfs/releases/download/v0.7.3/svfs_0.7.3_amd64.deb update_cache=yes
when: check_installed.stdout.find("0.7.3") == -1
become: yes
- name: override mount.svfs file (temp fix)
copy: src=mount.svfs dest=/sbin/mount.svfs mode=0755
become: yes
- name: ensure /mnt exists
file: path=/mnt state=directory
become: yes
- name: mount filesystems
mount:
src: svfs_{{item.name}}
fstype: svfs
name: /mnt/{{item.name}}
opts: username={{svfs.userName}},password={{svfs.password}},tenant={{svfs.tenantName}},region={{svfs.regionName}},container={{item.container}},uid=deploy,gid=deploy,_netdev,auto
state: mounted
with_items: "{{svfs.vfs}}"
become: yes
vars:
svfs:
tenantName: XXXX
userName: XXXX
password: XXXX
regionName: GRA1
vfs:
- name: backups
container: backups
- name: sites
container: sites
#!/usr/bin/env ruby
# *****************************************************************************
# SVFS: The Swift Virtual File System
# *****************************************************************************
# SVFS allows mounting Swift storage as a file system, using fuse. Check the
# project homepage for details and limitations to this approach.
# *****************************************************************************
# @vendor : OVH
# *****************************************************************************
if ENV['PATH'].nil?
ENV['PATH'] = "/bin:/usr/bin:/usr/local/bin"
end
OPTIONS = {
'allow_other' => '--allow-other',
'allow_root' => '--allow-root',
'block_size' => '--block-size',
'cache_access' => '--cache-max-access',
'cache_entries' => '--cache-max-entries',
'cache_ttl' => '--cache-ttl',
'container' => '--os-container-name',
'debug' => '--debug',
'default_perm' => '--default-permissions',
'extra_attr' => '--readdir-extra-attributes',
'gid' => '--default-gid',
'hubic_auth' => '--hubic-authorization',
'hubic_times' => '--hubic-times',
'hubic_token' => '--hubic-refresh-token',
'identity_url' => '--os-auth-url',
'mode' => '--default-mode',
'password' => '--os-password',
'profile_addr' => '--profile-bind',
'profile_cpu' => '--profile-cpu',
'profile_ram' => '--profile-ram',
'readdir' => '--readdir-concurrency',
'readahead_size' => '--readahead-size',
'region' => '--os-region-name',
'ro' => '--read-only',
'segment_size' => '--os-segment-size',
'storage_url' => '--os-storage-url',
'tenant' => '--os-tenant-name',
'timeout' => '--os-connect-timeout',
'token' => '--os-auth-token',
'uid' => '--default-uid',
'username' => '--os-username',
'version' => '--os-auth-version',
}
if ARGV[2] != '-o' || ARGV.length != 4
puts "Usage: #{File.basename($0)} dev dir [-o option=value,[option=value]...]\n"
abort
end
mount_dev = ARGV[0]
mount_dir = ARGV[1]
opts = ARGV[3].split(',')
extra = ""
opts.select! do |o|
part = o.partition('=')
opt_key = part.first
if opt_key == "go_gc"
extra = "GOGC=#{part.last} "
end
if OPTIONS.has_key?(opt_key)
o[opt_key] = OPTIONS[opt_key]
end
end
if extra.empty?
extra = "GOGC=60 "
end
system("#{extra}nohup svfs #{opts.join(' ')} #{mount_dev} #{mount_dir} &")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment