+ All Categories
Home > Software > Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot...

Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot...

Date post: 10-Jun-2015
Category:
Upload: netways
View: 132 times
Download: 0 times
Share this document with a friend
Description:
A lot of Puppet users are unaware of the efficiency and the power to do more that External Node Classifiers (ENCs) provide us. In this hands on tutorial, Anirban Saha is going to demonstrate how the simplest and the most complex of Puppet environments can leverage the feature of ENCs, both script and LDAP based, and do configuration management more efficiently in their infrastucture. This knowledge will help both beginners and experience puppet users to start using ENCs and build the base for a more scalable infrastructure as it grows and incorporate the best practices to do so within their organization.
Popular Tags:
14
Organizing Puppet nodes with External Node Classifiers and LDAP PuppetCamp Dusseldorf October, 2014
Transcript
Page 1: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

Organizing Puppet nodes with External Node Classifiers and LDAP PuppetCamp Dusseldorf October, 2014

Page 2: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

Objectives : • Organizing data and avoiding clutter • Learn the workflow of External Node Classifiers (ENCs) • How to write ENCs and demonstration • Learn the workflow of organizing node data with LDAP backend • How to configure LDAP for puppet nodes

Page 3: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

Why bother to organize data ?

because without it ….

Page 4: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

• Prepare to scale for now and for the future • Adopt standardized naming conventions to be used in

configuring ENCs and maintaining inventory • Practice the art of better module writing • Avoid unnecessary troubleshooting of nodes.pp • Educate teams to practice ENCs (and avoid malpractice such as

defining resources in nodes.pp…believe me, they do this)

Page 5: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

ENC Workflow • Basically a script in any language (Ruby, Python, Perl, etc) • Takes the hostname (FQDN) or certname as the sole argument • Manipulates the argument and collects the data as written in the script • Produces the output in YAML format • Output has three main keys – classes, parameters and environment • A basic example of the output : environment: production classes: - sudo - ssh - ntp parameters: location: datacenter3

Page 6: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

ENC output explained Environment : The environment of the node (e.g. production, staging, development, etc.) being sync’d as configured in puppet Classes : List of modules configured in puppet and supposed to be sync’d with the node, e.g. classes: - groups - users - ntp Parameters : A list of top scope variables which can be used in any of the modules listed in the ‘classes ‘ section. The value of the ‘parameters’ key is a hash of variable names and their values, can be used in the modules and templates, e.g. parameters: puppetserver: puppet-dusseldorf adminserver: admin-dusseldorf location: dusseldorf

Page 7: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

Puppet Configuration changes for ENC

Following changes need to be made : In puppet configuration file of puppet master (lets say /opt/puppet/puppet.conf, if puppet conf directory is /opt/puppet) : [master] node_terminus = exec external_nodes = /opt/puppet/enc/node_classifier.rb All node classifier scripts need to be placed in the same directory (here /opt/puppet/enc)

Page 9: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

Organizing Puppet Data with LDAP Prerequisites : • Active LDAP server or a new LDAP implementation • ruby-ldap package needs to be present on the Puppet worker node WorkFlow : • A new LDAP ‘objectclass’ called ‘puppetClient’ is added by extending the LDAP schema using the

node terminus shipped with Puppet (/usr/share/puppet/ext/ldap/puppet.schema) • This schema adds some new attributes for the puppetClient objectclass as follows :

• environment – equivalent to the ‘environment’ hash key in ENC scripts • puppetClass – equivalent to the ‘classes’ hash key in ENC scripts • puppetvar – equivalent to the ‘parameters’ hash key in ENC scripts

• Each new node to be added to the Puppet database need to be added with the above attributes and objectclass in the LDAP directory

Page 10: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

Puppet LDAP configuration steps Containers need to be added under the top-level organizations in LDAP as follows : dn: ou=hosts,dc=puppetcamp,dc=com objectclass: organizationalUnit ou: hosts dn: ou=production,ou=hosts,dc=puppetcamp,dc=com objectclass: organizationalUnit ou: production dn: ou=staging,ou=hosts,dc=puppetcamp,dc=com objectclass: organizationalUnit ou: staging The containers above represent each of the environments configured in the Puppet infrastructure

Page 11: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

Puppet LDAP configuration steps

The nodes need to be configured and added to LDAP as follows : dn: cn=pcdppms01.puppetcamp.com,ou=production,ou=hosts,dc=puppetcamp,dc=com objectclass: puppetClient objectclass: device environment: production puppetClass: groups puppetClass: sudo puppetClass: users::ops puppetClass: users::keys puppetvar: location='puppetcamp_dusseldorf' puppetvar: puppetserver='172.31.84.91' puppetvar: adminserver='172.31.0.2‘ The above configuration needs to be populated in ldif files and added to the LDAP directory

Page 12: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

Puppet configuration changes for LDAP

The following changes need to be done in puppet.conf on the puppet master node to use LDAP as the node backend: node_terminus = ldap ldapserver = ldap.puppetcamp.com ldapbase = ou=hosts,dc=puppetcamp,dc=com The puppet master then needs to be restarted for the changes to take effect

Page 14: Puppet Camp Duesseldorf 2014: Anirban Saha - External node classifiers - Get efficient and do a lot more

Contact: Anirban Saha Email : [email protected] Twitter : @rosesnthornz Skype : anirban.saha.88


Recommended