Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Does your configuration code smell?
Search
DevOps Pro
June 01, 2016
Technology
0
77
Does your configuration code smell?
by Tushar Sharma
DevOps Pro Vilnius 2016
DevOps Pro
June 01, 2016
Tweet
Share
More Decks by DevOps Pro
See All by DevOps Pro
Practical Application Logging and Monitoring
devopspro
0
110
Google Cloud Platform for DevOps Professionals
devopspro
0
290
Dev vs Ops transformation to Agility DevOps culture
devopspro
1
240
Using Test Automation for Continuous Integration, Delivery and Quality
devopspro
0
96
How the hell do I run my microservices in production, and will it scale?
devopspro
0
130
Accelerating innovation through AWS Cloud technology
devopspro
0
89
The Field Guide to Understanding Declarative Systems
devopspro
0
83
How we learned to love the Data Center Operating System
devopspro
0
200
DevOps is the answer! What was the question again?
devopspro
0
160
Other Decks in Technology
See All in Technology
ロールが細分化された組織でSREは何をするか?
tgidgd
1
160
AIの全社活用を推進するための安全なレールを敷いた話
shoheimitani
2
610
VS CodeとGitHub Copilotで爆速開発!アップデートの波に乗るおさらい会 / Rapid Development with VS Code and GitHub Copilot: Catch the Latest Wave
yamachu
2
300
クラウド開発の舞台裏とSRE文化の醸成 / SRE NEXT 2025 Lunch Session
kazeburo
1
400
オフィスビルを監視しよう:フィジカル×デジタルにまたがるSLI/SLO設計と運用の難しさ / Monitoring Office Buildings: The Challenge of Physical-Digital SLI/SLO Design & Operation
bitkey
1
290
マルチプロダクト環境におけるSREの役割 / SRE NEXT 2025 lunch session
sugamasao
1
220
CDK Vibe Coding Fes
tomoki10
1
450
SREのためのeBPF活用ステップアップガイド
egmc
1
780
CDKコード品質UP!ナイスな自作コンストラクタを作るための便利インターフェース
harukasakihara
2
160
事例で学ぶ!B2B SaaSにおけるSREの実践例/SRE for B2B SaaS: A Real-World Case Study
bitkey
1
270
全部AI、全員Cursor、ドキュメント駆動開発 〜DevinやGeminiも添えて〜
rinchsan
0
280
SREの次のキャリアの道しるべ 〜SREがマネジメントレイヤーに挑戦して、 気づいたこととTips〜
coconala_engineer
1
590
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
223
9.7k
GraphQLとの向き合い方2022年版
quramy
49
14k
Agile that works and the tools we love
rasmusluckow
329
21k
Code Reviewing Like a Champion
maltzj
524
40k
Done Done
chrislema
184
16k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
For a Future-Friendly Web
brad_frost
179
9.8k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
We Have a Design System, Now What?
morganepeng
53
7.7k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Transcript
Does Your Configuration Code Smell? Tushar Sharma
“Smells” Code Smell …certain structures in the code that suggest
(sometimes they scream for) the possibility of refactoring.
None
“Smells” Design Smells “Design smells are certain structures in the
design that indicate violation of fundamental design principles and negatively impact design quality.”
“Smells” Configuration Smells
“Infrastructure as Code” (IaC)
Puppet example package { 'apache2': require => Exec['apt-update'], ensure =>
installed, } service { 'apache2': ensure => running, } user { 'tushar': ensure => present, uid => '1000', gid => '1000', shell => '/bin/bash', home => '/home/tushar' } Configuration management tools: Ansible, Chef, CFEngine, Puppet
Software System IaC and Traditional SE Production code Infrastructure, configuration
code, tools and services Apply traditional software engineering practices
Configuration smells “Configuration smells are the characteristics of a configuration
program or script that violate the recommended best practices and potentially affect the program’s quality in a negative way.”
Implementation configuration smells
Implementation configuration smells import 'classes/*' # TODO: fix deprecated statement
class app-studio (String $version = ‘latest') { $primary_config_file = 'config' $source_config = 'config.source' if $version == ’44’ or $version == ‘4.2’ or $version != ‘4.5’ or $version == ‘4.9’{ case $::operatingsystem { 'debian': { apt::source { 'packages.dotdeb.org-repo.app': location => 'http://repo.app.com/dotdeb/', release => $::lsbdistcodename, repos => 'all', include_src => true include_src => true } } Deprecated Statement Usage
Implementation configuration smells import 'classes/*' # TODO: fix deprecated statement
class app-studio (String $version = ‘latest') { $primary_config_file = 'config' $source_config = 'config.source' if $version == ’44’ or $version == ‘4.2’ or $version != ‘4.5’ or $version == ‘4.9’{ case $::operatingsystem { 'debian': { apt::source { 'packages.dotdeb.org-repo.app': location => 'http://repo.app.com/dotdeb/', release => $::lsbdistcodename, repos => 'all', include_src => true include_src => true } } Incomplete Task
Implementation configuration smells import 'classes/*' # TODO: fix deprecated statement
class app-studio (String $version = ‘latest') { $primary_config_file = 'config' $source_config = 'config.source' if $version == ’44’ or $version == ‘4.2’ or $version != ‘4.5’ or $version == ‘4.9’{ case $::operatingsystem { 'debian': { apt::source { 'packages.dotdeb.org-repo.app': location => 'http://repo.app.com/dotdeb/', release => $::lsbdistcodename, repos => 'all', include_src => true include_src => true } } Long Statement Complex Expression
Implementation configuration smells import 'classes/*' # TODO: fix deprecated statement
class app-studio (String $version = ‘latest') { $primary_config_file = 'config' $source_config = 'config.source' if $version == ’44’ or $version == ‘4.2’ or $version != ‘4.5’ or $version == ‘4.9’{ case $::operatingsystem { 'debian': { apt::source { 'packages.dotdeb.org-repo.app': location => 'http://repo.app.com/dotdeb/', release => $::lsbdistcodename, repos => 'all', include_src => true include_src => true } } Missing Default Case
Implementation configuration smells import 'classes/*' # TODO: fix deprecated statement
class app-studio (String $version = ‘latest') { $primary_config_file = 'config' $source_config = 'config.source' if $version == ’44’ or $version == ‘4.2’ or $version != ‘4.5’ or $version == ‘4.9’{ case $::operatingsystem { 'debian': { apt::source { 'packages.dotdeb.org-repo.app': location => 'http://repo.app.com/dotdeb/', release => $::lsbdistcodename, repos => 'all', include_src => true include_src => true } } Duplicate Entity
Implementation configuration smells elsif $version in ['33', '3.3'] { }
if $::kernelversion =~ /^(2.2)/ { $appversion = '3.5' } elsif $::kernelversion =~ /^(2.1)/ { exec {"download_app_studio": command => "wget $url", timeout => 0, } } $version = '3.4' ? {undef => $primary_config_file, default => $source_config} file { "/root/.app": mode => '644', ensure => present } } Missing Conditional
Implementation configuration smells elsif $version in ['33', '3.3'] { }
if $::kernelversion =~ /^(2.2)/ { $appversion = '3.5' } elsif $::kernelversion =~ /^(2.1)/ { exec {"download_app_studio": command => "wget $url", timeout => 0, } } $version = '3.4' ? {undef => $primary_config_file, default => $source_config} file { "/root/.app": mode => '644', ensure => present } } Improper Quote Usage
Implementation configuration smells elsif $version in ['33', '3.3'] { }
if $::kernelversion =~ /^(2.2)/ { $appversion = '3.5' } elsif $::kernelversion =~ /^(2.1)/ { exec {"download_app_studio": command => "wget $url", timeout => 0, } } $version = '3.4' ? {undef => $primary_config_file, default => $source_config} file { "/root/.app": mode => '644', ensure => present } } Unguarded Variable
Implementation configuration smells elsif $version in ['33', '3.3'] { }
if $::kernelversion =~ /^(2.2)/ { $appversion = '3.5' } elsif $::kernelversion =~ /^(2.1)/ { exec {"download_app_studio": command => "wget $url", timeout => 0, } } $version = '3.4' ? {undef => $primary_config_file, default => $source_config} file { "/root/.app": mode => '644', ensure => present } } Improper Alignment
Implementation configuration smells elsif $version in ['33', '3.3'] { }
if $::kernelversion =~ /^(2.2)/ { $appversion = '3.5' } elsif $::kernelversion =~ /^(2.1)/ { exec {"download_app_studio": command => "wget $url", timeout => 0, } } $version = '3.4' ? {undef => $primary_config_file, default => $source_config} file { "/root/.app": mode => '644', ensure => present } } Invalid Property Value
Implementation configuration smells elsif $version in ['33', '3.3'] { }
if $::kernelversion =~ /^(2.2)/ { $appversion = '3.5' } elsif $::kernelversion =~ /^(2.1)/ { exec {"download_app_studio": command => "wget $url", timeout => 0, } } $version = '3.4' ? {undef => $primary_config_file, default => $source_config} file { "/root/.app": mode => '644', ensure => present } } Misplaced Attribute
Design configuration smells
class package::web { … } class package::mail { … }
class package::environment { … } class package::user { … } package.pp
class apache { package { 'apache2': … } service {
'apache2': … } service { 'mysql': … } package { 'php5': … } file { ‘/etc/apache2/ports.conf': … } user { ‘mitchell': … } } apache.pp
Multifaceted Abstraction • Each abstraction should be designed to
specify the properties of a single piece of software.
class web { } init.pp
Unnecessary Abstraction A class, ‘define’, or module must contain declarations
or statements specifying the properties of a desired system.
class web { exec { ‘hadoop-yarn’: … } exec {
‘apache-util-set’: … } exec { ‘smail-invoke’: … } exec { ‘postfix-set’: … } } init.pp
Imperative Abstraction An abstraction containing numerous imperative statements suffers from
imperative abstraction smell.
package { 'apache2': … } service { 'apache2': … }
service { 'mysql': … } package { 'php5': … } file { ‘/etc/apache2/ports.conf': … } user { ‘mitchell': … } init.pp
Missing Abstraction A module suffers from the missing abstraction smell
when resources and language elements are declared and used without encapsulating them in an abstraction.
class apache { package { 'apache2': … } service {
'apache2': … } file { ‘/etc/apache2/ports.conf': … } … } web.pp class apache { package { 'apache2': … } service { 'apache2': … } file { ‘/etc/apache2/ports.conf': … } … } server.pp
Duplicate Block A duplicate block of statements more than a
threshold indicates that probably a suitable abstraction definition is missing.
package { 'apache2': … } service { 'apache2': … }
service { 'mysql': … } package { 'php5': … } file { ‘/etc/apache2/ports.conf': … } user { ‘mitchell': … } package { 'apache2': … } service { 'apache2': … } service { 'mysql': … } package { 'php5': … } file { ‘/etc/apache2/ports.conf': … } user { ‘mitchell': … } package { 'apache2': … } service { 'apache2': … } service { 'mysql': … } package { 'php5': … } file { ‘/etc/apache2/ports.conf': … } user { ‘mitchell': … } init.pp
Insufficient Modularisation An abstraction suffers from this smell when it
is large or complex and thus can be modularized further.
None
Unstructured Module Each module in a configuration repository must have
a well-defined and consistent module structure. RepoName Manifests Modules README … Apache Adobe … files lib manifests spec templates tests README …
None
Dense Structure This smell arises when a configuration code repository
has excessive and dense dependencies.
None
Weekend Modularity This smell arises when a module exhibits high
coupling and low cohesion. Modularity ratio (A) = Cohesion(A) Coupling(A)
Implications of smells The straw that broke the camel's back
Detecting configuration smells Implementation configuration smells • Puppet-lint [1] •
Additional custom rules in Puppeteer Design configuration smells • Puppeteer [2] — an open source tool 1. http://puppet-lint.com/ 2. https://github.com/tushartushar/Puppeteer
Mining GitHub Repositories Repositories 4,621 Puppet files 142,662 Class declarations
132,323 Define declarations 39,263 File resources 117,286 Package resources 49,841 Service resources 18,737 Exec declarations 43,468 Lines of code (Puppet only) 8,948,611 http://www.tusharma.in/research/does-your-configuration-code-smell-msr-2016/
Let us summarize M E L S U P E
E R I I P T U I N M Y I I A A B N C
Let us summarize M E L S U P E
E R I I P T U I A N M Y I I A A B N C
Let us summarize S M E L S U P
E E R L I I P T U I A N M Y I I A A B N C
Let us summarize S M E L S U P
P E E R L I I P T U I A N M Y I I T A A B N C
Thank you!! Courtesy: spikedmath.com Tushar Sharma
[email protected]
@Sharma__Tushar