Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions lib/puppet/provider/s3ql_mount/s3ql_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ def commands_wrapper(command, *arguments)
Puppet::Util::Execution.execute([command, all_args], opts)
end

# TODO: This *arguments paramether is kinda pointless
def mount_s3ql(*arguments)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't know what i thought here, this code is… weird.

mount_args = ['--allow-other', '--metadata-upload-interval',
allow_other = ''
allow_other = '--allow-other' if @resource[:allow_other]
mount_args = [allow_other, '--metadata-upload-interval',
@resource[:upload_inverval], arguments].flatten
begin
commands_wrapper('mount.s3ql', mount_args)
Expand Down Expand Up @@ -86,10 +89,23 @@ def self.instances
mounts.map do |mnt|
storage_url, _, mountpoint, _, _, options = mnt.split

owner = options.sub(%r{.*user(_id)?=([^,)]+).*}, '\2') if options =~ %r{user(_id)?}
opts_hsh = options.split(',').map { |o|
k = o
v = true
if o.include?('=')
k, v = split('=')
end
[k, v]
}.to_h

owner = opts_hsh['user']
owner ||= opts_hsh['user_id']
owner ||= 0
group = options.sub(%r{.*group(_id)?=([^,)]).*}, '\2') if options =~ %r{group(_id)?}
group = opts_hsh['group']
group ||= opts_hsh['group_id']
group ||= 0
allow_other = opts_hsh['allow_other']
allow_other ||= false

# and initialize @property_hash
new(name: mountpoint,
Expand All @@ -98,7 +114,8 @@ def self.instances
storage_url: storage_url,
owner: owner,
group: group,
backend: storage_url.split(':')[0])
backend: storage_url.split(':')[0],
allow_other: allow_other)
end
end

Expand Down
13 changes: 13 additions & 0 deletions lib/puppet/type/s3ql_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@
end
end

newproperty(:allow_other) do
desc <<-EOS
Whether to allow "other" to access this mountpoint

The default is `false`. To allow it, also make sure to set `allow_other` in `s3ql`.
EOS
defaultto :false
munge do |val|
:false if [false, 'false', :false].include? val
:true if [true, 'true', :true].include? val
end
end

newproperty(:backend) do
desc <<-EOS
The backend used.
Expand Down
9 changes: 9 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@
$package_name = 's3ql',
$package_ensure = 'present',
$package_provider = undef,
$allow_other = false,
) {

package { 's3ql':
ensure => $package_ensure,
name => $package_name,
provider => $package_provider,
}

if $allow_other {
file_line { "user_allow_other ${allow_other}":
path => '/etc/fuse.conf',
line => 'user_allow_other',
match => '^#user_allow_other'
}
}
}
1 change: 1 addition & 0 deletions spec/unit/provider/s3ql_mount/s3ql_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
storage_url: 'gs://bucket/prefix',
owner: 'examplewww',
group: 'examplewww',
allow_other: true,
)
end

Expand Down
1 change: 1 addition & 0 deletions spec/unit/type/s3ql_mount_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
:owner,
:group,
:backend,
:allow_other,
]
end
let :parameters do
Expand Down