Puppet - an introduction

12
puppet An introduction

Transcript of Puppet - an introduction

Page 1: Puppet - an introduction

puppetAn introduction

Page 2: Puppet - an introduction

My Puppet experience

• At Syncapse, migrated from AWS to company owned DC. Wrote puppet 2 code for whole infra.o Hadoop and Hbase clustero Python based data pipeline machineso Tomcat based web serverso Apache web servers

• At SlideShare, worked on migration from puppet 2 to puppet 3 (dc movement and RHEL upgrade)o rsnapshot moduleo solr moduleo Using various modules from puppetlabs e.g. haproxy, system etc.

Page 3: Puppet - an introduction

What this Session will cover ?

• How Puppet works• Puppet Terminologies• Relationships and Ordering• Puppet modules• Hands on

• Understand Hiera• Provision a node as webserver• Provision a node as database server• Go through dummy module code• Add one level of hierarchy in hiera

Page 4: Puppet - an introduction

How puppet works ?

Page 5: Puppet - an introduction

Puppet TerminologiesCatalog A document that describes the desired system state for one specific machine.

Page 6: Puppet - an introduction

Puppet TerminologiesFactsFacter is a cross platform Ruby library designed to gather information on puppet nodes.

[root@puppetnode ~]# facter -y--- macaddress_eth0: "08:00:27:62:B9:AD" blockdevice_sda_vendor: ATA operatingsystem: CentOS rubyversion: "1.8.7" is_virtual: "true" productname: VirtualBox swapfree: "3.94 GB" hardwareisa: x86_64 id: root kernelmajversion: "2.6" interfaces: "eth0,eth1,lo" swapsize_mb: "4031.99" uuid: "78347BE7-62D1-4ECF-BD30-2159CF8FDA3C" netmask: "255.255.255.0" swapsize: "3.94 GB" bios_release_date: "12/01/2006" processor0: "Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz" uniqueid: "1cac0580"

Page 7: Puppet - an introduction

Puppet TerminologiesResourcestype { ‘title’: attribute => value,}file { ‘/etc/password’: ensure => file, owner => ‘root’, group => ‘root’, mode => ‘0600’,}puppet resource user root

ClassesGroup of resouces can be organised in classes.

NodesClasses get applied to nodes.# /etc/puppet/manifests/site.ppnode ‘test.corp.adobe.com { include common include apache include squid}

Page 8: Puppet - an introduction

Relationships and Ordering

• Order of resources in Puppet does not matter. Puppet manages resources in most efficient way

• If some resources are to be managed in specific order, declare relationships :

package { ‘openssh-server’: ensure => exists, before => File[‘/etc/ssh/sshd_config’]}ORfile { ‘/etc/ssh/sshd_config’: ensure => file, mode => 0600, source => ‘puppet:///modules/sshd/sshd_config’, require => Package[‘openssh-server’]}notify, subscribe, chaining arrows (-> and ~>)

Page 9: Puppet - an introduction

Puppet Modulespuppet module install puppetlabs-apachepuppet module generate author-mode_name

Page 10: Puppet - an introduction

Hands on• Go through hiera.yaml• Provision a node with role webserver• Provision a node with role dbserver• Add one level in hierarchy in hiera.yaml• Go through puppet module structure

Page 11: Puppet - an introduction

Advanced Topics• Virtual Resources – declare somewhere and

realize anywhere, any number of times• Exported Resources – allow nodes to share

information• PuppetDB – stores catalogs and facts of all the

nodes. • MCollective – framework for orchestration and

parallel job execution

Page 12: Puppet - an introduction

Useful resouces• Puppet language

o http://docs.puppetlabs.com/puppet/3.8/reference/lang_visual_index.html

• Writing Puppet moduleso https://blog.mozilla.org/it/2013/01/30/liveblog-how-to-use-puppet-like-an-adult/

• Hierao http://docs.puppetlabs.com/hiera/1/index.html

• Tutorialso http://www.example42.com/tutorials/PuppetTutorialo http://pivotallabs.com/spinning-useful-vms-quickly-vagrant-puppet-puppet-forge/