Skip to content

Commit

Permalink
Merge pull request #44 from redBorder/development
Browse files Browse the repository at this point in the history
Release 2.0.5
  • Loading branch information
manegron committed Jun 5, 2024
2 parents a3cc65a + 344f4b0 commit c1d383e
Show file tree
Hide file tree
Showing 9 changed files with 595 additions and 536 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,63 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Create tag based on metadata.rb
id: create_tag
run: |
TAG=$(grep -o 'version\s*["'\''][^"'\'']*' ./resources/metadata.rb | sed 's/version\s*["'\'']//;s/["'\'']//')
echo "TAG=$TAG" >> $GITHUB_ENV
shell: bash

- name: Check if Tag Exists
id: check_tag
run: |
if git rev-parse "refs/tags/${{ env.TAG }}" >/dev/null 2>&1; then
echo "Tag ${{ env.TAG }} already exists, exiting."
exit 1
fi
shell: bash

- name: Set Version
if: success()
run: echo "VERSION=${{ env.TAG }}" >> $GITHUB_ENV

- name: Run Docker Container
if: success()
run: docker run --privileged -d --name builder --network host rockylinux:9 /bin/sleep infinity

- name: Install build tools RPM
if: success()
run: |
docker cp ./ builder:/build
docker exec builder bash -c "yum install -y epel-release && yum install -y make git mock"
docker exec builder bash -c "rm -rf /etc/mock/default.cfg"
- name: Setup SDK
if: success()
run: |
docker exec builder bash -c "curl https://raw.githubusercontent.com/redBorder/repoinit/master/sdk9.cfg > /build/sdk9.cfg"
docker exec builder bash -c "echo \"config_opts['use_host_resolv'] = True\" >> /build/sdk9.cfg"
docker exec builder bash -c "ln -s /build/sdk9.cfg /etc/mock/default.cfg"
- name: Build RPM using mock
if: success()
run: |
docker exec builder bash -c "git config --global --add safe.directory /build"
docker exec builder bash -c "cd /build/ && VERSION=${{ env.TAG }} make rpm"
- name: Copy RPMS
if: success()
run: |
docker cp builder:/build/packaging/rpm/pkgs/. ./rpms
- name: Delete non-.rpm files
if: success()
run: |
find ./rpms -type f -not -name '*.rpm' -exec rm {} \;
- name: Release
if: success()
uses: softprops/action-gh-release@v1
with:
files: ./rpms/*
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
cookbook-logstash CHANGELOG
===============

## 2.0.5

- Miguel Negrón
- [028f051] Improvement/fix lint (#43)

## 2.0.4

- nilsver
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# cookbook-logstash
[![Build Status][build-shield]][build-url]
[![Linters][linters-shield]][linters-url]
[![License][license-shield]][license-url]

<!-- Badges -->
[build-shield]: https://github.com/redBorder/cookbook-logstash/actions/workflows/rpm.yml/badge.svg?branch=master
[build-url]: https://github.com/redBorder/cookbook-logstash/actions/workflows/rpm.yml?query=branch%3Amaster
[linters-shield]: https://github.com/redBorder/cookbook-logstash/actions/workflows/lint.yml/badge.svg?event=push
[linters-url]: https://github.com/redBorder/cookbook-logstash/actions/workflows/lint.yml
[license-shield]: https://img.shields.io/badge/license-AGPLv3-blue.svg
[license-url]: https://github.com/cookbook-logstash/blob/HEAD/LICENSE

This is the cookbook for logstash integration in redborder.

With this cookbook, redborder platform create needed pipelines that allow normalize, enrich and modify events collected into the platform and indexed later.

### Platforms

- Rocky Linux 9

### Chef

- Chef 15.7.0 or later

## 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
5 changes: 2 additions & 3 deletions resources/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#Flags
default["logstash"]["registered"] = false

# Flags
default['logstash']['registered'] = false
94 changes: 54 additions & 40 deletions resources/libraries/helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Logstash
module Helper

def get_managers
sensors = []
managers_keys = Chef::Node.list.keys.sort
Expand All @@ -18,23 +17,27 @@ def get_managers
end
end

unless roles.nil?
if roles.include?("manager")
sensors << m
end
next unless roles

if roles.include?('manager')
sensors << m
end
end
sensors
end

def get_namespaces
namespaces = []
Chef::Role.list.keys.each do |rol|
Chef::Role.list.each_key do |rol|
ro = Chef::Role.load rol
if ro and ro.override_attributes["redborder"] and ro.override_attributes["redborder"]["namespace"] and ro.override_attributes["redborder"]["namespace_uuid"] and !ro.override_attributes["redborder"]["namespace_uuid"].empty?
namespaces.push(ro.override_attributes["redborder"]["namespace_uuid"])
end
next unless ro && ro.override_attributes['redborder'] &&
ro.override_attributes['redborder']['namespace'] &&
ro.override_attributes['redborder']['namespace_uuid'] &&
!ro.override_attributes['redborder']['namespace_uuid'].empty?

namespaces.push(ro.override_attributes['redborder']['namespace_uuid'])
end

namespaces.uniq
end

Expand All @@ -55,51 +58,62 @@ def get_sensors_info(sensor_type)
end
end

unless roles.nil?
if !roles.empty? and !roles.include?("manager")
case sensor_type
when "ips-sensor"
if roles.include?("ips-sensor") or roles.include?("ipsv2-sensor") or roles.include?("ipscp-sensor")
sensors << m
end
when "cep-sensor"
if m.respond_to?"run_list" and (m.run_list.map{|x| x.name}.include?"vault-sensor" or m.run_list.map{|x| x.name}.include?"cep-sensor")
sensors << m
end
else
if m.respond_to?"run_list" and m.run_list.map{|x| x.name}.include?(sensor_type)
sensors << m
end
end
next unless roles && !roles.empty? && !roles.include?('manager')

case sensor_type
when 'ips-sensor'
if roles.include?('ips-sensor') || roles.include?('ipsv2-sensor') || roles.include?('ipscp-sensor')
sensors << m
end
when 'cep-sensor'
if m.respond_to?('run_list') &&
(m.run_list.map(&:name).include?('vault-sensor') || m.run_list.map(&:name).include?('cep-sensor'))
sensors << m
end
else
if m.respond_to?('run_list') &&
m.run_list.map(&:name).include?(sensor_type)
sensors << m
end
end
end
sensors
end

def check_proxy_monitors(device_nodes)
has_redfish_monitors = false
has_bulkstats_monitors = false

unless device_nodes.nil?
device_nodes.each do |monitor|
if monitor["redborder"]["monitors"]
monitor["redborder"]["monitors"].each do |dmonitor|
has_redfish_monitors = (dmonitor["system"].split().first == "redfish" or has_redfish_monitors)
has_bulkstats_monitors = (dmonitor["system"].to_s.start_with? "bulkstats" or has_bulkstats_monitors)
end
end
def bulkstats_monitors?(device_nodes)
return false unless device_nodes

device_nodes.each do |monitor|
next unless monitor['redborder']['monitors']

monitor['redborder']['monitors'].each do |dmonitor|
return true if dmonitor['system'].to_s.start_with?('bulkstats')
end
end

false
end

def redfish_monitors?(device_nodes)
return false unless device_nodes

device_nodes.each do |monitor|
next unless monitor['redborder']['monitors']

monitor['redborder']['monitors'].each do |dmonitor|
return true if dmonitor['system'].split().first == 'redfish'
end
end
return (has_bulkstats_monitors || has_redfish_monitors), has_bulkstats_monitors, has_redfish_monitors

false
end

def is_proxy?
node['roles'].include? "proxy-sensor"
node.role?('proxy-sensor')
end

def is_manager?
node['roles'].include? "manager"
node.role?('manager')
end
end
end
9 changes: 4 additions & 5 deletions resources/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name 'logstash'
maintainer 'Juan J. Prieto'
maintainer_email 'jjprieto@redborder.com'
license 'All rights reserved'
maintainer 'Eneo Tecnología S.L.'
maintainer_email 'git@redborder.com'
license 'AGPL-3.0'
description 'Installs/Configures cookbook-logstash'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '2.0.4'
version '2.0.5'
Loading

0 comments on commit c1d383e

Please sign in to comment.