SCaLE Puppet Introduction. Puppet Assigns and Maintains a Machine s Desired Role

Similar documents
Configuration Management with Puppet. Introduction

PULLING STRINGS. Learn how to save time and streamline your system administration with the help of Puppet, a centralized

Being a puppet master

An Introduction to Puppet Enterprise

Configuration Management with Puppet. LinuxFest Northwest. Garrett Honeycutt April 25th, 2010

Puppet. Configuring your systems so you don't have to... Frank Sweetser Senior Network Engineer WPI Network Operations and Security

Configuration Management - Using Puppet. lctseng / Liang-Chi Tseng

Cobbler and Puppet. Controlling your server builds. Eric Mandel and Jason Ford BlackMesh

Integrating the Cloud with Puppet. Tuesday, February 26, 13

Puppet Types and Providers Dan Bode and Nan Liu

Puppet Documentation. (Generated on July 01, 2013, from git revision 46784ac1656bd7b57fcfb51d0865ec7ff65533d9)

An downloadable version of this guide may be found on our downloads page.

Chapter 1 - Introduction. September 8, 2016

PUPPET MODULES: A HOLISTIC APPROACH

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

deploying high capacity IP fabrics

Less talk, more rock. Puppet

Puppet on the AWS Cloud

PESIT Bangalore South Campus

ChiliProject - Bug # 529: builder is not part of the bundle. Add it to Gemfile

Today. Review. Unix as an OS case study Intro to Shell Scripting. What is an Operating System? What are its goals? How do we evaluate it?

CST8207: GNU/Linux Operating Systems I Lab Ten Boot Process and GRUB. Boot Process and GRUB

About Backup and Restore, on page 1 Supported Backup and Restore Procedures, on page 3

On a Ubuntu system which was updated today to facter (diretly via apt.puppetlabs.com) I also see exactly the same error.

Installing Open Project on Ubuntu AWS with Apache and Postgesql

Advanced Puppet Topics. Ken Barber Professional Services Engineer

CSE 303 Lecture 4. users/groups; permissions; intro to shell scripting. read Linux Pocket Guide pp , 25-27, 61-65, , 176

Bitnami JRuby for Huawei Enterprise Cloud

Model Question Paper. Credits: 4 Marks: 140

Project #3: Implementing NIS

MFM 4.2. Install Guide

Preupgrade. Preupgrade overview

Troubleshooting. The NLR Web Interface Does not Appear CHAPTER

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

From Bare Metal to Cloud. Andy ICCLab, ZHAW Piotr Kasprzak, GWDG

Introduction and first application. Luigi De Russis. Rails 101

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

From Bare Metal to Cloud

Unix Introduction to UNIX

Q) Q) What is Linux and why is it so popular? Answer - Linux is an operating system that uses UNIX like Operating system...

CSE 390a Lecture 3. Multi-user systems; remote login; editors; users/groups; permissions

Red Hat Satellite 6.3

IBM AIX Operating System Courses

An Introduction to the Puppet Ecosystem

Puppet. Pulling Strings with. Configuration Management Made Easy. James Turnbull. Available as a PDF Electronic Book or Print On Demand

How to Back Up Linux/UNIX Data Using SSHFS

USING DIRECT DATABASE DRIVERS

Red Hat Satellite 6.3

CONCEPTES AVANÇATS DE SISTEMES OPERATIUS

Using CFEngine with Open Nebula A CFEngine Special Topics Handbook

PUPPET. Use at General Mills

HANDS UP IF YOU DON T HAVE A VM OR IF YOU DON T REMEMBER YOUR PASSWORDS. Or something broke

Linux Essentials Objectives Topics:

Basic UNIX system administration

Commands are in black

24 Writing Your First Script

Shell Programming Overview

Bitnami Ruby for Huawei Enterprise Cloud

Contents in Detail. Foreword by Xavier Noria

Migrate Data from Cisco Secure ACS to Cisco ISE

Junos OS. Puppet for Junos OS Administration Guide. Modified: Copyright 2018, Juniper Networks, Inc.

Using vrealize Log Insight Importer. April 12, 2018 vrealize Log Insight 4.6

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Linux Systems Administration Shell Scripting Basics. Mike Jager Network Startup Resource Center

LAB #7 Linux Tutorial

레드마인 설치 작성일 : 작성자 : 김종열

Manual Shell Script Linux If File Exists Wildcard

Red Hat Satellite 6.3

Qedit 5.6 for HP-UX. Change Notice. by Robelle Solutions Technology Inc.

Introduction to Linux

Tivoli Provisioning Manager for OS Deployment Installation on W2003R2-NFS-MySQL

Introduction to Computer Security

INUVIKA TECHNICAL GUIDE

PrepAwayExam. High-efficient Exam Materials are the best high pass-rate Exam Dumps

Preparing for the Prime Home Installation

EE516: Embedded Software Project 1. Setting Up Environment for Projects

App Central: Developer's Guide. For APKG 2.0

Puppet 3 Beginner's Guide

Jackson State University Department of Computer Science CSC / Computer Security Fall 2013 Instructor: Dr. Natarajan Meghanathan

Unix Basics. UNIX Introduction. Lecture 14

UDS Enterprise Free & Evaluation Edition. Lab UDS Enterprise + VMware vsphere + RDP/XRDP

Abstract. This is the MySQL OS X extract from the MySQL 5.6 Reference Manual. For legal information, see the Legal Notices.

UDS Enterprise Free & Evaluation Edition. Lab UDS Enterprise + VMware vsphere + RDP/XRDP

Manual Prepared by GalaxyVisions Customer Care Team

Using bash. Administrative Shell Scripting COMP2101 Fall 2017

Chapter 5: User Management. Chapter 5 User Management

CounterACT Macintosh/Linux Property Scanner Plugin

We re all developers now

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Manual Script Windows Batch If Condition. Statement Examples >>>CLICK HERE<<<

QuickStart: Deploying DataSynapse GridServer 5.0 on HP Clusters

Lab 1: Accessing the Linux Operating System Spring 2009

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala

Managing Databases. Prerequisites. Information About the Database Administration Tools CHAPTER

Deploying Rails with Kubernetes

Using Ruby and irb in CSE 341 Winter 2015

Using PCF Ops Manager to Deploy Hyperledger Fabric

Qedit 5.7 for HP-UX. Change Notice. by Robelle Solutions Technology Inc.

Introduction to Linux

Transcription:

SCaLE Puppet Introduction Puppet Assigns and Maintains a Machine s Desired Role Managing Configuration Drift 1 of 24 2/23/10 7:41 PM

Puppet Executables that we will employ: ralsh The Resource Abstraction Layer Shell. facter Executable and library that discovers facts about client systems. puppet Executable that interprets Puppet manifests, compiles the catalog, and applies the catalog locally. puppetmasterd Centralized daemon that authenticates client connections, serves files, compiles templates, and provides puppet clients with a catalog. puppetd Puppet daemon that runs on client machines, makes connections to the puppetmaster, retrieves the catalog, and applies that catalog locally. puppetca Puppet s built-in certificate authority. Resources Resources are the building blocks Puppet uses to model system configurations. Simple user resource declaration. 2 of 24 2/23/10 7:41 PM

user{'redmine': ensure => present, shell => '/usr/sbin/nologin', RAL: Resource Abstraction Layer The RAL provides a consistent model for resources across supported platforms. RAL: Resource Abstraction Layer Resource types depend on providers to translate specification into implementation. package{'rubygems': ensure => installed, Package is just one of the many native Puppet resource types. RAL: Resource Abstraction Layer Each resource type has one or more providers. 3 of 24 2/23/10 7:41 PM

RAL: Resource Abstraction Layer Providers are the interface between the underlying OS and the resource types. 4 of 24 2/23/10 7:41 PM

RAL: Resource Abstraction Layer The package resource type has 23 providers: ls -1 /usr/lib/ruby/site_ruby/1.8/puppet/provider/package appdmg.rb freebsd.rb sunfreeware.rb apple.rb gem.rb sun.rb aptitude.rb hpux.rb up2date.rb apt.rb openbsd.rb urpmi.rb aptrpm.rb pkgdmg.rb yumhelper.py blastwave.rb portage.rb yumhelper.pyc darwinport.rb ports.rb yumhelper.pyo dpkg.rb rpm.rb yum.rb fink.rb rug.rb Ralsh: The Resource Abstraction Layer Shell Executing ralsh and providing a resource and a title returns the state of a resource. root@puppetclient:~$ ralsh user redmine user { 'redmine': ensure => 'absent' Ralsh: The Resource Abstraction Layer Shell Executing ralsh and providing a resource, a title, and specifying an attribute alters the resource. root@puppetclient:~$ ralsh user redmine ensure=present notice: /User[redmine]/ensure: created user { 'redmine': uid => '500', password => '!!', gid => '500', home => '/home/redmine', shell => '/bin/bash', ensure => 'present' 5 of 24 2/23/10 7:41 PM

Core Resource types: user group host cron exec file package service mount tidy Core Resource types: The type reference documentation can also be found on the Reductive Labs website. http://docs.reductivelabs.com/guides/types/index.html The User Resource Type Some basic attributes for the user resource type: name: OS specified limits apply. (namevar) ensure: Sets the basic state of the user resource. Valid values are absent, present. gid: The user s primary group. Can be specified numerically or by name. groups: The secondary group or groups to which the user is assigned. The primary group should not be listed. Multiple groups should be specified as an array. home: The users home directory. managehome: Whether to manage the home directory when managing the user. Valid values are true, false. The File Resource Type Basic Attributes: path: Specifies the target location for file. (namevar) ensure: Accepts absent, present, file, and directory. Any other value will be treated as a symlink. owner: Owner of file. 6 of 24 2/23/10 7:41 PM

group: Group of file. mode: Mode of file content: Specifies the content of file as a string. source: Specifies the source of file. force: Force replacement of directories with a link. Valid values (true, false). ignore: Omits files matching specified patterns during recursion (Ex:.svn,.git). recurse: Whether or not directories should be managed recursively. Valid values (true, false) purge: Whether or not to purge unmanaged file resources within a directory. Valid values (true, false) The File Resource Type Simple file resource declaration with a local source. file {'/etc/sudoers': ensure => file, group => 'root', owner => 'root', mode => '440', source => '/etc/puppet/files/sudoers', The File Resource Type Directory example. file {'/tmp/src': ensure => directory, mode => '755', The File Resource Type Symlink example. file {'/tmp/testfile': source => '/tmp/src/testfile', file {'/tmp/testlink': ensure => '/tmp/testfile', 7 of 24 2/23/10 7:41 PM

Facter and Facts Puppet uses facter to gather information about the host system. Facter and Facts Executing the facter command returns a list of key value pairs. root@puppetclient:~$ facter architecture => x86_64 domain => reductivelabs.com facterversion => 1.5.2 fqdn => puppetclient.reductivelabs.com hardwaremodel => x86_64 hostname => aku interfaces => eth0 ipaddress => 172.16.10.1 kernel => Linux operatingsystem => Ubuntu... The returned key value pairs are facts. The Puppet Executable The standalone puppet executable: interprets puppet code The Puppet Executable The standalone puppet executable: interprets puppet code compiles a catalog The Puppet Executable The standalone puppet executable: 8 of 24 2/23/10 7:41 PM

interprets puppet code compiles a catalog uses the RAL to apply the catalog locally. The Puppet Executable The Puppet Executable Files containing Puppet code are known as manifests and by convention have a.pp suffix. The Puppet Executable Example Puppet Manifest: user {'elvis': ensure => present, 9 of 24 2/23/10 7:41 PM

home => '/home/elvis', gid => 'elvis', shell => '/bin/bash', managehome => true, # A group resource definition group {'foo': ensure => present, Specifying Dependencies Puppet is not a procedural language, it is declarative. All ordering dependencies between resources must be explicity specified. Specifying Dependencies The require and before metaparameters establish dependencies between resources. Specifying Dependencies require Specifying Dependencies 10 of 24 2/23/10 7:41 PM

before Specifying Dependencies This ensures that permissions of these directories are managed only after the db migration task is run. exec{'migrate': command => '/usr/bin/rake db:migrate', cwd => $reddir, environment => 'RAILS_ENV=production', require => Exec['session'], creates => "${reddir/db/schema.rb" file{ [ "${reddir/public", "${reddir/files", "${reddir/log", "${reddir/tmp", "${reddir/public/plugin_assets" ]: ensure => directory, recurse => true, owner => 'redmine', group => 'redmine', mode => '0755', require => Exec['migrate'], Redmine Dependencies 11 of 24 2/23/10 7:41 PM

Specifying Dependencies Resources can be refreshed by other resources. The subscribe and notify metaparameters establish refresh relationships between resources. Specifying Dependencies The subscribe metaparameter establishes a refresh relationship from the containing resource to a change in the referenced resource. 12 of 24 2/23/10 7:41 PM

Specifying Dependencies This manifest ensures that mysqld is restarted only if /root/.my.cnf changes. service{'mysqld-restart': restart => '/usr/sbin/service mysqld restart' file{'/root/.my.cnf': content => template('mysql/my.cnf.erb'), notify => Service['mysqld-restart'], The Resources Resource Type Using the host resource type we can specify specific host entries. host {'kermit.reductivelabs.com': ensure => present, host_aliases => 'aku', ip => '172.16.238.131', host {'piggy.reductivelabs.com': ensure => present, host_aliases => ['piggy', 'missy'], ip => '172.16.238.132', host {'oscar.reductivelabs.com': ensure => absent, 13 of 24 2/23/10 7:41 PM

What if we only want to have explicitly declared entries in the /etc/hosts file? The Resources Resource Type If a resource is ensurable then the resources resource type can be used to enable purging of unmanaged resources. The Resources Resource Type This will purge all unspecified host resources. resources {'host': purge => true, The Resources Resource Type Attributes: name: the name of the resource type that is to be managed. (namevar) purge: true or false unless_system_user: true, false, or some upper uid limit specified as an integer. The Resources Resource Type Exercise: Purging unmanage resources. Use ralsh to generate a manifest named hosts.pp in /etc/puppet/manifests. Edit hosts.pp to include a resources type that enables purging for the host resource type. Manually add a host entry to /etc/hosts. Use puppet to interpret the hosts.pp manifest and ensure that the unmanaged resource is purged. The Service Resource Type: Attributes: name: The name of the service as understood on the underlying services subsystem. (namevar) 14 of 24 2/23/10 7:41 PM

enable: If a service should be started at boot. Can be true or false. ensure: If the resource should currently be running. Can be true, false, running, or stopped. hasrestart: Specifies that your service has a restart command. Can be true or false. hasstatus: Specifies that your service has a status command. Can be true or false. pattern: The pattern to search for in the process table. restart: Specify a restart command. start: Specify a start command. status: Specify a status command. stop: Specify a stop command. The Service Resource Type: Example of a service resource type: service {'sshd': enable => true, ensure => running, hasstatus => true, hasrestart => true, The Service Resource Type: Exercise: Use ralsh to stop the sshd service. What happens if you execute the same ralsh command again? Set the parameter hasstatus=true and use ralsh to ensure sshd is stopped. Use ralsh to ensure that the sshd service is started. Be sure to use hasstatus=true. Classes Classes in Puppet are used to model fundamental aspects of nodes. Classes Example: ruby::dev class. class ruby::dev { require ruby 15 of 24 2/23/10 7:41 PM

package {['ruby-rdoc', 'ruby-irb', 'rubygem-rake']: ensure => installed, Classes You can also create relationships to classes using require and before. class redmine::webbrick { include redmine $redmine_port='3000' exec{'start-redmine': command => 'ruby script/server webrick -e production &', unless => "netstat -ltn grep ${redmine_port", cwd => $redmine::params::reddir, user => 'redmine', path => '/bin:/usr/bin', require => Class['redmine'], Redmine Class Relationships 16 of 24 2/23/10 7:41 PM

Defined Resource Types Defined resource types behave like custom resource types. Accepts Metaparameters Can be used multiple times Defined Resource Types Vhost example define rails::db_config( $adapter, $database, $host='localhost', $username, $password, $encoding='utf8', $environment='production', $socket='/tmp/mysql.sock' ){ file{"${name/config/database.yml": content => template('rails/database.yml.erb'), Defined Resource Types Using a defined resource example. $reddir='/opt/redmine' rails::db_config{$reddir: adapter => 'mysql', username => 'redmine', password => 'password', database => 'redmine', socket => '/var/run/mysqld/mysqld.sock', Templates Puppet uses Ruby s builtin templating, ERB. 17 of 24 2/23/10 7:41 PM

http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/erb.html Templates Basic ERB for productions rails db configuration. <%= environment %>: adapter: <%= adapter %> database: <%= database %> host: <%= host %> username: <%= username %> password: <%= password %> encoding: <%= encoding %> socket: <%= socket %> Templates Basic ERB syntax: Iteration # We can also iterate over arrays <% fooarray.each do val %> Foo array has a value of <%= val %> <% end %> Client/Server Diagram 18 of 24 2/23/10 7:41 PM

Environments 19 of 24 2/23/10 7:41 PM

External Nodes Diagram 20 of 24 2/23/10 7:41 PM

Exported Resources Puppet has the ability to export resources to a database so that they can be collected and used on other hosts. class hosts { @@host { $hostname: ip => $ipaddress, alias => $fqdn Host << >> Exported Resources 21 of 24 2/23/10 7:41 PM

Exporting resources requires configuration of storeconfigs. Exported Resources But what if there is a host entry that we don t want to have in the /etc/host files. We can use the resources resource to purge rogue entries. Exported resources for decommissioned servers must be purged from the database using a script. Future Architecture 22 of 24 2/23/10 7:41 PM

I am known by many names Dan Bode dan <at> reductivelabs.com bodepd <on> irc://chat.freenode.net/#puppet Want to learn more? http://reductivelabs.com/ 23 of 24 2/23/10 7:41 PM

http://docs.reductivelabs.com/ http://reductivelabs.com/trac/puppet 24 of 24 2/23/10 7:41 PM