Top Banner
Building and Testing Puppet with Docker Carla Souza
37

Building and Testing Puppet with Docker

Jun 29, 2015

Download

carlaasouza

PuppetConf 2014 presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building and Testing Puppet with Docker

Building and Testing Puppet with Docker

Carla Souza

Page 2: Building and Testing Puppet with Docker

Carla Souza

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

Page 3: Building and Testing Puppet with Docker

Our environment

~15k nodesRedboxesAmazon EC2 InstancesVirtual machines

OpenVZ containersKVM

Page 4: Building and Testing Puppet with Docker
Page 5: Building and Testing Puppet with Docker

Code your infrastructure

Page 6: Building and Testing Puppet with Docker

Code QA

Page 7: Building and Testing Puppet with Docker

Check your syntax

puppet parse validatepuppet-lintyaml syntax checkererb syntax checker

Page 8: Building and Testing Puppet with Docker

Variable data type validationvalidate_absolute_pathvalidate_arrayvalidate_augeasvalidate_boolvalidate_cmdvalidate_hashvalidate_ipv4_addressvalidate_ipv6_addressvalidate_revalidate_slength

validate_string

Page 9: Building and Testing Puppet with Docker

Smoke testing#tests/test.pp

class { 'apt': }

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

Page 10: Building and Testing Puppet with Docker

rspec-puppet

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

Page 11: Building and Testing Puppet with Docker

beaker

Page 12: Building and Testing Puppet with Docker

beaker

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

Page 13: Building and Testing Puppet with Docker

Code Review

Page 14: Building and Testing Puppet with Docker
Page 15: Building and Testing Puppet with Docker

No errors on the puppet run!=

Correctly configured

Page 16: Building and Testing Puppet with Docker
Page 17: Building and Testing Puppet with Docker

Mimic the production environment

Page 18: Building and Testing Puppet with Docker

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

Page 19: Building and Testing Puppet with Docker
Page 20: Building and Testing Puppet with Docker

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

* not required

Page 21: Building and Testing Puppet with Docker

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 Puppet with Docker

Step 2: Facts

Steal facts from an existing node

Page 23: Building and Testing Puppet with Docker

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 Puppet with Docker

Step 3: Specify OS

--os ubuntu14.04

--os debian-wheezy

Page 25: Building and Testing Puppet with Docker

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

Page 26: Building and Testing Puppet with Docker

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

Page 27: Building and Testing Puppet with Docker

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

Page 28: Building and Testing Puppet with Docker

FROM tianon/debian:wheezy

RUN apt-get -qq -y install puppet puppetmaster

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

Page 29: Building and Testing Puppet with Docker

$ ls .

./

../

.git/

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

Page 30: Building and Testing Puppet with Docker

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 Puppet with Docker

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

Page 32: Building and Testing Puppet with Docker

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

--hostname myserver \

--verbose

Page 33: Building and Testing Puppet with Docker
Page 34: Building and Testing Puppet with Docker

Why using the existing tools?

Page 35: Building and Testing Puppet with Docker

What can I do with all this?

Page 36: Building and Testing Puppet with Docker

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 Puppet with Docker

Thank you!

[email protected]

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

Twitter: @carlaas* not yet available