SlideShare a Scribd company logo
CMDB Driven by Perl
Road to a Perl ”driven” Configuration Management Database
Jens Rehsack
Niederrhein Perl Mongers
The Perl Conference in Amsterdam
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 1 / 44
Introduction Motivation
Motivation
Progress
Progress isn’t made by early risers. It’s made by lazy men trying to
find easier ways to do something.
(Robert A. Heinlein)
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 3 / 44
Introduction Motivation
Motivation
Efficiency
Business success is because of Perl. It enables us to deliver right
solutions in days instead of months.
(Elizabeth Mattijsen)
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 4 / 44
Introduction Motivation
Goal
Automation
Full flavoured systems management
Installation without Administrator interaction
Control sensors and alarming
Ensured system state by actual-theoretical comparison
Faster reaction in emergency cases by organized component moving
Have an up-to-date ”Operation Handbook” as well as archiving them
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 5 / 44
Beginning Taking over
Begin with reporting
Begin with reporting
In the beginning was the (Installation-)Report
Technical Sales defined an XML Document for Change Requests and Status
Reports
Based on work of forerunner a 70% solution could be delivered
Document Definition lacks entity-relations
Document Definition misses technolgy requirements
⇒ Appears to be a dead end
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 7 / 44
Beginning After reporting
From reporting to . . .
Mind the goal
Alice: Would you tell me, please, which way I ought to go from here?
The Cheshire Cat: That depends a good deal on where you want to
get to.
(Lewis Carroll)
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 8 / 44
Beginning Mine Sweeper
Where do I begin
To write the workflow how great Perl 5 can be
The project was in a state where a developer created a particular Report
based on the existing snapshot.
This solution did not maintain an abstraction layer for gathered data - every
time when the report needs an extension, an end-to-end (snapshot to
XML-Tag) enhancement had to be created.
Changes shall be deployed from the same report format as installations are
reported.
We have to be able to say at any moment what is operated on the platform.
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 9 / 44
Beginning Baby Steps
Baby Steps
Improve knowledge
Based on identified issues the first goal had to be to identify all entities and their
relations together
Surrounded
Problem: The entire platform was completely unstructured
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 10 / 44
Beginning Baby Steps
Baby Steps
Multiple Beginnings
The already known ”(Installation-)Report”
Platform Snapshot (SCM Repository of selected configuration files)
Puppet Classes (without Hiera) mixed with Configuration Items (within
Hiera) and prepared configuration files (unsupervised)
Hiera is Puppet’s built-in key/value data lookup system. By default, it uses
simple YAML or JSON files, although one can extend it to work with
almost any data source.
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 11 / 44
World Domination Separation
Circle in the Sand
:platform
:snapshot
:scan db:cmdb
:hiera
:report
collect
scan
process-scan
yaml-gen
puppet run
CRQ
export
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 13 / 44
Concerns Identifying
Technical Concerns
Rough
Collecting platform parameters (to query them in structured way)
Identify coherences of Configuration Items (CI)
Define a data model
Define technical requirements
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 14 / 44
Concerns Identifying
Practical Concerns
Practical
Validity of CI’s
Limits of our CI’s
Data ownership of CI’s
Methods to persist CI’s
Methods to access CI’s
Permission management
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 15 / 44
Tuck In! MI:5
Impossible Things
Impossible Things
Alice laughed. ”There’s no use trying,” she said: ”one can’t believe
impossible things.”
”I daresay you haven’t had much practice,” said the Queen. ”When I
was your age, I always did it for half-an-hour a day. Why, sometimes I’ve
believed as many as six impossible things before
breakfast.” (Lewis Carroll)
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 17 / 44
Tuck In! Home Improvement
The Fool with a Tool
Try again
So we closed our eyes, took a deep breath (multiple times) and looked around for
tools to store serialized data and read in structured way . . .
Tool Time
MongoDB allows easy storing in any format - but lacks structured querying
dedicated entities (configuration items)
Data Files delegate relationship handling completely to business logic
AnyData2 gotcha - allows reading most confusing stuff and could be queried in
structured way
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 18 / 44
Tuck In! Home Improvement
. . . is still a Fool
Volatile Structure
Persist structured data using SQLite
Define a data model representing existing relations
Develop AnyData2::Format classes representing defined ER (Entity
Relationship) model
Develop simple MOP inside this AnyData2 instance to manage attributes vs.
columns
Glue everything together using SQL
The entire ER model remains a moving target
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 19 / 44
Tuck In! Clean Picture
Abstraction Layer
. . . of configured components
Focus the goal to know what is operated
Depth first search over all component configuration files
Identify relationships (remember: there is no operation model at all)
Clean up configuration when no reasonable relationships can be resolved or
relationships are conflicting
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 20 / 44
Tuck In! Control
Moo in practice
Moo in practice
It appears that the tools helping to do safe IoT device updating are the same tools
helping to coordinate CI determining:
MooX::Cmd helps separating concerns
MooX::ConfigFromFile helps contribute ”divine wisdom”
MooX::Options allow overriding ”divine wisdom” by ”individual
wisdom”
MooX::Log::Any feeds DBIx::LogAny
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 21 / 44
Tuck In! Control
Moo in background
Moo in background
Manage database connections based on concerns
Manage CI structures based on relations
Manage Web-API integration
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 22 / 44
Tuck In! Reflecting Relationships
Craziness
Crazy
I’m not crazy. My reality is just different than yours.
The Cheshire Cat
(Lewis Carroll)
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 23 / 44
Tuck In! Reflecting Relationships
Harmonization
Harmonize Craziness
Practically any administrator had a different background regarding to the
platform components thus a different picture of their relationships
EPIC battles leads to common craziness
ER model analysis sessions uncovered holes in picture
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 24 / 44
Tuck In! Meanwhile
Civilized
March Hare: Have some wine.
(Alice looked all round the table, but there was nothing on it but tea.)
Alice: I don’t see any wine.
March Hare: There isn’t any.
Alice: Then it wasn’t very civil of you to offer it.
March Hare: It wasn’t very civil of you to sit down without being invited.
(Lewis Carroll)
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 25 / 44
Tuck In! Meanwhile
Adding a Goal
CentOS 5 ends its maintenance
Many of existing tools need to be upgraded
Upgraded tools don’t support existing hacks anymore
Existing hacks must be replaced by a reasonable configuration structure
Same problem like the report format:
◮ neither the ER model of platform components nor issues of platform where
known
◮ nor cared about
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 26 / 44
Tuck In! Meanwhile
Self Protection
Delegation
We learned from mistakes of past:
No responsibility taken for filling weird puppet templates
No external data will be managed
No precompiled/puzzled resources are prepared
⇒ ER model of CMDB is presented via RESTful API
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 27 / 44
Tuck In! Merging Pictures
Scan completed
Early implementation of above mentioned RESTful API run against ScanDB
ScanDB represents just a view of the configuration snapshot
There is no future, nor past
Time for CMDB to enter the stage
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 28 / 44
Tuck In! Future and Past
Customers . . .
CREATE TABLE customer_t
(
customer _id INTEGER PRIMARY KEY
-- entity stuff
, c ustomer_name VARCHAR (80) UNIQUE NOT NULL
-- cmdb stuff
, valid _from DATETIME NOT NULL
, valid _to DATETIME
, modified _at DATETIME NOT NULL
, modified _by VARCHAR (32) NOT NULL
);
primary key and global identifier for this data type
the payload of this data type, automatically indexed
CMDB manages history and updates using these columns
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 29 / 44
Tuck In! Future and Past
VPN links to customers . . .
CREATE TABLE vpn_link_t
(
vpn_link_id INTEGER PRIMARY KEY
-- entity stuff
, customer_id INTEGER NOT NULL
, v pn_link_type VARCHAR (12)
, custom er_net VARCHAR (64) UNIQUE NOT NULL
, servic es_net VARCHAR (64) UNIQUE NOT NULL
-- cmdb stuff
, valid_from DATETIME NOT NULL
, valid_to DATETIME
, modified_at DATETIME NOT NULL
, modified_by VARCHAR (32) NOT NULL
-- FK
, FOREIGN KEY ( customer_id ) REFERENCES customer_t( customer_id )
ON UPDATE CASCADE ON DELETE CASCADE
);
refer the customer
support Cisco, Juniper, Paolo Alto, . . .
networks must be unique or network admins kill you
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 30 / 44
Tuck In! Future and Past
Moo Interception
package Foo:: Role :: Database :: CMDB;
use Moo:: Role;
requires "log";
has cmdb => (
is => "ro",
required => 1,
handles => "Foo:: Role :: Database",
isa => sub {
_INSTANCE_OF($_[0], "Foo:: Helper :: CMDB") and $_[0]-> DOES("Foo:: Role :: Dat
and return;
die " Insufficient initialisation parameter for cmdb";
},
coerce => sub {
_HASH($_ [0]) and return Foo :: Helper ::CMDB ->new (%{$_ [0]});
$_ [0];
},
);
role can be consumed by any class needing access to CMDB
transform hash initializer into object
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 31 / 44
Tuck In! Future and Past
Hard work
package Foo:: Helper :: CMDB;
use Moo; extends "Foo:: Helper :: DatabaseClass ";
has config _tables => (is => "lazy", ...);
has history_tabl es => (is => "lazy", ...);
around deploy => sub { ...
my @tables = @{$self -> config_tables };
foreach my $tbl (@tables) {
my @h ist_coldefs =
map { my $default = defined $_ - >[4] ? " DEFAULT $_ - >[4]" : "";
$pure_cols{$_ - >[1]} ? ("$_ - >[1] $_ - >[2] $default")
: ("old_$_ - >[1] $_ - >[2] $default", "new_$_ - >[1] $_ - >[2] $default")
} @table_info ;
}
unshift @hist_coldefs , "${base_name}_hist_id INTEGER PRIMARY KEY";
my $hist_defs = join("n , ", @hist_coldefs );
my $hist_tbl = <<EOCHT;
CREATE TABLE ${base_name}_hist (
${hist_defs}
);
EOCHT
that are all tables with trailing t in their names
create history table for each config table
memoizing old and new values on updating payload
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 32 / 44
Tuck In! Future and Past
Hard work (continued) - INSERT
my $new_cols = join(", ", map { $pure_cols{$_} ? $_ : "new_$_" }
grep { !$skipped{$_} } @table_cols );
my $new_vals = join(", ", map {"NEW.$_"} grep { !$skipped{$_} } @table_cols );
my $new_trgr = <<EONT;
CREATE TRIGGER new_${base_name}_row AFTER INSERT ON ${base_name}_t
BEGIN
INSERT INTO ${base_name}_hist ($new_cols)
VALUES ($new_vals );
END;
EONT
⇒ ON INSERT fill history rows without filling ”OLD ” columns
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 33 / 44
Tuck In! Future and Past
Hard work (continued) - UPDATE
my (@updt_cols , @rfrs_cond , @updt_vals );
foreach my $colnm (grep { !$skipped{$_} } @table_cols ) {
my @lcd = $pure_cols{$colnm} ? $colnm : ("old_${colnm}", "new_${colnm}");
push @updt_cols , @lcd;
push @rfrs_cond , $pure_cols{$colnm}
? _cmp_if_nullable ("existing.${colnm}", "NEW.${colnm}")
: ( _cmp_if_nullable ("existing.old_${colnm}", "OLD.${colnm}"),
_cmp_if_nullable ("existing.new_${colnm}", "NEW.${colnm}"));
push @updt_vals , $pure_cols{$colnm }?("NEW.$colnm"):("OLD.$colnm","NEW.$colnm")
}
my $updt_cols = join(", ", @updt_cols );
my $updt_refreshed_cols = join(", ", map { "refreshed.$_" } @updt_cols );
my $updt_vals = join(", ", @updt_vals );
⇒ Prepare for a bit complexer trigger
⇒ Distinguish between real updates and just ”touches”
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 34 / 44
Tuck In! Future and Past
Hard work (continued) - UPDATE
my $updt_trgr = <<EONT;
CREATE TRIGGER updt_${base_name}_row AFTER UPDATE ON ${base_name}_t
BEGIN
INSERT OR REPLACE INTO ${base_name}_hist (${base_name}_hist_id , $updt_cols)
VALUES (
(SELECT MAX(existing.${base_name}_hist_id) ${base_name}_hist_id
FROM ${base_name}_hist existing WHERE $updt_refreshed_cond ),
$updt_vals );
END;
EONT
⇒ ON UPDATE create history (INSERT) rows with ”OLD ” and ”NEW ”
columns
except nothing changes (REPLACE)
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 35 / 44
Tuck In! Features
”UPSERT”
MERGE INTO tablename USING table_reference ON (condition)
WHEN MATCHED THEN
UPDATE SET column1 = value1 [, column2 = value2 ...]
WHEN NOT MATCHED THEN
INSERT (column1 [, column2 ...]) VALUES (value1 [, value2 ...]);
SQLite
Unsupported by SQLite
INSERT OR REPLACE deletes before insert
→ Kills UPDATE Trigger
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 36 / 44
Tuck In! Features
Perl helps out
$self ->cmdb ->upsert( customer_t => {
customer_name => "Foo Enterprises ", });
$self ->cmdb ->upsert( vpn_link_t => {
customer_name => "Foo Enterprises ",
vpn_link_type => "Juniper",
customer_net => " 10.116.47.8/29",
services_net => " 10.126.47.8/29" } );
SQL created . . .
INSERT OR IGNORE INTO vpn_link_t (
customer_id , vpn_link_type , customer_net , services_net , modified_by
) VALUES (
(SELECT customer_id FROM customer_t WHERE customer_name =?),
?, ?, ?, ?);
UPDATE vpn_link_t SET vpn_link_type =?, customer_net =?, services_net =?,
modified_by =?, touched_at= CURRENT_TIMESTAMP
WHERE changes ()=0 AND customer_id =(
SELECT customer_id FROM customer_t WHERE customer_name =?);
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 37 / 44
Tuck In! Features
Known limitations
Restricted to CMDB
Refuse updates of identifying columns (UNIQUE constraints)
WHERE clause derived from UNIQUE constraints
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 38 / 44
Tuck In! Meanwhile II
CMDB to Hiera
YAML Generator
Development team read via RESTful API the theoretical configuration set
Hiera YAML files are written
Additional exports are managed via Hiera
Puppet classes are rewritten to understand new ER model
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 39 / 44
Goals reached Circle closed
Circle closed
:platform
:snapshot
:scan db:cmdb
:hiera
:report
collect
scan
process-scan
yaml-gen
puppet run
CRQ
export
scan
process-scan
yaml-gen
CRQ
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 41 / 44
Goals reached Circle closed
Goals reached
→ Actual-theoretical comparison done via processing scan database
→ Unmaintainted installation via cronjob possible
→ Reaction in emergency cases by organized component moving done multiple
times
→ Monitoring, sensors, alarming open
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 42 / 44
Conclusion
Conclusion
Can a programming language save a life
Yes, it can - but here it saves our business
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 43 / 44
Thank you Thank you
Thank You For Listening
Questions?
Jens Rehsack <rehsack@cpan.org>
Cologne
Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 44 / 44

More Related Content

PPTX
Thinking in parallel ab tuladev
PDF
Cross Compiling for Perl Hackers
PDF
Propel Your PHP Applications
PPTX
S4: Distributed Stream Computing Platform
PPT
Fed Up Of Framework Hype Dcphp
PDF
Get your organization’s feet wet with Semantic Web Technologies
PDF
the productive programer: mechanics
Thinking in parallel ab tuladev
Cross Compiling for Perl Hackers
Propel Your PHP Applications
S4: Distributed Stream Computing Platform
Fed Up Of Framework Hype Dcphp
Get your organization’s feet wet with Semantic Web Technologies
the productive programer: mechanics

Similar to A CMDB Driven by Perl (20)

PPTX
Distributed deep learning_over_spark_20_nov_2014_ver_2.8
PPTX
Essential Data Engineering for Data Scientist
PPTX
Yarn spark next_gen_hadoop_8_jan_2014
ODP
Controller design-pattern-drupal-north-toronto-2018-final
PPTX
What Impact Will Entity Framework Have On Architecture
PPT
Overview Of Parallel Development - Ericnel
PPT
DRESD In a Nutshell July07
PPTX
Distributed Deep Learning + others for Spark Meetup
PDF
50 ways to tweak your wonderfull and magnific paper
PDF
HDR Defence - Software Abstractions for Parallel Architectures
PDF
Tools and Virtualization to Manage our Operations at Puppet Labs - PuppetConf...
PDF
LinuxCon NA 2016: When Containers and Virtualization Do - and Don’t - Work T...
PPT
ADO.NET Entity Framework
PPTX
Optimizing Application Architecture (.NET/Java topics)
PDF
Puppet for SysAdmins
PDF
Spark Based Distributed Deep Learning Framework For Big Data Applications
PDF
May 29, 2014 Toronto Hadoop User Group - Micro ETL
PDF
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
PDF
Beat the devil: towards a Drupal performance benchmark
Distributed deep learning_over_spark_20_nov_2014_ver_2.8
Essential Data Engineering for Data Scientist
Yarn spark next_gen_hadoop_8_jan_2014
Controller design-pattern-drupal-north-toronto-2018-final
What Impact Will Entity Framework Have On Architecture
Overview Of Parallel Development - Ericnel
DRESD In a Nutshell July07
Distributed Deep Learning + others for Spark Meetup
50 ways to tweak your wonderfull and magnific paper
HDR Defence - Software Abstractions for Parallel Architectures
Tools and Virtualization to Manage our Operations at Puppet Labs - PuppetConf...
LinuxCon NA 2016: When Containers and Virtualization Do - and Don’t - Work T...
ADO.NET Entity Framework
Optimizing Application Architecture (.NET/Java topics)
Puppet for SysAdmins
Spark Based Distributed Deep Learning Framework For Big Data Applications
May 29, 2014 Toronto Hadoop User Group - Micro ETL
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
Beat the devil: towards a Drupal performance benchmark
Ad

More from Jens Rehsack (7)

PDF
System Monitoring with Unix::Statgrab and Perl
PDF
Perl6 for-beginners
PDF
Unix::Statgrab
PDF
Moo at System::Image::Update
PDF
PkgSrc in Five Minutes
PDF
Moo at App::Math::Trainer
PDF
Perl on-embedded-devices
System Monitoring with Unix::Statgrab and Perl
Perl6 for-beginners
Unix::Statgrab
Moo at System::Image::Update
PkgSrc in Five Minutes
Moo at App::Math::Trainer
Perl on-embedded-devices
Ad

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PPTX
L1 - Introduction to python Backend.pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Introduction to Artificial Intelligence
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
top salesforce developer skills in 2025.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Nekopoi APK 2025 free lastest update
PPTX
history of c programming in notes for students .pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
System and Network Administration Chapter 2
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Digital Strategies for Manufacturing Companies
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Design an Analysis of Algorithms I-SECS-1021-03
Understanding Forklifts - TECH EHS Solution
L1 - Introduction to python Backend.pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Introduction to Artificial Intelligence
CHAPTER 2 - PM Management and IT Context
How to Choose the Right IT Partner for Your Business in Malaysia
Softaken Excel to vCard Converter Software.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
top salesforce developer skills in 2025.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Nekopoi APK 2025 free lastest update
history of c programming in notes for students .pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
System and Network Administration Chapter 2
Design an Analysis of Algorithms II-SECS-1021-03
Digital Strategies for Manufacturing Companies
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms I-SECS-1021-03

A CMDB Driven by Perl

  • 1. CMDB Driven by Perl Road to a Perl ”driven” Configuration Management Database Jens Rehsack Niederrhein Perl Mongers The Perl Conference in Amsterdam Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 1 / 44
  • 2. Introduction Motivation Motivation Progress Progress isn’t made by early risers. It’s made by lazy men trying to find easier ways to do something. (Robert A. Heinlein) Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 3 / 44
  • 3. Introduction Motivation Motivation Efficiency Business success is because of Perl. It enables us to deliver right solutions in days instead of months. (Elizabeth Mattijsen) Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 4 / 44
  • 4. Introduction Motivation Goal Automation Full flavoured systems management Installation without Administrator interaction Control sensors and alarming Ensured system state by actual-theoretical comparison Faster reaction in emergency cases by organized component moving Have an up-to-date ”Operation Handbook” as well as archiving them Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 5 / 44
  • 5. Beginning Taking over Begin with reporting Begin with reporting In the beginning was the (Installation-)Report Technical Sales defined an XML Document for Change Requests and Status Reports Based on work of forerunner a 70% solution could be delivered Document Definition lacks entity-relations Document Definition misses technolgy requirements ⇒ Appears to be a dead end Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 7 / 44
  • 6. Beginning After reporting From reporting to . . . Mind the goal Alice: Would you tell me, please, which way I ought to go from here? The Cheshire Cat: That depends a good deal on where you want to get to. (Lewis Carroll) Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 8 / 44
  • 7. Beginning Mine Sweeper Where do I begin To write the workflow how great Perl 5 can be The project was in a state where a developer created a particular Report based on the existing snapshot. This solution did not maintain an abstraction layer for gathered data - every time when the report needs an extension, an end-to-end (snapshot to XML-Tag) enhancement had to be created. Changes shall be deployed from the same report format as installations are reported. We have to be able to say at any moment what is operated on the platform. Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 9 / 44
  • 8. Beginning Baby Steps Baby Steps Improve knowledge Based on identified issues the first goal had to be to identify all entities and their relations together Surrounded Problem: The entire platform was completely unstructured Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 10 / 44
  • 9. Beginning Baby Steps Baby Steps Multiple Beginnings The already known ”(Installation-)Report” Platform Snapshot (SCM Repository of selected configuration files) Puppet Classes (without Hiera) mixed with Configuration Items (within Hiera) and prepared configuration files (unsupervised) Hiera is Puppet’s built-in key/value data lookup system. By default, it uses simple YAML or JSON files, although one can extend it to work with almost any data source. Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 11 / 44
  • 10. World Domination Separation Circle in the Sand :platform :snapshot :scan db:cmdb :hiera :report collect scan process-scan yaml-gen puppet run CRQ export Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 13 / 44
  • 11. Concerns Identifying Technical Concerns Rough Collecting platform parameters (to query them in structured way) Identify coherences of Configuration Items (CI) Define a data model Define technical requirements Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 14 / 44
  • 12. Concerns Identifying Practical Concerns Practical Validity of CI’s Limits of our CI’s Data ownership of CI’s Methods to persist CI’s Methods to access CI’s Permission management Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 15 / 44
  • 13. Tuck In! MI:5 Impossible Things Impossible Things Alice laughed. ”There’s no use trying,” she said: ”one can’t believe impossible things.” ”I daresay you haven’t had much practice,” said the Queen. ”When I was your age, I always did it for half-an-hour a day. Why, sometimes I’ve believed as many as six impossible things before breakfast.” (Lewis Carroll) Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 17 / 44
  • 14. Tuck In! Home Improvement The Fool with a Tool Try again So we closed our eyes, took a deep breath (multiple times) and looked around for tools to store serialized data and read in structured way . . . Tool Time MongoDB allows easy storing in any format - but lacks structured querying dedicated entities (configuration items) Data Files delegate relationship handling completely to business logic AnyData2 gotcha - allows reading most confusing stuff and could be queried in structured way Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 18 / 44
  • 15. Tuck In! Home Improvement . . . is still a Fool Volatile Structure Persist structured data using SQLite Define a data model representing existing relations Develop AnyData2::Format classes representing defined ER (Entity Relationship) model Develop simple MOP inside this AnyData2 instance to manage attributes vs. columns Glue everything together using SQL The entire ER model remains a moving target Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 19 / 44
  • 16. Tuck In! Clean Picture Abstraction Layer . . . of configured components Focus the goal to know what is operated Depth first search over all component configuration files Identify relationships (remember: there is no operation model at all) Clean up configuration when no reasonable relationships can be resolved or relationships are conflicting Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 20 / 44
  • 17. Tuck In! Control Moo in practice Moo in practice It appears that the tools helping to do safe IoT device updating are the same tools helping to coordinate CI determining: MooX::Cmd helps separating concerns MooX::ConfigFromFile helps contribute ”divine wisdom” MooX::Options allow overriding ”divine wisdom” by ”individual wisdom” MooX::Log::Any feeds DBIx::LogAny Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 21 / 44
  • 18. Tuck In! Control Moo in background Moo in background Manage database connections based on concerns Manage CI structures based on relations Manage Web-API integration Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 22 / 44
  • 19. Tuck In! Reflecting Relationships Craziness Crazy I’m not crazy. My reality is just different than yours. The Cheshire Cat (Lewis Carroll) Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 23 / 44
  • 20. Tuck In! Reflecting Relationships Harmonization Harmonize Craziness Practically any administrator had a different background regarding to the platform components thus a different picture of their relationships EPIC battles leads to common craziness ER model analysis sessions uncovered holes in picture Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 24 / 44
  • 21. Tuck In! Meanwhile Civilized March Hare: Have some wine. (Alice looked all round the table, but there was nothing on it but tea.) Alice: I don’t see any wine. March Hare: There isn’t any. Alice: Then it wasn’t very civil of you to offer it. March Hare: It wasn’t very civil of you to sit down without being invited. (Lewis Carroll) Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 25 / 44
  • 22. Tuck In! Meanwhile Adding a Goal CentOS 5 ends its maintenance Many of existing tools need to be upgraded Upgraded tools don’t support existing hacks anymore Existing hacks must be replaced by a reasonable configuration structure Same problem like the report format: ◮ neither the ER model of platform components nor issues of platform where known ◮ nor cared about Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 26 / 44
  • 23. Tuck In! Meanwhile Self Protection Delegation We learned from mistakes of past: No responsibility taken for filling weird puppet templates No external data will be managed No precompiled/puzzled resources are prepared ⇒ ER model of CMDB is presented via RESTful API Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 27 / 44
  • 24. Tuck In! Merging Pictures Scan completed Early implementation of above mentioned RESTful API run against ScanDB ScanDB represents just a view of the configuration snapshot There is no future, nor past Time for CMDB to enter the stage Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 28 / 44
  • 25. Tuck In! Future and Past Customers . . . CREATE TABLE customer_t ( customer _id INTEGER PRIMARY KEY -- entity stuff , c ustomer_name VARCHAR (80) UNIQUE NOT NULL -- cmdb stuff , valid _from DATETIME NOT NULL , valid _to DATETIME , modified _at DATETIME NOT NULL , modified _by VARCHAR (32) NOT NULL ); primary key and global identifier for this data type the payload of this data type, automatically indexed CMDB manages history and updates using these columns Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 29 / 44
  • 26. Tuck In! Future and Past VPN links to customers . . . CREATE TABLE vpn_link_t ( vpn_link_id INTEGER PRIMARY KEY -- entity stuff , customer_id INTEGER NOT NULL , v pn_link_type VARCHAR (12) , custom er_net VARCHAR (64) UNIQUE NOT NULL , servic es_net VARCHAR (64) UNIQUE NOT NULL -- cmdb stuff , valid_from DATETIME NOT NULL , valid_to DATETIME , modified_at DATETIME NOT NULL , modified_by VARCHAR (32) NOT NULL -- FK , FOREIGN KEY ( customer_id ) REFERENCES customer_t( customer_id ) ON UPDATE CASCADE ON DELETE CASCADE ); refer the customer support Cisco, Juniper, Paolo Alto, . . . networks must be unique or network admins kill you Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 30 / 44
  • 27. Tuck In! Future and Past Moo Interception package Foo:: Role :: Database :: CMDB; use Moo:: Role; requires "log"; has cmdb => ( is => "ro", required => 1, handles => "Foo:: Role :: Database", isa => sub { _INSTANCE_OF($_[0], "Foo:: Helper :: CMDB") and $_[0]-> DOES("Foo:: Role :: Dat and return; die " Insufficient initialisation parameter for cmdb"; }, coerce => sub { _HASH($_ [0]) and return Foo :: Helper ::CMDB ->new (%{$_ [0]}); $_ [0]; }, ); role can be consumed by any class needing access to CMDB transform hash initializer into object Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 31 / 44
  • 28. Tuck In! Future and Past Hard work package Foo:: Helper :: CMDB; use Moo; extends "Foo:: Helper :: DatabaseClass "; has config _tables => (is => "lazy", ...); has history_tabl es => (is => "lazy", ...); around deploy => sub { ... my @tables = @{$self -> config_tables }; foreach my $tbl (@tables) { my @h ist_coldefs = map { my $default = defined $_ - >[4] ? " DEFAULT $_ - >[4]" : ""; $pure_cols{$_ - >[1]} ? ("$_ - >[1] $_ - >[2] $default") : ("old_$_ - >[1] $_ - >[2] $default", "new_$_ - >[1] $_ - >[2] $default") } @table_info ; } unshift @hist_coldefs , "${base_name}_hist_id INTEGER PRIMARY KEY"; my $hist_defs = join("n , ", @hist_coldefs ); my $hist_tbl = <<EOCHT; CREATE TABLE ${base_name}_hist ( ${hist_defs} ); EOCHT that are all tables with trailing t in their names create history table for each config table memoizing old and new values on updating payload Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 32 / 44
  • 29. Tuck In! Future and Past Hard work (continued) - INSERT my $new_cols = join(", ", map { $pure_cols{$_} ? $_ : "new_$_" } grep { !$skipped{$_} } @table_cols ); my $new_vals = join(", ", map {"NEW.$_"} grep { !$skipped{$_} } @table_cols ); my $new_trgr = <<EONT; CREATE TRIGGER new_${base_name}_row AFTER INSERT ON ${base_name}_t BEGIN INSERT INTO ${base_name}_hist ($new_cols) VALUES ($new_vals ); END; EONT ⇒ ON INSERT fill history rows without filling ”OLD ” columns Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 33 / 44
  • 30. Tuck In! Future and Past Hard work (continued) - UPDATE my (@updt_cols , @rfrs_cond , @updt_vals ); foreach my $colnm (grep { !$skipped{$_} } @table_cols ) { my @lcd = $pure_cols{$colnm} ? $colnm : ("old_${colnm}", "new_${colnm}"); push @updt_cols , @lcd; push @rfrs_cond , $pure_cols{$colnm} ? _cmp_if_nullable ("existing.${colnm}", "NEW.${colnm}") : ( _cmp_if_nullable ("existing.old_${colnm}", "OLD.${colnm}"), _cmp_if_nullable ("existing.new_${colnm}", "NEW.${colnm}")); push @updt_vals , $pure_cols{$colnm }?("NEW.$colnm"):("OLD.$colnm","NEW.$colnm") } my $updt_cols = join(", ", @updt_cols ); my $updt_refreshed_cols = join(", ", map { "refreshed.$_" } @updt_cols ); my $updt_vals = join(", ", @updt_vals ); ⇒ Prepare for a bit complexer trigger ⇒ Distinguish between real updates and just ”touches” Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 34 / 44
  • 31. Tuck In! Future and Past Hard work (continued) - UPDATE my $updt_trgr = <<EONT; CREATE TRIGGER updt_${base_name}_row AFTER UPDATE ON ${base_name}_t BEGIN INSERT OR REPLACE INTO ${base_name}_hist (${base_name}_hist_id , $updt_cols) VALUES ( (SELECT MAX(existing.${base_name}_hist_id) ${base_name}_hist_id FROM ${base_name}_hist existing WHERE $updt_refreshed_cond ), $updt_vals ); END; EONT ⇒ ON UPDATE create history (INSERT) rows with ”OLD ” and ”NEW ” columns except nothing changes (REPLACE) Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 35 / 44
  • 32. Tuck In! Features ”UPSERT” MERGE INTO tablename USING table_reference ON (condition) WHEN MATCHED THEN UPDATE SET column1 = value1 [, column2 = value2 ...] WHEN NOT MATCHED THEN INSERT (column1 [, column2 ...]) VALUES (value1 [, value2 ...]); SQLite Unsupported by SQLite INSERT OR REPLACE deletes before insert → Kills UPDATE Trigger Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 36 / 44
  • 33. Tuck In! Features Perl helps out $self ->cmdb ->upsert( customer_t => { customer_name => "Foo Enterprises ", }); $self ->cmdb ->upsert( vpn_link_t => { customer_name => "Foo Enterprises ", vpn_link_type => "Juniper", customer_net => " 10.116.47.8/29", services_net => " 10.126.47.8/29" } ); SQL created . . . INSERT OR IGNORE INTO vpn_link_t ( customer_id , vpn_link_type , customer_net , services_net , modified_by ) VALUES ( (SELECT customer_id FROM customer_t WHERE customer_name =?), ?, ?, ?, ?); UPDATE vpn_link_t SET vpn_link_type =?, customer_net =?, services_net =?, modified_by =?, touched_at= CURRENT_TIMESTAMP WHERE changes ()=0 AND customer_id =( SELECT customer_id FROM customer_t WHERE customer_name =?); Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 37 / 44
  • 34. Tuck In! Features Known limitations Restricted to CMDB Refuse updates of identifying columns (UNIQUE constraints) WHERE clause derived from UNIQUE constraints Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 38 / 44
  • 35. Tuck In! Meanwhile II CMDB to Hiera YAML Generator Development team read via RESTful API the theoretical configuration set Hiera YAML files are written Additional exports are managed via Hiera Puppet classes are rewritten to understand new ER model Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 39 / 44
  • 36. Goals reached Circle closed Circle closed :platform :snapshot :scan db:cmdb :hiera :report collect scan process-scan yaml-gen puppet run CRQ export scan process-scan yaml-gen CRQ Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 41 / 44
  • 37. Goals reached Circle closed Goals reached → Actual-theoretical comparison done via processing scan database → Unmaintainted installation via cronjob possible → Reaction in emergency cases by organized component moving done multiple times → Monitoring, sensors, alarming open Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 42 / 44
  • 38. Conclusion Conclusion Can a programming language save a life Yes, it can - but here it saves our business Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 43 / 44
  • 39. Thank you Thank you Thank You For Listening Questions? Jens Rehsack <rehsack@cpan.org> Cologne Jens Rehsack (Niederrhein.PM) CMDB Driven by Perl The Perl Conference in Amsterdam 44 / 44