Skip to content

Commit

Permalink
Move mcli config to its own action
Browse files Browse the repository at this point in the history
  • Loading branch information
manegron committed Oct 15, 2024
1 parent 7cc8878 commit b63405a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
47 changes: 30 additions & 17 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
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 @@ -34,22 +33,6 @@
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 Expand Up @@ -122,6 +105,36 @@
end
end

action :add_mcli do
managers_with_minio = new_resource.managers_with_minio
s3_bucket = new_resource.s3_bucket
s3_endpoint = new_resource.s3_endpoint

if !Minio::Helpers.s3_ready?
s3_user = Minio::Helpers.generate_random_key(20)
s3_password = Minio::Helpers.generate_random_key(40)
else
s3_user = new_resource.access_key_id
s3_password = new_resource.secret_key_id
end

# mcli (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
end

action :remove do
begin

Expand Down
2 changes: 1 addition & 1 deletion resources/resources/config.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
actions :add, :remove, :register, :deregister, :add_s3_conf_nginx
actions :add, :remove, :register, :deregister, :add_s3_conf_nginx, :add_mcli
default_action :add

attribute :user, kind_of: String, default: 'minio'
Expand Down

0 comments on commit b63405a

Please sign in to comment.