Skip to content

Commit

Permalink
Merge pull request #9 from redBorder/development
Browse files Browse the repository at this point in the history
Release 0.0.5
  • Loading branch information
malvads authored May 27, 2024
2 parents 6a9e181 + f1806a3 commit 550a743
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 48 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
cookbook-minio CHANGELOG
===============

## 0.0.5

- Miguel Negrón
- [1aecb04] Improvement/fix cookbook lint (#7)

## 0.0.4

- David Vanhoucke
Expand Down
10 changes: 5 additions & 5 deletions resources/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default["minio"]["user"] = "minio"
default["minio"]["group"] = "minio"
default["minio"]["port"] = 9000
default['minio']['user'] = 'minio'
default['minio']['group'] = 'minio'
default['minio']['port'] = 9000

#Flags
default["minio"]["registered"] = false
# Flags
default['minio']['registered'] = false
9 changes: 4 additions & 5 deletions resources/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name 'minio'
maintainer 'Alberto Rodríguez'
maintainer_email 'arodriguez@redborder'
license 'AGPLv3'
maintainer 'Eneo Tecnología S.L.'
maintainer_email 'git@redborder.com'
license 'AGPL-3.0'
description 'Installs/Configures Minio'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.0.4'
version '0.0.5'
62 changes: 31 additions & 31 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
action :add do #Usually used to install and configure something
action :add do
begin

user = new_resource.user

dnf_package "minio" do
dnf_package 'minio' do
action :upgrade
flush_cache [:before]
end
execute "create_user" do
command "/usr/sbin/useradd -r minio"

execute 'create_user' do
command '/usr/sbin/useradd -r minio'
ignore_failure true
not_if "getent passwd minio"
not_if 'getent passwd minio'
end

%w[ /var/minio /var/minio/data /etc/minio ].each do |path|
%w(/var/minio /var/minio/data /etc/minio).each do |path|
directory path do
owner user
group user
mode 0755
mode '0755'
action :create
end
end

service "minio" do
service_name "minio"
service 'minio' do
service_name 'minio'
ignore_failure true
supports :status => true, :reload => true, :restart => true, :enable => true
supports status: true, reload: true, restart: true, enable: true
action [:start, :enable]
end

Chef::Log.info("Minio cookbook has been processed")
Chef::Log.info('Minio cookbook has been processed')
rescue => e
Chef::Log.error(e.message)
end
Expand All @@ -39,14 +39,14 @@
action :remove do
begin

service "minio" do
service_name "minio"
service 'minio' do
service_name 'minio'
ignore_failure true
supports :status => true, :enable => true
supports status: true, enable: true
action [:stop, :disable]
end

Chef::Log.info("Minio cookbook has been processed")
Chef::Log.info('Minio cookbook has been processed')
rescue => e
Chef::Log.error(e.message)
end
Expand All @@ -56,24 +56,24 @@

begin
consul_servers = system('serf members -tag consul=ready | grep consul=ready &> /dev/null')
if consul_servers and !node["minio"]["registered"]
if consul_servers && !node['minio']['registered']
query = {}
query["ID"] = "s3-#{node["hostname"]}"
query["Name"] = "s3"
query["Address"] = ipaddress
query["Port"] = node["minio"]["port"]
query['ID'] = "s3-#{node['hostname']}"
query['Name'] = 's3'
query['Address'] = ipaddress
query['Port'] = node['minio']['port']
json_query = Chef::JSONCompat.to_json(query)

execute 'Register service in consul' do
command "curl -X PUT http://localhost:8500/v1/agent/service/register -d '#{json_query}' &>/dev/null"
retries 3
retry_delay 2
action :nothing
command "curl -X PUT http://localhost:8500/v1/agent/service/register -d '#{json_query}' &>/dev/null"
retries 3
retry_delay 2
action :nothing
end.run_action(:run)

node.normal["minio"]["registered"] = true
node.normal['minio']['registered'] = true

Chef::Log.info("Minio service has been registered on consul")
Chef::Log.info('Minio service has been registered on consul')
end
rescue => e
Chef::Log.error(e.message)
Expand All @@ -83,15 +83,15 @@
action :deregister do
begin
consul_servers = system('serf members -tag consul=ready | grep consul=ready &> /dev/null')
if consul_servers and node["minio"]["registered"]
if consul_servers && node['minio']['registered']
execute 'Deregister service in consul' do
command "curl -X PUT http://localhost:8500/v1/agent/service/deregister/s3-#{node["hostname"]} &>/dev/null"
command "curl -X PUT http://localhost:8500/v1/agent/service/deregister/s3-#{node['hostname']} &>/dev/null"
action :nothing
end.run_action(:run)

node.normal["minio"]["registered"] = false
node.normal['minio']['registered'] = false

Chef::Log.info("Minio service has been deregistered from consul")
Chef::Log.info('Minio service has been deregistered from consul')
end
rescue => e
Chef::Log.error(e.message)
Expand Down
2 changes: 1 addition & 1 deletion resources/recipes/configure_solo.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
minio_config "config" do
minio_config 'config' do
action [:add]
end
4 changes: 2 additions & 2 deletions resources/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
minio_config "config" do
mystring "test"
minio_config 'config' do
mystring 'test'
action :add
end
8 changes: 4 additions & 4 deletions resources/resources/config.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
actions :add, :remove, :register, :deregister
default_action :add

attribute :user, :kind_of => String, :default => "minio"
attribute :group, :kind_of => String, :default => "minio"
attribute :port, :kind_of => Fixnum, :default => 9000
attribute :user, kind_of: String, default: 'minio'
attribute :group, kind_of: String, default: 'minio'
attribute :port, kind_of: Integer, default: 9000

attribute :ipaddress, :kind_of => String, :default => "127.0.0.1"
attribute :ipaddress, kind_of: String, default: '127.0.0.1'

0 comments on commit 550a743

Please sign in to comment.