building and testing from scratch a puppet environment with docker - puppetconf 2014

37
Building and Testing Puppet with Docker Carla Souza

Upload: puppet-labs

Post on 01-Dec-2014

1.797 views

Category:

Technology


1 download

DESCRIPTION

Building and Testing from Scratch a Puppet Environment with Docker - Carla Souza, Reliant

TRANSCRIPT

Page 1: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Building and Testing Puppet with Docker

Carla Souza

Page 2: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Carla Souza

Software engineer for ReliantPuppet user since 2010Container virtualization user since 2008

Page 3: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Our environment

~15k nodesRedboxesAmazon EC2 InstancesVirtual machines

OpenVZ containersKVM

Page 4: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014
Page 5: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Code your infrastructure

Page 6: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Code QA

Page 7: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Check your syntax

puppet parse validatepuppet-lintyaml syntax checkererb syntax checker

Page 8: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Variable data type validationvalidate_absolute_pathvalidate_arrayvalidate_augeasvalidate_boolvalidate_cmdvalidate_hashvalidate_ipv4_addressvalidate_ipv6_addressvalidate_revalidate_slength

validate_string

Page 9: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Smoke testing#tests/test.pp

class { 'apt': }

puppet apply --noop --modulepath=".." tests/test.pp

Page 10: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

rspec-puppet

https://github.com/puppetlabs/puppetlabs-apt/blob/master/spec/unit/puppet/type/apt_key_spec.rb#L75

Page 11: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

beaker

Page 12: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

beaker

https://github.com/puppetlabs/puppetlabs-apt/blob/master/spec/acceptance/nodesets/default.yml

Page 13: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Code Review

Page 14: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014
Page 15: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

No errors on the puppet run!=

Correctly configured

Page 16: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014
Page 17: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Mimic the production environment

Page 18: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Image from http://wegeekgirls.files.wordpress.com/2014/04/mystique_x-men_days-of-future-past.png

Page 19: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014
Page 20: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

1. Target node's hostname2. Use custom facts*3. Specify OS4. Thats all

* not required

Page 21: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Step 2: Facts

Write your own custom facts# myserver-facts.txtdomain=reliantsecurity.comipaddress=172.17.42.1ipaddress_docker0=172.17.42.1ipaddress_lo=127.0.0.1ipaddress_wlan0=172.16.3.218is_virtual=false

Page 22: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Step 2: Facts

Steal facts from an existing node

Page 23: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Step 2: Facts$ mystique fetch-facts myserver

$ mystique fetch-facts --hostname myserver --user carla myserver.company

# myserver-facts.txtdomain=reliantsecurity.comipaddress=172.17.42.1ipaddress_docker0=172.17.42.1ipaddress_lo=127.0.0.1ipaddress_wlan0=172.16.3.218is_virtual=false(...)

Page 24: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Step 3: Specify OS

--os ubuntu14.04

--os debian-wheezy

Page 25: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

# mystique run --os ubuntu14.04 --hostname myserver

Page 26: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

# mystique run --facts /path/to/facts.txt --hostname myserver

Page 27: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Image from http://wegeekgirls.files.wordpress.com/2014/04/mystique_x-men_days-of-future-past.png

Page 28: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

FROM tianon/debian:wheezy

RUN apt-get -qq -y install puppet puppetmaster

ONBUILD ADD puppet.tar.gz /etc/puppet/

Page 29: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

$ ls .

./

../

.git/

.gitignorefiles/templates/manifests/modules/auth.confautosign.conffileserver.confnamespaceauth.conf

Page 30: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

FROM mystique/debian:latest

ADD myserver-facts.txt /etc/facter/facts.d/

RUN puppet apply --modulepath=/etc/puppet/modules master.pp

CMD puppet agent --no-daemonize

Page 31: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

# mystique run --facts /path/to/facts.txt --hostname myserver

Report for myserver

12 resources created

2 warnings

0 errors

Page 32: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

# mystique run --facts /path/to/facts.txt \

--hostname myserver \

--verbose

Page 33: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014
Page 34: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Why using the existing tools?

Page 35: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

What can I do with all this?

Page 36: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Future steps● Mimic existing resources from nodes● Extend supported OS● Specify puppet version● Multiple node testing

○ Linking containers● User an existing Puppet Master

Page 37: Building and Testing from Scratch a Puppet Environment with Docker - PuppetConf 2014

Thank you!

[email protected]

https://github.com/carlasouza/mystique*

Twitter: @carlaas* not yet available