Skip to content

Commit

Permalink
Merge pull request #2 from redBorder/development
Browse files Browse the repository at this point in the history
Release 0.0.1
  • Loading branch information
malvads authored May 24, 2024
2 parents ba019ad + 3f92c75 commit 3971ead
Show file tree
Hide file tree
Showing 15 changed files with 901 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# RPM
pkgs
SOURCES

# DS_Store
.DS_Store
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# .rubocop.yml

# Deshabilita la regla Chef/Deprecations/ResourceWithoutUnifiedTrue
Chef/Deprecations/ResourceWithoutUnifiedTrue:
Enabled: false
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cookbook-rb-common CHANGELOG
===============

## 0.0.1

- Miguel Negrón
- [dc1026b] Feature/add nofile configuration (#1)
- Initial version


5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'cookstyle', '= 7.32.1'
gem 'rspec', '= 3.11'
gem 'rubocop', '= 1.25.1'
663 changes: 663 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all: rpm

rpm:
$(MAKE) -C packaging/rpm

rpmtest:
$(MAKE) LATEST=`git stash create` -C packaging/rpm
55 changes: 55 additions & 0 deletions packaging/rpm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
PACKAGE_NAME?= cookbook-rb-common

VERSION?= $(shell git describe --abbrev=6 --tags HEAD --always | sed 's/-/_/g')

BUILD_NUMBER?= 1

MOCK_CONFIG?=default

RESULT_DIR?=pkgs

LATEST?=HEAD

all: rpm


SOURCES:
mkdir -p SOURCES

archive: SOURCES
cd ../../ && \
git archive --prefix=$(PACKAGE_NAME)-$(VERSION)/ \
-o packaging/rpm/SOURCES/$(PACKAGE_NAME)-$(VERSION).tar.gz $(LATEST)


build_prepare: archive
mkdir -p $(RESULT_DIR)
rm -f $(RESULT_DIR)/$(PACKAGE_NAME)*.rpm


srpm: build_prepare
/usr/bin/mock \
-r $(MOCK_CONFIG) \
--define "__version $(VERSION)" \
--define "__release $(BUILD_NUMBER)" \
--resultdir=$(RESULT_DIR) \
--buildsrpm \
--spec=${PACKAGE_NAME}.spec \
--sources=SOURCES
@echo "======= Source RPM now available in $(RESULT_DIR) ======="

rpm: srpm
/usr/bin/mock \
-r $(MOCK_CONFIG) \
--define "__version $(VERSION)"\
--define "__release $(BUILD_NUMBER)"\
--resultdir=$(RESULT_DIR) \
--rebuild $(RESULT_DIR)/$(PACKAGE_NAME)*.src.rpm
@echo "======= Binary RPMs now available in $(RESULT_DIR) ======="

clean:
rm -rf SOURCES pkgs

distclean: clean
rm -f build.log root.log state.log available_pkgs installed_pkgs \
*.rpm *.tar.gz
49 changes: 49 additions & 0 deletions packaging/rpm/cookbook-rb-common.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Name: cookbook-rb-common
Version: %{__version}
Release: %{__release}%{?dist}
BuildArch: noarch
Summary: redborder common cookbook to configure redborder system settings

License: AGPL 3.0
URL: https://github.com/redBorder/cookbook-rb-common
Source0: %{name}-%{version}.tar.gz

%description
%{summary}

%prep
%setup -qn %{name}-%{version}

%build

%install
mkdir -p %{buildroot}/var/chef/cookbooks/rb-common
cp -f -r resources/* %{buildroot}/var/chef/cookbooks/rb-common/
chmod -R 0755 %{buildroot}/var/chef/cookbooks/rb-common
install -D -m 0644 README.md %{buildroot}/var/chef/cookbooks/rb-common/README.md

%pre

%post
case "$1" in
1)
# This is an initial install.
:
;;
2)
# This is an upgrade.
su - -s /bin/bash -c 'source /etc/profile && rvm gemset use default && env knife cookbook upload rb-common'
;;
esac

%files
%defattr(0755,root,root)
/var/chef/cookbooks/rb-common
%defattr(0644,root,root)
/var/chef/cookbooks/rb-common/README.md

%doc

%changelog
* Thu May 21 2024 Miguel Negrón <[email protected]>
- Inital version
34 changes: 34 additions & 0 deletions resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# common Cookbook

Cookbook to configure common system redborder settings

### Platforms

- Rocky Linux 9

### Chef

- Chef 12.0 or later

# BUILDING

- Build rpm package for redborder platform:
* git clone https://github.com/redborder/cookbook-rb-common.git
* cd cookbook-rb-common
* make
* RPM packages is under packaging/rpm/pkgs/

## Contributing

1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write your change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github

## License
GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007

## Authors
Miguel Negrón <[email protected]>
5 changes: 5 additions & 0 deletions resources/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# require 'set' TODO: refactor to this
# nofile settings (ulimits)
default[:redborder][:nofile] = {}
default[:redborder][:nofile][:soft] = 8192
default[:redborder][:nofile][:hard] = 8192
6 changes: 6 additions & 0 deletions resources/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name 'rb-common'
maintainer 'Miguel Negron'
maintainer_email '[email protected]'
license 'All rights reserved'
description 'Redborder common system settings'
version '0.0.1'
26 changes: 26 additions & 0 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Cookbook:: rb-common
# Provider:: config

action :configure do
# nofile settings
# soft
execute "ulimit -Sn #{node['redborder']['nofile']['soft']}" do
not_if "ulimit -Sn | grep #{node['redborder']['nofile']['soft']}"
end

# hard
execute "ulimit -Hn #{node['redborder']['nofile']['hard']}" do
not_if "ulimit -Hn | grep #{node['redborder']['nofile']['hard']}"
end

template '/etc/security/limits.d/10-nofile.conf' do
source '10-nofile.conf.erb'
cookbook 'rb-common'
owner 'root'
owner 'root'
mode '644'
retries 2
variables(soft: node['redborder']['nofile']['soft'],
hard: node['redborder']['nofile']['hard'])
end
end
8 changes: 8 additions & 0 deletions resources/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Cookbook:: rb-common
# Recipe:: default
# Copyright:: 2024, redborder
# License:: Affero General Public License, Version 3

rb_common_config 'config' do
action :configure
end
5 changes: 5 additions & 0 deletions resources/resources/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Cookbook:: rb-common
# Resource:: config

actions :configure
default_action :configure
17 changes: 17 additions & 0 deletions resources/templates/default/10-nofile.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<%####################################################################### %>
<%# Copyright (c) 2024 ENEO Tecnología S.L. %>
<%# This file is part of redBorder. %>
<%# redBorder is free software: you can redistribute it and/or modify %>
<%# it under the terms of the GNU Affero General Public License License as published by %>
<%# the Free Software Foundation, either version 3 of the License, or %>
<%# (at your option) any later version. %>
<%# redBorder is distributed in the hope that it will be useful, %>
<%# but WITHOUT ANY WARRANTY; without even the implied warranty of %>
<%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %>
<%# GNU Affero General Public License License for more details. %>
<%# You should have received a copy of the GNU Affero General Public License License %>
<%# along with redBorder. If not, see <http://www.gnu.org/licenses/>. %>
<%####################################################################### %>
# Generated by CHEF
* soft nofile <%=@soft%>
* hard nofile <%=@hard%>

0 comments on commit 3971ead

Please sign in to comment.