devops: falando um pouco sobre desenvolvimento orientado a testes com puppet
TRANSCRIPT
![Page 1: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/1.jpg)
DevOps: Falando um pouco sobredesenvolvimento orientado a testes
com Puppet
DevOps: Falando um pouco sobredesenvolvimento orientado a testes
com Puppet
![Page 2: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/2.jpg)
http://about.me/mfandrade
Quem sou eu?
![Page 3: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/3.jpg)
Puppet?
![Page 4: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/4.jpg)
MANIFEST
MANIFEST
MANIFEST
![Page 5: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/5.jpg)
MANIFEST
RESOURCE
RESOURCE
RESOURCE
MANIFEST
RESOURCE
RESOURCE
MANIFEST
RESOURCE
![Page 6: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/6.jpg)
MANIFEST
CATALOG
RESOURCE
RESOURCE
RESOURCE
MANIFEST
RESOURCE
RESOURCE
MANIFEST
RESOURCE
compile
![Page 7: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/7.jpg)
DECLARATIVA
![Page 8: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/8.jpg)
IDEMPOTENTE
![Page 9: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/9.jpg)
// rpm basedpackage { 'mysql': ensure => installed,}
file { '/etc/my.cnf': ensure => present, source => 'puppet:///modules/mysql/my.cnf', require => Package['mysql'],}
service { 'mysqld': ensure => running, enabled => true, subscribe => File['/etc/my.cnf'],}
1
![Page 10: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/10.jpg)
// deb basedpackage { 'mysqlserver': ensure => installed,}
file { '/etc/mysql/my.cnf': ensure => present, source => 'puppet:///modules/mysql/my.cnf', require => Package['mysqlserver'],}
service { 'mysql': ensure => running, enabled => true, subscribe => File['/etc/mysql/my.cnf'],}
2
![Page 11: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/11.jpg)
// mysql.pp // rpm and deb based$pkg = 'mysql'$cfg = '/etc/my.cnf'$srv = 'mysqld'
if $::osfamily == 'Debian' { $pkg = 'mysqlserver' $cfg = '/etc/mysql/my.cnf' $srv = 'mysql'
}
// cont...
![Page 12: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/12.jpg)
// mysql.pp // rpm and deb based$pkg = 'mysql'$cfg = '/etc/my.cnf'$srv = 'mysqld'
if $::osfamily == 'Debian' { $pkg = 'mysqlserver' $cfg = '/etc/mysql/my.cnf' $srv = 'mysql'
}
// cont...
![Page 13: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/13.jpg)
3// mysql.pp // rpm and deb basedif $::osfamily == 'Debian' { $pkg = 'mysqlserver' $cfg = '/etc/mysql/my.cnf' $srv = 'mysql'
} elsif $::osfamily == 'RedHat' { $pkg = 'mysql' $cfg = '/etc/my.cnf' $srv = 'mysqld'
} else fail('Unsupported osfamily')
// cont...
![Page 14: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/14.jpg)
3// cont...package { $pkg: ensure => installed,}
file { $cfg: ensure => present, source => 'puppet:///modules/mysql/my.cnf', require => Package[$pkg],}
service { $srv: ensure => running, enabled => true, subscribe => File[$cfg],}
![Page 15: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/15.jpg)
Como testar isso?
![Page 16: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/16.jpg)
Como testar isso?
cucumber-puppethttp://projects.puppetlabs.com/projects/cucumber-puppet/
rspec-puppethttp://rspec-puppet.com/tutorial/
puppet-lint * http://puppet-lint.com/
![Page 17: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/17.jpg)
rspec-puppet
![Page 18: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/18.jpg)
rspec-puppetrequire 'rspec'require 'rspecpuppet'
describe 'when installing mysql' do it { should contain_package('mysql').with { :ensure => 'installed' }}
it { should contain_file('/etc/my.cnf').with { :ensure => 'present', :source => 'puppet:///modules/mysql/my.cnf', }}
it { should contain_service('mysqld').with { :ensure => 'running', :enable => true }}end
![Page 19: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/19.jpg)
rspec-puppetrequire 'rspec'require 'rspecpuppet'
describe 'when installing mysql' do it { should compile }
end
![Page 20: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/20.jpg)
rspec-puppetrequire 'rspec'require 'rspecpuppet'
describe 'when installing mysql' do it { should compile }
end
SMOKE TE
STSMOK
E TEST
![Page 21: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/21.jpg)
$ puppet apply noop verbose mysql.pp
![Page 22: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/22.jpg)
$ puppet apply noop verbose mysql.ppError: Syntax error at 'fail'; expected '}' at mysql.pp:13 on localhostError: Invalid parameter enabled on Service[mysql] at mysql.pp:28 on localhost
![Page 23: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/23.jpg)
// mysql.pp // rpm and deb basedif $::osfamily == 'Debian' { $pkg = 'mysqlserver' $cfg = '/etc/mysql/my.cnf' $srv = 'mysql'
} elsif $::osfamily == 'RedHat' { $pkg = 'mysql' $cfg = '/etc/my.cnf' $srv = 'mysqld'
} else fail('Unsupported osfamily')
// cont...
![Page 24: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/24.jpg)
// mysql.pp // rpm and deb basedif $::osfamily == 'Debian' { $pkg = 'mysqlserver' $cfg = '/etc/mysql/my.cnf' $srv = 'mysql'
} elsif $::osfamily == 'RedHat' { $pkg = 'mysql' $cfg = '/etc/my.cnf' $srv = 'mysqld'
} else { fail('Unsupported osfamily') }
// cont...
![Page 25: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/25.jpg)
// cont...package { $pkg: ensure => installed,}
file { $cfg: ensure => present, source => 'puppet:///modules/mysql/my.cnf', require => Package[$pkg],}
service { $srv: ensure => running, enabled => true, subscribe => File[$cfg],}
![Page 26: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/26.jpg)
// cont...package { $pkg: ensure => installed,}
file { $cfg: ensure => present, source => 'puppet:///modules/mysql/my.cnf', require => Package[$pkg],}
service { $srv: ensure => running, enable => true, subscribe => File[$cfg],}
![Page 27: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/27.jpg)
$ puppet apply noop verbose mysql.ppNotice: Compiled catalog for notebook in environment production in 3.30 secondsInfo: Applying configuration version '1444280295'Notice: /Stage[main]/Mysql/Package[mysqlserver]/ensure: current_value purged, should be present (noop)Notice: /Stage[main]/Mysql/Service[mysql]/ensure: current_value stopped, should be running (noop)Info: /Stage[main]/Mysql/Service[mysql]: Unscheduling refresh on Service[mysql]Notice: Class[Mysql]: Would have triggered 'refresh' from 2 eventsNotice: Stage[main]: Would have triggered 'refresh' from 1 eventsNotice: Finished catalog run in 0.53 seconds
![Page 28: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/28.jpg)
Características
Simplicidade
Curva de aprendizado
Pouca profundidade
Design evolutivo
https://docs.puppetlabs.com/
![Page 29: DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet](https://reader031.vdocuments.pub/reader031/viewer/2022021813/587ab2fa1a28abed218b690d/html5/thumbnails/29.jpg)
OBRIGADOOBRIGADO