SlideShare a Scribd company logo
1 of 33
Configuration management
Why? What? How?
Why?
● example:
○ imagine that we want to prevent root
logins on 100 nodes
Why?
● example:
○ imagine that we want to prevent root
logins on 100 nodes
○ we want to set PermitRootLogin option
in sshd_config to "no"
Why?
● example:
○ imagine that we want to prevent root
logins on 100 nodes
○ we want to set PermitRootLogin option
in sshd_config to "no"
○ we have to execute this command on
every node:
echo "PermitRootLogin no" >>
/etc/ssh/sshd_config
for node in node{1..100};do ssh
root@$node "echo "PermitRootLogin
no" >> /etc/ssh/sshd_config"
;done
● bug: string will be appended
every time we run this for cycle
○ no problem, we gonna fix it
for node in node{1..100};do ssh
root@$node "(grep -iq
'PermitRootLogin'
/etc/ssh/sshd_config || echo "
PermitRootLogin no" >>
/etc/ssh/sshd_config) && sed -i
's/^.*PermitRootLogin.
*$/PermitRootLogin no/;'
/etc/sshd_config"
;done
● it's complicated, i'll put it
into script
What if?
● option is already set to "no"
What if?
● option is already set to "no"
● option is commented out
What if?
● option is already set to "no"
● option is commented out
● sshd_config does not exist on
specified path
What if?
● option is already set to "no"
● option is commented out
● sshd_config does not exist on
specified path
● sshd is not installed at all
What if?
● option is already set to "no"
● option is commented out
● sshd_config does not exist on
specified path
● sshd is not installed at all
● operation fails on node 2,4,9,31
and 83 (wrong permissions?)
What if?
● option is already set to "no"
● option is commented out
● sshd_config does not exist on
specified path
● sshd is not installed at all
● operation fails on node 2,4,9,31
and 83 (wrong permissions?)
● node 70 and 71 is openindiana
What if?
● option is already set to "no"
● option is commented out
● sshd_config does not exist on
specified path
● sshd is not installed at all
● operation fails on node 2,4,9,31
and 83 (wrong permissions?)
● node 70 and 71 is openindiana
● sshd fails to restart on node
19,21
What if?
● option is already set to "no"
● option is commented out
● sshd_config does not exist on
specified path
● sshd is not installed at all
● operation fails on node 2,4,9,31
and 83 (wrong permissions?)
● node 70 and 71 is openindiana
● sshd fails to restart on node
19,21
● node 13 is in maintenance
Script
● would be too complicated
○ different operation systems and flavors
○ handling all situations
● can't handle offline nodes
● hard to maintain
● hard to use
● human error is inevitable
complex processeses or orchestration through
the for cycle is
NO GO
What is configuration management
good for ?
● can handle a lot of details
● handling deviation from defined configuration
○ accidentally removed packages,files,configuration by
hand...
○ would return system to original state
● infrastructure configuration as a code
○ code is repeatable
○ using VCS (git,svn,hg,...) you may create
environment for change management
● change deployment
○ in controled manner
● automatic server deployment
○ new server is deployed using existing code
"I don't need to use it"
● do it, you won't regret it
○ even on your computer alone
○ or with few servers
How?
● there are a lot of tools available:
○ Puppet
○ Chef
○ Bcfg2
○ CFEngine3
○ Salt
○ Ansible
○ ...and others
● choose the right tool for your needs
CFEngine 3
Tomas Corej
@tomas_corej
History of CM tools
src: http://bit.ly/acuidi
CFEngine
● developed in 1993 by @markburgess_osl
○ also created whole field
● CFEngine 1
○ domain-specific language
● CFEngine 2 (1998)
○ idea of convergence
■ tool discover state of system
● CFEngine 3 (2009)
○ complete rewrite
○ based on Promise Theory developed by Mark
Burgess
CFEngine 3
● written in C
● strong theoretical background
○ it should be same for years
● cross platform
○ Linux,*BSD,Solaris,Windows....
○ from Rasberry Pi to big IT deployments (Facebook)
● small footprint
○ small cpu usage - http://bit.ly/QJcrg8
● very scalable
○ can handle hundreds of thousands servers
○ policy hierarchy
● zero reported vulnerabilities
CFEngine 3 design principles
● desired-state configuration
○ declarative policy language
○ you only specify your desired final state of system
○ CFEngine will handle everything else automatically
○ but if operation is not native, you have to tell
CFEngine "how"
● promise theory
○ models behaviour of agents in an environment
without central authority
○ voluntary cooperation
● convergent configuration
○ you don't need know current state of system
○ convergence in incremental steps
Architecture
src: cfengine.com
Architecture
● no clear distinction between agent (client)
and policy hub (server)
● every agent can be policy hub for another
set of agents
● agents updates policy files from hub
○ if policy hub is unreachable => policy files are not
updated
○ every 5 minutes
○ no other mechanism to tell agents what to do
Show me the code!
bundle agent sshd_norootlogin
{
files:
"/etc/ssh/sshd_config"
edit_line =>
replace_or_add(".*PermitRootLogin.*",
"PermitRootLogin no");
}
Code
● covers many situations:
○ commented option
○ non-exist option
○ option set to other value than "no"
● how to handle various environments ?
○ using context
○ they're known also as the classes but their meaning
is not the same as in OOP
Context
● as a conditionals to handle different
environments or state
○ does a file exist ? is pkg installed ? yes/no
○ is this system debian,ubuntu or windows?
○ is this system with hostname matching web* ?
● hard classes
○ discovered by cfengine
○ hostname, ip addresses, interfaces...
● soft classes
○ classes defined during runtime
code++
bundle agent sshd_norootlogin
{
vars:
debian::
"sshdconf" string => "/etc/ssh/sshd_config";
!debian::
"sshdconf" string => "/usr/local/etc/ssh/sshd_config";
files:
"$(sshdconf)"
edit_line =>
replace_or_add(".*PermitRootLogin.*",
"PermitRootLogin no");
}
Who am I and why CFEngine
● sysadmin @ Websupport.sk
● the biggest webhosting provider in Slovakia
● tens thousands of services (domains,vps,
hostings)
● we're going to move all of them to new
hardware infrastructure in few months
● we choosed CFEngine3 because of it
features:
The features that works for us
● strong theoretical background
○ where will be Puppet and Chef when hype ends ?
● small CPU and memory overhead
● scalability
○ we may need to handle 1000-2000 virtual servers
● model based monitoring http://bit.ly/Vle8zc
○ CFEngine can be used as a monitoring tool or as a
addon to other monitoring tool
○ monitoring is self-learning => no need to setup
anything
○ learns state of system for past 7 days
○ if metric value is larger than standard deviation =>
something unusual is happening
Features that works for us
● knowledge maps
○ you may generate logical maps of subsystems from
code
● is not written in ruby :)
○ we have strong experience with C
Questions ?

More Related Content

What's hot

Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
Sagiv Ofek
 
Puppet Camp Boston 2014: Securely Managing Secrets with FreeIPA and Puppet (I...
Puppet Camp Boston 2014: Securely Managing Secrets with FreeIPA and Puppet (I...Puppet Camp Boston 2014: Securely Managing Secrets with FreeIPA and Puppet (I...
Puppet Camp Boston 2014: Securely Managing Secrets with FreeIPA and Puppet (I...
Puppet
 

What's hot (19)

Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
 
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and VarnishMagento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
 
Linux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filterLinux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filter
 
Puppet User Group Presentation - 15 March 2012
Puppet User Group Presentation - 15 March 2012Puppet User Group Presentation - 15 March 2012
Puppet User Group Presentation - 15 March 2012
 
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
 
Thread safety
Thread safetyThread safety
Thread safety
 
Grand Central Dispatch in Objective-C
Grand Central Dispatch in Objective-CGrand Central Dispatch in Objective-C
Grand Central Dispatch in Objective-C
 
Virtual domains
Virtual domainsVirtual domains
Virtual domains
 
What is new in Go 1.8
What is new in Go 1.8What is new in Go 1.8
What is new in Go 1.8
 
Linux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regxLinux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regx
 
Building a network emulator with Docker and Open vSwitch
Building a network emulator with Docker and Open vSwitchBuilding a network emulator with Docker and Open vSwitch
Building a network emulator with Docker and Open vSwitch
 
OlinData Puppet Presentation for MOSC 2012
OlinData Puppet Presentation for MOSC 2012OlinData Puppet Presentation for MOSC 2012
OlinData Puppet Presentation for MOSC 2012
 
Puppet Camp Boston 2014: Securely Managing Secrets with FreeIPA and Puppet (I...
Puppet Camp Boston 2014: Securely Managing Secrets with FreeIPA and Puppet (I...Puppet Camp Boston 2014: Securely Managing Secrets with FreeIPA and Puppet (I...
Puppet Camp Boston 2014: Securely Managing Secrets with FreeIPA and Puppet (I...
 
Ssh cookbook
Ssh cookbookSsh cookbook
Ssh cookbook
 
Don’t block the event loop!
Don’t block the event loop!Don’t block the event loop!
Don’t block the event loop!
 
Introduction of unit test on android kernel
Introduction of unit test on android kernelIntroduction of unit test on android kernel
Introduction of unit test on android kernel
 
ssh
sshssh
ssh
 
Linux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell scriptLinux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell script
 

Similar to Tomáš Čorej: Configuration management & CFEngine3

Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Docker, Inc.
 
A3Sec Advanced Deployment System
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment System
a3sec
 
Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9 Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9
Jérôme Petazzoni
 
Introduction to Docker and Containers
Introduction to Docker and ContainersIntroduction to Docker and Containers
Introduction to Docker and Containers
Docker, Inc.
 

Similar to Tomáš Čorej: Configuration management & CFEngine3 (20)

Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
 
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo..."Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
 
A3Sec Advanced Deployment System
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment System
 
Introduction to Docker (as presented at December 2013 Global Hackathon)
Introduction to Docker (as presented at December 2013 Global Hackathon)Introduction to Docker (as presented at December 2013 Global Hackathon)
Introduction to Docker (as presented at December 2013 Global Hackathon)
 
Adhocr T-dose 2012
Adhocr T-dose 2012Adhocr T-dose 2012
Adhocr T-dose 2012
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
Tips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyTips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development Efficiency
 
Docker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQ
Docker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQDocker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQ
Docker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQ
 
Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9 Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9
 
Introduction to Docker and Containers
Introduction to Docker and ContainersIntroduction to Docker and Containers
Introduction to Docker and Containers
 
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin PiebiakWorkflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
 
Workflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesWorkflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large Enterprises
 
Linux 开源操作系统发展新趋势
Linux 开源操作系统发展新趋势Linux 开源操作系统发展新趋势
Linux 开源操作系统发展新趋势
 
We shall play a game....
We shall play a game....We shall play a game....
We shall play a game....
 
0507 057 01 98 * Adana Klima Servisleri
0507 057 01 98 * Adana Klima Servisleri0507 057 01 98 * Adana Klima Servisleri
0507 057 01 98 * Adana Klima Servisleri
 
Shall we play a game
Shall we play a gameShall we play a game
Shall we play a game
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
 
Designate Install and Operate Workshop
Designate Install and Operate WorkshopDesignate Install and Operate Workshop
Designate Install and Operate Workshop
 
Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compact
 

More from Jano Suchal

Rank all the (geo) things!
Rank all the (geo) things!Rank all the (geo) things!
Rank all the (geo) things!
Jano Suchal
 
Ako si vybrať programovácí jazyk alebo framework?
Ako si vybrať programovácí jazyk alebo framework?Ako si vybrať programovácí jazyk alebo framework?
Ako si vybrať programovácí jazyk alebo framework?
Jano Suchal
 
Bonetics: Mastering Puppet Workshop
Bonetics: Mastering Puppet WorkshopBonetics: Mastering Puppet Workshop
Bonetics: Mastering Puppet Workshop
Jano Suchal
 
Ako si vybrať programovací jazyk a framework?
Ako si vybrať programovací jazyk a framework?Ako si vybrať programovací jazyk a framework?
Ako si vybrať programovací jazyk a framework?
Jano Suchal
 
Garelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringGarelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoring
Jano Suchal
 
Vojtech Rinik: Internship v USA - moje skúsenosti
Vojtech Rinik: Internship v USA - moje skúsenostiVojtech Rinik: Internship v USA - moje skúsenosti
Vojtech Rinik: Internship v USA - moje skúsenosti
Jano Suchal
 
Profiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applicationsProfiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applications
Jano Suchal
 
Aký programovací jazyk a framework si vybrať a prečo?
Aký programovací jazyk a framework si vybrať a prečo?Aký programovací jazyk a framework si vybrať a prečo?
Aký programovací jazyk a framework si vybrať a prečo?
Jano Suchal
 
Petr Joachim: Redis na Super.cz
Petr Joachim: Redis na Super.czPetr Joachim: Redis na Super.cz
Petr Joachim: Redis na Super.cz
Jano Suchal
 
Metaprogramovanie #1
Metaprogramovanie #1Metaprogramovanie #1
Metaprogramovanie #1
Jano Suchal
 

More from Jano Suchal (20)

Slovensko.Digital: Čo ďalej?
Slovensko.Digital: Čo ďalej?Slovensko.Digital: Čo ďalej?
Slovensko.Digital: Čo ďalej?
 
Datanest 3.0
Datanest 3.0Datanest 3.0
Datanest 3.0
 
Improving code quality
Improving code qualityImproving code quality
Improving code quality
 
Beyond search queries
Beyond search queriesBeyond search queries
Beyond search queries
 
Rank all the things!
Rank all the things!Rank all the things!
Rank all the things!
 
Rank all the (geo) things!
Rank all the (geo) things!Rank all the (geo) things!
Rank all the (geo) things!
 
Ako si vybrať programovácí jazyk alebo framework?
Ako si vybrať programovácí jazyk alebo framework?Ako si vybrať programovácí jazyk alebo framework?
Ako si vybrať programovácí jazyk alebo framework?
 
Bonetics: Mastering Puppet Workshop
Bonetics: Mastering Puppet WorkshopBonetics: Mastering Puppet Workshop
Bonetics: Mastering Puppet Workshop
 
Peter Mihalik: Puppet
Peter Mihalik: PuppetPeter Mihalik: Puppet
Peter Mihalik: Puppet
 
Ako si vybrať programovací jazyk a framework?
Ako si vybrať programovací jazyk a framework?Ako si vybrať programovací jazyk a framework?
Ako si vybrať programovací jazyk a framework?
 
SQL: Query optimization in practice
SQL: Query optimization in practiceSQL: Query optimization in practice
SQL: Query optimization in practice
 
Garelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringGarelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoring
 
Miroslav Šimulčík: Temporálne databázy
Miroslav Šimulčík: Temporálne databázyMiroslav Šimulčík: Temporálne databázy
Miroslav Šimulčík: Temporálne databázy
 
Vojtech Rinik: Internship v USA - moje skúsenosti
Vojtech Rinik: Internship v USA - moje skúsenostiVojtech Rinik: Internship v USA - moje skúsenosti
Vojtech Rinik: Internship v USA - moje skúsenosti
 
Profiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applicationsProfiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applications
 
Aký programovací jazyk a framework si vybrať a prečo?
Aký programovací jazyk a framework si vybrať a prečo?Aký programovací jazyk a framework si vybrať a prečo?
Aký programovací jazyk a framework si vybrať a prečo?
 
Čo po GAMČI?
Čo po GAMČI?Čo po GAMČI?
Čo po GAMČI?
 
Petr Joachim: Redis na Super.cz
Petr Joachim: Redis na Super.czPetr Joachim: Redis na Super.cz
Petr Joachim: Redis na Super.cz
 
Metaprogramovanie #1
Metaprogramovanie #1Metaprogramovanie #1
Metaprogramovanie #1
 
PostgreSQL: Advanced features in practice
PostgreSQL: Advanced features in practicePostgreSQL: Advanced features in practice
PostgreSQL: Advanced features in practice
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Tomáš Čorej: Configuration management & CFEngine3

  • 2. Why? ● example: ○ imagine that we want to prevent root logins on 100 nodes
  • 3. Why? ● example: ○ imagine that we want to prevent root logins on 100 nodes ○ we want to set PermitRootLogin option in sshd_config to "no"
  • 4. Why? ● example: ○ imagine that we want to prevent root logins on 100 nodes ○ we want to set PermitRootLogin option in sshd_config to "no" ○ we have to execute this command on every node: echo "PermitRootLogin no" >> /etc/ssh/sshd_config
  • 5. for node in node{1..100};do ssh root@$node "echo "PermitRootLogin no" >> /etc/ssh/sshd_config" ;done ● bug: string will be appended every time we run this for cycle ○ no problem, we gonna fix it
  • 6. for node in node{1..100};do ssh root@$node "(grep -iq 'PermitRootLogin' /etc/ssh/sshd_config || echo " PermitRootLogin no" >> /etc/ssh/sshd_config) && sed -i 's/^.*PermitRootLogin. *$/PermitRootLogin no/;' /etc/sshd_config" ;done ● it's complicated, i'll put it into script
  • 7. What if? ● option is already set to "no"
  • 8. What if? ● option is already set to "no" ● option is commented out
  • 9. What if? ● option is already set to "no" ● option is commented out ● sshd_config does not exist on specified path
  • 10. What if? ● option is already set to "no" ● option is commented out ● sshd_config does not exist on specified path ● sshd is not installed at all
  • 11. What if? ● option is already set to "no" ● option is commented out ● sshd_config does not exist on specified path ● sshd is not installed at all ● operation fails on node 2,4,9,31 and 83 (wrong permissions?)
  • 12. What if? ● option is already set to "no" ● option is commented out ● sshd_config does not exist on specified path ● sshd is not installed at all ● operation fails on node 2,4,9,31 and 83 (wrong permissions?) ● node 70 and 71 is openindiana
  • 13. What if? ● option is already set to "no" ● option is commented out ● sshd_config does not exist on specified path ● sshd is not installed at all ● operation fails on node 2,4,9,31 and 83 (wrong permissions?) ● node 70 and 71 is openindiana ● sshd fails to restart on node 19,21
  • 14. What if? ● option is already set to "no" ● option is commented out ● sshd_config does not exist on specified path ● sshd is not installed at all ● operation fails on node 2,4,9,31 and 83 (wrong permissions?) ● node 70 and 71 is openindiana ● sshd fails to restart on node 19,21 ● node 13 is in maintenance
  • 15. Script ● would be too complicated ○ different operation systems and flavors ○ handling all situations ● can't handle offline nodes ● hard to maintain ● hard to use ● human error is inevitable complex processeses or orchestration through the for cycle is NO GO
  • 16. What is configuration management good for ? ● can handle a lot of details ● handling deviation from defined configuration ○ accidentally removed packages,files,configuration by hand... ○ would return system to original state ● infrastructure configuration as a code ○ code is repeatable ○ using VCS (git,svn,hg,...) you may create environment for change management ● change deployment ○ in controled manner ● automatic server deployment ○ new server is deployed using existing code
  • 17. "I don't need to use it" ● do it, you won't regret it ○ even on your computer alone ○ or with few servers
  • 18. How? ● there are a lot of tools available: ○ Puppet ○ Chef ○ Bcfg2 ○ CFEngine3 ○ Salt ○ Ansible ○ ...and others ● choose the right tool for your needs
  • 20. History of CM tools src: http://bit.ly/acuidi
  • 21. CFEngine ● developed in 1993 by @markburgess_osl ○ also created whole field ● CFEngine 1 ○ domain-specific language ● CFEngine 2 (1998) ○ idea of convergence ■ tool discover state of system ● CFEngine 3 (2009) ○ complete rewrite ○ based on Promise Theory developed by Mark Burgess
  • 22. CFEngine 3 ● written in C ● strong theoretical background ○ it should be same for years ● cross platform ○ Linux,*BSD,Solaris,Windows.... ○ from Rasberry Pi to big IT deployments (Facebook) ● small footprint ○ small cpu usage - http://bit.ly/QJcrg8 ● very scalable ○ can handle hundreds of thousands servers ○ policy hierarchy ● zero reported vulnerabilities
  • 23. CFEngine 3 design principles ● desired-state configuration ○ declarative policy language ○ you only specify your desired final state of system ○ CFEngine will handle everything else automatically ○ but if operation is not native, you have to tell CFEngine "how" ● promise theory ○ models behaviour of agents in an environment without central authority ○ voluntary cooperation ● convergent configuration ○ you don't need know current state of system ○ convergence in incremental steps
  • 25. Architecture ● no clear distinction between agent (client) and policy hub (server) ● every agent can be policy hub for another set of agents ● agents updates policy files from hub ○ if policy hub is unreachable => policy files are not updated ○ every 5 minutes ○ no other mechanism to tell agents what to do
  • 26. Show me the code! bundle agent sshd_norootlogin { files: "/etc/ssh/sshd_config" edit_line => replace_or_add(".*PermitRootLogin.*", "PermitRootLogin no"); }
  • 27. Code ● covers many situations: ○ commented option ○ non-exist option ○ option set to other value than "no" ● how to handle various environments ? ○ using context ○ they're known also as the classes but their meaning is not the same as in OOP
  • 28. Context ● as a conditionals to handle different environments or state ○ does a file exist ? is pkg installed ? yes/no ○ is this system debian,ubuntu or windows? ○ is this system with hostname matching web* ? ● hard classes ○ discovered by cfengine ○ hostname, ip addresses, interfaces... ● soft classes ○ classes defined during runtime
  • 29. code++ bundle agent sshd_norootlogin { vars: debian:: "sshdconf" string => "/etc/ssh/sshd_config"; !debian:: "sshdconf" string => "/usr/local/etc/ssh/sshd_config"; files: "$(sshdconf)" edit_line => replace_or_add(".*PermitRootLogin.*", "PermitRootLogin no"); }
  • 30. Who am I and why CFEngine ● sysadmin @ Websupport.sk ● the biggest webhosting provider in Slovakia ● tens thousands of services (domains,vps, hostings) ● we're going to move all of them to new hardware infrastructure in few months ● we choosed CFEngine3 because of it features:
  • 31. The features that works for us ● strong theoretical background ○ where will be Puppet and Chef when hype ends ? ● small CPU and memory overhead ● scalability ○ we may need to handle 1000-2000 virtual servers ● model based monitoring http://bit.ly/Vle8zc ○ CFEngine can be used as a monitoring tool or as a addon to other monitoring tool ○ monitoring is self-learning => no need to setup anything ○ learns state of system for past 7 days ○ if metric value is larger than standard deviation => something unusual is happening
  • 32. Features that works for us ● knowledge maps ○ you may generate logical maps of subsystems from code ● is not written in ruby :) ○ we have strong experience with C