Skip to content

Commit

Permalink
Merge pull request #26 from redBorder/feature/add_mc_tool
Browse files Browse the repository at this point in the history
Feature/add mc tool (mcli)
  • Loading branch information
manegron authored Oct 15, 2024
2 parents 90ffa0e + a869458 commit 780b272
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
17 changes: 17 additions & 0 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
user = new_resource.user
s3_bucket = new_resource.s3_bucket
s3_endpoint = new_resource.s3_endpoint
managers_with_minio = new_resource.managers_with_minio

if !Minio::Helpers.s3_ready?
s3_user = Minio::Helpers.generate_random_key(20)
Expand Down Expand Up @@ -33,6 +34,22 @@
end
end

# MC tool configuration
directory '/root/.mcli' do
owner 'root'
group 'root'
mode '0755'
action :create
end

template '/root/.mcli/config.json' do
source 'mcli_config.json.erb'
cookbook 'minio'
variables(s3_user: s3_user,
s3_password: s3_password,
managers_with_minio: managers_with_minio)
end

service 'minio' do
service_name 'minio'
ignore_failure true
Expand Down
1 change: 1 addition & 0 deletions resources/resources/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
attribute :s3_endpoint, kind_of: String, default: 's3.service'
attribute :ipaddress, kind_of: String, default: '127.0.0.1'
attribute :s3_hosts, kind_of: Array, default: ['localhost:9000']
attribute :managers_with_minio, kind_of: Array, default: ['localhost']
43 changes: 43 additions & 0 deletions resources/templates/default/mcli_config.json.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"version": "10",
"aliases": {
"gcs": {
"url": "https://storage.googleapis.com",
"accessKey": "YOUR-ACCESS-KEY-HERE",
"secretKey": "YOUR-SECRET-KEY-HERE",
"api": "S3v2",
"path": "dns"
},
"local": {
"url": "http://localhost:9000",
"accessKey": "<%= @s3_user %>",
"secretKey": "<%= @s3_password %>",
"api": "S3v4",
"path": "auto"
},
"play": {
"url": "https://play.min.io",
"accessKey": "YOUR-ACCESS-KEY-HERE",
"secretKey": "YOUR-ACCESS-KEY-HERE",
"api": "S3v4",
"path": "auto"
},
<% @managers_with_minio.each do |m| %>
<% manager = (m == 'localhost') ? node.name : m %>
"<%= manager %>": {
"url": "<%= "http://#{manager}.#{node.default['redborder']['cdomain']}:#{node['minio']['port']}" %>",
"accessKey": "<%= @s3_user %>",
"secretKey": "<%= @s3_password %>",
"api": "s3v4",
"path": "auto"
},
<% end %>
"s3": {
"url": "https://s3.amazonaws.com",
"accessKey": "YOUR-ACCESS-KEY-HERE",
"secretKey": "YOUR-SECRET-KEY-HERE",
"api": "S3v4",
"path": "dns"
}
}
}

0 comments on commit 780b272

Please sign in to comment.