Скачать презентацию Scalable Systems Management with Puppet Nick Jones and Скачать презентацию Scalable Systems Management with Puppet Nick Jones and

f116b1f0de377d5e2348af33934df965.ppt

  • Количество слайдов: 77

Scalable Systems Management with Puppet Nick Jones and Stephen Mc. Nally HPC Operations Group Scalable Systems Management with Puppet Nick Jones and Stephen Mc. Nally HPC Operations Group August 2, 2010

National Institute for Computational Sciences · NICS is a collaboration between UT and ORNL National Institute for Computational Sciences · NICS is a collaboration between UT and ORNL · Awarded the NSF Track 2 B ($65 M) · Phased deployment of Cray XT systems · Staffed with 25 FTEs, funding for 15 more · Total JICS funding ~$92 M

#4 Top 500 June 2010 #4 Top 500 June 2010

Topics · Challenges that System Administrators Face · Why Puppet? · Puppet Installation and Topics · Challenges that System Administrators Face · Why Puppet? · Puppet Installation and Configuration · Managing Your Infrastructure with Puppet · Advanced Puppet Topics · Hands On Exercises 4 of 77

Wireless · Global. Meeting. Wireless · Passcode: TG 10 5 of 77 Wireless · Global. Meeting. Wireless · Passcode: TG 10 5 of 77

Challenges that System Administrators Face Challenges that System Administrators Face

What do Systems Administrators do? · Watch You. Tube · Eat Fritos and Mountain What do Systems Administrators do? · Watch You. Tube · Eat Fritos and Mountain Dew · Have big warm fuzzy secret heart · Rearrange Netflix queue 7 of 77

Case Studies : Your Prototypical Sys. Admin · Has to manage lots of servers Case Studies : Your Prototypical Sys. Admin · Has to manage lots of servers · Responsible for installation, maintenance, updates……the whole shebang · Let’s call him (or her) “Geppetto” 8 of 77

Case Study 1 : Sudo · Organization gets new interns · Need to give Case Study 1 : Sudo · Organization gets new interns · Need to give interns sudo privileges on appropriate machines 9 of 77

Case Study 1 : Sudo · The old way: – Edit the sudoers file Case Study 1 : Sudo · The old way: – Edit the sudoers file on one server – Use scp, pdsh, rsync or some combination of the above to deploy to necessary systems · Pitfalls: – What if you have different distros, and they store the sudoers file in different locations? – How do you detect errors? 10 of 77

Case Study 1 : Sudo · The Puppet way: – Edit the sudoers file Case Study 1 : Sudo · The Puppet way: – Edit the sudoers file on one server – Every other server automatically pulls down the updated Puppet file and installs it into the proper location for its distro · Advantages: – Easy – Centralized – Logged 11 of 77

Case Study 2 : iptables · Need to collaborate with outside group · Must Case Study 2 : iptables · Need to collaborate with outside group · Must allow them SSH access to internal network 12 of 77

Case Study 2 : iptables · The old way: – Update the iptables rules Case Study 2 : iptables · The old way: – Update the iptables rules to allow access from the right ip ranges – Copy the rules to each machine – Restart iptables on each machine, and check that the rule worked 13 of 77

Case Study 2 : iptables · The Puppet way: – Update the iptables rule Case Study 2 : iptables · The Puppet way: – Update the iptables rule to allow access from the right ip ranges – Tell Puppet to ensure that the iptables service is running – Each client machine automatically pulls the updated iptables rule – Each client intelligently knows that iptables must be restarted after a rule update, and it does this automatically using dependencies 14 of 77

Case Study 3 : Doomsday · Centralized web server goes down due to hardware Case Study 3 : Doomsday · Centralized web server goes down due to hardware failure · Must get the website back up quickly 15 of 77

Case Study 3 : Doomsday · The old way: – Multiple sysadmins get stressed Case Study 3 : Doomsday · The old way: – Multiple sysadmins get stressed out – Reinstall the server and reconfigure by hand – Restore Apache configs by hand from tape or other backup (you did backup right? ) 16 of 77

Case Study 3 : Doomsday · The Puppet way: – Take any other spare Case Study 3 : Doomsday · The Puppet way: – Take any other spare server – Change the MAC address in DHCP to the new server – Puppet automatically enforces and deploys the new configuration on the new server – Installs and updates all necessary configurations, including ensuring that the proper services are running 17 of 77

Why Puppet? Why Puppet?

What is Puppet? · Puppet is a configuration management utility · Puppet is not What is Puppet? · Puppet is a configuration management utility · Puppet is not the only configuration management utility 19 of 77

Puppet Competitors · c. Fengine · Bcfg 2 · Chef · …. . and Puppet Competitors · c. Fengine · Bcfg 2 · Chef · …. . and the list goes on 20 of 77

Puppet vs c. Fengine · c. Fengine focuses on managing textfiles · Puppet focuses Puppet vs c. Fengine · c. Fengine focuses on managing textfiles · Puppet focuses on managing constructs like users, services, and packages 21 of 77

Puppet vs c. Fengine · Puppet is model driven – The lowest layer is Puppet vs c. Fengine · Puppet is model driven – The lowest layer is responsible for resource modeling – Eg. User on Solaris vs User on Linux · The language handles high level relationships – Think users instead of /etc/passwd 22 of 77

Puppet Language · Puppet uses Ruby · Puppet’s Language is declarative · You specify Puppet Language · Puppet uses Ruby · Puppet’s Language is declarative · You specify the configuration – Puppet handles the implementation – Must use detailed specification – Need things like dependencies to get the full power of Puppet 23 of 77

Layers Image: Official Puppet Documentation 24 of 77 Layers Image: Official Puppet Documentation 24 of 77

How does Puppet work? Image: Official Puppet Documentation 25 of 77 How does Puppet work? Image: Official Puppet Documentation 25 of 77

Idempotency · Puppet configurations are idempotent – they can safely be run multiple times Idempotency · Puppet configurations are idempotent – they can safely be run multiple times · By default, Puppet runs every 30 minutes · Unlike say --- kickstart --- Puppet can detect the current state of the system · Won’t make changes unless necessary 26 of 77

Cross Platform Abstraction · Puppet doesn’t care about specifics unique to your system · Cross Platform Abstraction · Puppet doesn’t care about specifics unique to your system · All handled automatically (facter!) · Manage users, files, packages, etc. the same way regardless of OS or distro 27 of 77

Providers · Providers fulfill resources – Example: package management – Both ‘yum’ and ‘apt’ Providers · Providers fulfill resources – Example: package management – Both ‘yum’ and ‘apt’ are valid package managers · Puppet uses ‘providers’ to abstract package management away from the user 28 of 77

Facter · How does Puppet know about your system? – Using the Ruby library Facter · How does Puppet know about your system? – Using the Ruby library Facter – Facter supports a large number of predefined facts – Custom facts can be defined -bash-3. 2$ facter architecture => x 86_64 domain => nics. utk. edu facterversion => 1. 5. 7 fqdn => example. nics. utk. edu hardwareisa => x 86_64 hardwaremodel => x 86_64 hostname => example id => jones interfaces => eth 0, eth 0_kraken_una, eth 1 …. and more 29 of 77

Linux · Centos · Debian 3. 1 and later · Fedora Core 2 -6 Linux · Centos · Debian 3. 1 and later · Fedora Core 2 -6 · Fedora 7 and later · Gentoo Linux · Mandriva Corporate Server 4 · RHEL 3 and Later · Oracle Linux · Su. Se Linux 8 and later · Ubuntu 7. 04 and later 30 of 77

BSD/*nix/Windows · Free. BSD 4. 7 and later · Open. BSD 4. 1 and BSD/*nix/Windows · Free. BSD 4. 7 and later · Open. BSD 4. 1 and later · Mac OS X · Solaris 2. 6 · Solaris 7 and later · Windows Support (in beta) 31 of 77

Installing Puppet Table credit: Turnbull, Pulling Strings with Puppet 32 of 77 Installing Puppet Table credit: Turnbull, Pulling Strings with Puppet 32 of 77

Installing Puppet Table credit: Turnbull, Pulling Strings with Puppet 33 of 77 Installing Puppet Table credit: Turnbull, Pulling Strings with Puppet 33 of 77

Installing Puppet Table credit: Turnbull, Pulling Strings with Puppet 34 of 77 Installing Puppet Table credit: Turnbull, Pulling Strings with Puppet 34 of 77

35 of 77 35 of 77

Puppet Installation and Configuration Puppet Installation and Configuration

Manual Installation of Puppet is a client / server based application Puppet clients are Manual Installation of Puppet is a client / server based application Puppet clients are often referred to as nodes, clients, or hosts The Puppet server is often referred to as the puppetmaster Not: 37 of 77

Manual Installation of Puppet Currently Reductive Labs offers support for the following operating systems: Manual Installation of Puppet Currently Reductive Labs offers support for the following operating systems: Linux: Cent. OS, Debian, Fedora, Gentoo, Mandriva, RHEL, Oracle Linux, SUSE, and Ubuntu BSD: Free. BSD, and Open. BSD Other Unix: Mac OS-X, and Sun Solaris Windows: None currently Source: http: //docs. puppetlabs. com/guides/platforms. html 38 of 77

Manual Installation of Puppet • The Puppet client must be installed on every system Manual Installation of Puppet • The Puppet client must be installed on every system – even your Puppetmaster • Most platforms will use the default package manager to install Puppet • If you use a package management system (i. e. - yum) you will automatically get most prerequisite libraries • Facter is not installed by default when using the package manager • Reductive Labs provides source tar balls in case you want to torture yourself 39 of 77

Installing Puppet on Cent. OS / RHEL Ensure that your package manager (yum) is Installing Puppet on Cent. OS / RHEL Ensure that your package manager (yum) is configured to communicate with the EPEL repo. # rpm -Uvh http: //download. fedora. redhat. com/pub/epel/5/x 86_64/epel-release-53. noarch. rpm # yum repolist Should list epel in the left hand column 40 of 77

Installing Puppet on Cent. OS / RHEL # yum install -y puppet (installs the Installing Puppet on Cent. OS / RHEL # yum install -y puppet (installs the client) # yum install -y puppet-server (installs the server) # yum install -y facter # yum install -y ruby-doc (optional if you want –help to work with ruby commands) These installs will also process other dependencies such as ruby and ruby -libs 41 of 77

Configure Puppet on Cent. OS / RHEL • Once yum installation is complete you Configure Puppet on Cent. OS / RHEL • Once yum installation is complete you must configure Puppet • The /etc/puppet directory will be created after installation • Create a simple manifest in /etc/puppet/manifests/ called site. pp • The puppetmaster daemon needs a syntactically correct file to run • Example: node default { } 42 of 77

Configure Puppet on Cent. OS / RHEL • The default config file is located Configure Puppet on Cent. OS / RHEL • The default config file is located at /etc/puppet. conf • It is initially created with a basic set of options • These options control the behavior of the Puppet suite 43 of 77

Configure Puppet on Cent. OS / RHEL • Sample puppet. conf file (to see Configure Puppet on Cent. OS / RHEL • Sample puppet. conf file (to see all values use # puppet – genconfig): # cat /etc/puppet. conf [main] vardir = /var/lib/puppet logdir = /var/log/puppet rundir = /var/run/puppet ssldir = $vardir/ssl tagmap = /etc/puppet/tagmail. conf reportfrom = puppet@sample. domain. com [puppetd] classfile = $vardir/classes. txt localconfig = $vardir/localconfig report = true [puppetmasterd] reports = tagmail autosign = /etc/puppet/autosign. conf 44 of 77

Configure Puppet on Cent. OS / RHEL • The puppet client config looks for Configure Puppet on Cent. OS / RHEL • The puppet client config looks for a system named “puppet” • Add an entry to DNS for the puppet master (recommended) puppet IN CNAME puppetmaster • You could also change the config to point to a specific system (not recommended) • Start the puppetmaster daemon # /etc/init. d/puppetmaster start && tail –f /var/log/messages • Ensure the puppetmaster daemon starts on boot # /sbin/chkconfig puppetmaster on 2345 • Basic puppetmaster installation is complete 45 of 77

Configure Puppet on Cent. OS / RHEL • To complete the configuration we must Configure Puppet on Cent. OS / RHEL • To complete the configuration we must configure the client to run on the puppetmaster • Manually start the puppet client once to test # /etc/init. d/puppet once -v • This will generate a certificate request to the puppetmaster # puppetca --list (will show the waiting certificate requests) • Multiple ways to resolve this 1. Setup puppetmaster to automatically sign all certificates 2. Setup puppetmaster to only sign specific certificates 3. Perform manual certificate signing each time • We use option #2 46 of 77

Setup Certificate Autosign Option #1 • To setup automatic certificate signing you must specify Setup Certificate Autosign Option #1 • To setup automatic certificate signing you must specify so in the /etc/puppet/autosign. conf file • An example of autosign. conf file that accepts every new certificate request # cat /etc/puppet/autosign. conf *. sample. domain. com • Pro’s – will automatically sign certs, when reinstalling a system the autosign. conf file doesn’t need to be updated • Con’s – security risk, not good to automate the certificate signing mechanism 47 of 77

Setup Certificate Autosign Option #2 • To setup restrictive automatic signing we will use Setup Certificate Autosign Option #2 • To setup restrictive automatic signing we will use the /etc/puppet/autosign. conf file • Example autosign. conf file # cat /etc/puppet/autosign. conf server 1. sample. domain. com server 2. sample. domain. com server 3. sample. domain. com • Pro’s – adds additional control to certificate signing, provides greater security than option #1, is a good balance of security and automation • Con’s – the autosign. conf file must be kept up to date 48 of 77

Setup Certificate Autosign Option #3 • Manual certificate signing doesn’t require the autosign. conf Setup Certificate Autosign Option #3 • Manual certificate signing doesn’t require the autosign. conf file • Once the certificate request has been made you should be able to see a list of the waiting requests on the puppetmaster by using: # puppetca --list server 1. sample. domain. com server 2. sample. domain. com • To sign a specific request run the following: # puppetca --sign server 1. sample. domain. com 49 of 77

Setup Certificate Autosign Option #3 • You may verify the signed cert by running: Setup Certificate Autosign Option #3 • You may verify the signed cert by running: # puppetca --list --all + server 1. sample. domain. com • The “+” sign denotes a signed certificate • Pro’s – most secure way to sign certificates • Con’s – can get cumbersome when scaling your puppet installation 50 of 77

Configure Puppet on Cent. OS / RHEL • After the certificate is accepted you Configure Puppet on Cent. OS / RHEL • After the certificate is accepted you can retest by starting the puppet client # /etc/init. d/puppet once –v • In syslog you will see entries similar to the following: puppetd[18704]: Starting Puppet client version 0. 25. 4 puppetmasterd[18047]: Compiled catalog for server 1. sample. domain. com in 0. 25 seconds puppetd[18704]: Finished catalog run in 2. 96 seconds • Puppet client should start and should finish the catalog run without any errors 51 of 77

Installation is complete! Basic Puppet installation is complete! (seriously, we aren’t joking) 52 of Installation is complete! Basic Puppet installation is complete! (seriously, we aren’t joking) 52 of 77

BREAK 53 of 77 BREAK 53 of 77

Managing Your Infrastructure with Puppet Managing Your Infrastructure with Puppet

NICS Puppet Infrastructure /etc/puppet auth. conf files/ autosign. conf byhost/ fileserver. conf host 1/ NICS Puppet Infrastructure /etc/puppet auth. conf files/ autosign. conf byhost/ fileserver. conf host 1/ puppet. conf host 2/ tagmail. conf host 3/ manifests/ nodes. pp site. pp classes/ class 1. pp class 2. pp Files 55 of 77 Folders Placeholder Names modules/ mod 1/ manifests/ init. pp files/ templates/

Sample site. pp • There are many ways to configure your Puppet environment • Sample site. pp • There are many ways to configure your Puppet environment • Here’s one way to setup your /etc/puppet/manifests/site. pp file: #site. pp import “classes/*. pp” #This will import every. pp #file in the classes directory import nodes #This will import the nodes. pp file that /etc/puppet/manifests #lives in • You can also set enterprise wide environment variables here instead of specifically defining them within each node • Environment variables can be used in templates 56 of 77

Classes vs. Modules • Why use the classes directory and the modules directory? • Classes vs. Modules • Why use the classes directory and the modules directory? • Classes are more global and usually contain many different modules • Modules are the smallest unit of measure that Puppet builds from • Here are some sample classes that we use: badservices. pp, cluster. pp, disable_accounts. pp, diskcheck. pp, homedirs. pp, hpss. pp, infrastructure. pp, ipmi. pp, packages. pp, python_env. pp, rootmail. pp, security. pp, snmp. pp, subversion. pp, yumconfig. pp, yumreposerver. pp 57 of 77

Building Puppet Modules • We store all of our modules in /etc/puppet/modules • This Building Puppet Modules • We store all of our modules in /etc/puppet/modules • This is referenced in our /etc/puppet. conf file under the puppetmaster section • Here are some of the modules we have created over time: accounts, iptables, named, oncalldb, postfix, rt, syslogng, amie_gold, cron, openssl, postgresql, dhcpd, grid_tools, lustre, moab, networking, otp, psacct, subversion, drupal, nfs, passwd, puppet, sudo, cacti, httpd, mysql, pbstools, splunk, sysctl, console, infiniband, ldap, mailman, nagios, ntp, php, ssh, syslog • You don’t have to create all of your modules up front • Work on one application (module) at a time until everything is in Puppet 58 of 77

Building Puppet Modules • This method of storing modules separately in /etc/puppet/modules assists in Building Puppet Modules • This method of storing modules separately in /etc/puppet/modules assists in management • We can store module specific files within the module instead of all together • If you’re working on a module, you can stay in that module until you are finished and ready to test • Inside each module, we have two main directories: manifests and files • The file directory houses the module specific files • The manifest is where the module’s definition lives (init. pp) 59 of 77

Sample module init. pp • Below is a simple example of the named (DNS) Sample module init. pp • Below is a simple example of the named (DNS) class: class named { package { bind: ensure => installed; bind-chroot: ensure => installed; } service { "named": enable => true, ensure => running, require => [ Package["bind"], Package["bind-chroot"] ]; } file { "/var/named/chroot/etc/rndc. key": path => "/var/named/chroot/etc/rndc. key", source => "puppet: ///named/var/named/chroot/etc/rndc. key", require => [ Package["bind"], Package["bind-chroot"] ]; } } 60 of 77

Module Files • What goes in the files directory? • These files can be Module Files • What goes in the files directory? • These files can be anything from configuration files to custom scripts • Gives the system administrator the ability to control any file • This doubles as a security measure and as a standardization practice • We store our files in the same directory structure as the final configuration • The “puppet” user must be able to read the files • Simplifies system administration 61 of 77

Sample Infrastructure Class • Our infrastructure. pp class uses several different modules class infrastructure Sample Infrastructure Class • Our infrastructure. pp class uses several different modules class infrastructure { include puppet include yumconfig include syslog include security if $ntp_server { include ntp: : server } else { include ntp } include ldap include console include badservices } 62 of 77

What is a template? • Puppet templates are flat files containing Embedded Ruby (ERB) What is a template? • Puppet templates are flat files containing Embedded Ruby (ERB) variables • An example ssh_config template follows: Protocol <%= ssh_Protocol %> <% if ssh_Listen. Address != "" %> Listen. Address <%= ssh_Listen. Address %> <% end -%> Syslog. Facility <%= ssh_Syslog. Facility %> RSAAuthentication <%= ssh_RSAAuthentication %> Pubkey. Authentication <%= ssh_Pubkey. Authentication %> Use. PAM <%= ssh_Use. PAM %> Accept. Env LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY Accept. Env LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT Accept. Env LC_IDENTIFICATION LC_ALL X 11 Forwarding <%= ssh_X 11 Forwarding %> None. Enabled no 63 of 77

ERB variable declaration • Ruby ERB variables can be set in different places • ERB variable declaration • Ruby ERB variables can be set in different places • They can be specified in the class that calls them: class resolv { $searchpath = "testing. com" $nameservers = ["192. 168. 0. 1", "192. 168. 0. 2"] file { "resolv. conf": name => "/etc/resolv. conf", content => template("resolv-template. erb") } } 64 of 77

ERB variable declaration • Or you can set them for each node in /etc/puppet/manifests/nodes. ERB variable declaration • Or you can set them for each node in /etc/puppet/manifests/nodes. pp node server 1 { $searchpath = "testing. com" $nameservers = ["192. 168. 0. 1", "192. 168. 0. 2"] include resolv } node server 2 { $searchpath = "testing. com" $nameservers = ["192. 168. 0. 1", "192. 168. 0. 2"] include resolv } 65 of 77

Hands on Exercises • Install and configure Puppet client/server • Create a basic My. Hands on Exercises • Install and configure Puppet client/server • Create a basic My. SQL client module • Create a basic My. SQL server module 66 of 77

Install and Configure Puppet client / server • Using the handouts install and configure Install and Configure Puppet client / server • Using the handouts install and configure the Puppetmaster and Puppet client • These systems are Cent. OS 5. 5 virtual machines • Login and pw will be given 67 of 77

Create a module • Now that we have Puppet up and running, create a Create a module • Now that we have Puppet up and running, create a My. SQL client module using the handout • Once you have created the My. SQL client module, we would then like to work through creating a My. SQL server module 68 of 77

Advanced Puppet Topics Advanced Puppet Topics

Module Dependency • Module dependencies can serialize module installation • Handy when an application Module Dependency • Module dependencies can serialize module installation • Handy when an application needs to have certain files in place before installing the rest • Puppet runs in a “shotgun” manner • Different pieces of each class are installed a completely different times • This is where module dependency comes in • Example: YUM repositories and application specific installs 70 of 77

Intra-module dependencies • Most of the time dependencies are in the context of the Intra-module dependencies • Most of the time dependencies are in the context of the same module • The application must be installed before it is configured class rt { package {"rt 3": ensure => installed, } file { "/etc/rt 3/RT_Site. Config. pm": source => "puppet: ///rt/etc/rt 3/RT_Site. Config. pm", ensure => present, owner => apache, group => apache, mode => 640, require => Package[rt 3]; } } 71 of 77

Inter-module dependencies • The more complex your Puppet environment becomes the greater the need Inter-module dependencies • The more complex your Puppet environment becomes the greater the need for inter-module dependencies are. • This is where a specific resource defined in module “A” is dependent on a resource in module “B” class rt { package { "rt 3": ensure => installed, require => Yumrepo[epel]; "mod_fcgid": ensure => installed; "perl-Authen-PAM": ensure => installed; } } 72 of 77

Module Inheritance • Inherit statements do exactly what they sound like they do • Module Inheritance • Inherit statements do exactly what they sound like they do • Come in handy when you only need to change something specific for a node or two class ntp: : verne inherits ntp { file { "/etc/sysconfig/ntpd": ensure => file, source => "puppet: ///verne/etc/sysconfig/ntpd", owner => root, group => root, mode => 0644, notify => [ Service[ntpd], ], } } 73 of 77

Optimize your My. SQL modules for use with dependencies • HINT - The My. Optimize your My. SQL modules for use with dependencies • HINT - The My. SQL server module should have an inheritance from the My. SQL client module 74 of 77

Proper Cluster Management • Clusters should be managed with “classes” not “modules” • Here’s Proper Cluster Management • Clusters should be managed with “classes” not “modules” • Here’s an example of our /etc/puppet/manifests/cluster. pp class cluster { include puppet include yumconfig include syslog include sysctl include ntp include homedirs include ldap include console include psacct include security } 75 of 77

Proper Cluster Management • More recent version of Puppet support ruby regex • Here’s Proper Cluster Management • More recent version of Puppet support ruby regex • Here’s an example of how to efficiently manage a cluster of 10 node /^clusternode[0 -9]+/ { $disable_ipv 6 = False include cluster include kernel-utils boot_kernel { "2. 6. 18 -164. 15. 1. el 5": } } • To test out your ruby regex use: http: //rubular. com/ 76 of 77

Questions? ? Nick Jones Stephen Mc. Nally 77 of 77 jones@nics. utk. edu smcnally@utk. Questions? ? Nick Jones Stephen Mc. Nally 77 of 77 jones@nics. utk. edu smcnally@utk. edu