Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Delegated Config with Multiple Hiera Databases ...

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for Rob Terhaar Rob Terhaar
September 24, 2014

Delegated Config with Multiple Hiera Databases - PuppetConf 2014

PuppetConf 2014

Avatar for Rob Terhaar

Rob Terhaar

September 24, 2014
Tweet

More Decks by Rob Terhaar

Other Decks in Technology

Transcript

  1. Company & Personal Bio • Build custom cloud, automation, deployment,

    and management systems for: • Finance / / Bio-Tech / / Start-ups / / Advertising • Sysadmin since 1998 • Puppet user since 2007 • Based in NYC
  2. With Hiera, you can externalize your data, and easily understand

    how configuration data is assigned to your servers.
  3. Business Logic (Hiera) vs. OS-Specific Config (params.pp) • Servers in

    production: use database IP 10.0.0.1 • In us-east1: use NTP server 167.88.119.29 • On RHEL7: SELINUX=enforcing • Package names for Apache on Debian/RHEL: apache2/httpd • 1 CPU = default to 1 worker
 but on 4 CPUs = default to 5 workers
  4. Hiera Basics Function in a parameterized class class ntp( $servers

    = hiera('ntp::servers'), ) { < ntp config goes here… > }
  5. $ cat /etc/puppet/hiera.yaml --- :backends: - yaml ! :logger: console

    ! :hierarchy: - "fqdn/%{fqdn}" - "role/%{role}" - "lifecycle/%{lifecycle}" - "location/%{location}" - common ! :yaml: :datadir: /etc/puppet/hieradb
  6. $ tree /etc/puppet/hieradb ! "## lifecycle $ "## dev.yaml $

    "## production.yaml $ &## staging.yaml "## location $ &## us-east1.yaml &## os "## rhel6.yaml &## rhel7.yaml
  7. • eyaml • http (REST) • mysql • postgres •

    redis • mongodb • json • yaml • and more…
  8. $ cat /etc/puppet/hiera.yaml --- :backends: ! ! ! :logger: console

    ! :hierarchy: - "fqdn/%{fqdn}" - "role/%{role}" - "lifecycle/%{lifecycle}" - "location/%{location}" - common ! :yaml: :datadir: /etc/puppet/hieradb ! :postgres: :datadir: /etc/puppet/hieradb :host: <hostname> :user: <username> :pass: <password> :database: <database> - yaml - postgres
  9. $ tree /etc/puppet/hieradb ! "## lifecycle $ "## dev.yaml $

    "## $ "## production.yaml $ &## staging.yaml "## location $ &## us-east1.yaml &## os "## rhel6.yaml &## rhel7.yaml production.sql
  10. “Architecture is the stuff that's hard to change later. And

    there should be as little of that stuff as possible.” 
 - Martin Fowler http:/ /martinfowler.com/ieeeSoftware/whoNeedsArchitect.pdf
  11. Everyone Else DevOps Team Node resource resource resource resource Node

    resource resource resource resource environments modules hiera puppetdb manifests templates ! - fqdn/%{::fqdn}! - lifecycle/%{::lifecycle}! - location/%{::location}! - os/%{::osfamily}! - common Puppet Master
  12. Everyone Else DevOps Team hiera ! - fqdn/%{::fqdn}! - lifecycle/%{::lifecycle}!

    - location/%{::location}! - os/windows.yml! - common
  13. Everyone Else! ! ntp::servers = [! “server1.corp”,! “server2.corp”,! ] DevOps

    Team hiera ! - fqdn/%{::fqdn}! - lifecycle/%{::lifecycle}! - location/%{::location}! - os/windows.yml! - common
  14. Colleagues who are not in the “DevOps Team” need to

    manage a few pre-defined parameters. (but only on a subset of servers)
  15. Everyone Else! ! ntp::servers = [! “server1.corp”,! “server2.corp”,! ] Special

    People Club hiera ! - fqdn/%{::fqdn}! - lifecycle/%{::lifecycle}! - location/%{::location}! - os/windows.yml! - common Colleagues who are not in the “DevOps Team” need to manage a few pre-defined parameters. (but only on a subset of servers)
  16. • What are we building (1-2 sentence overview) • What

    are the basic goals? (write them down!) • How will we know when it’s done? • What assumptions are we are making? • What are some risks? The Requirements Document
  17. • Get feedback from… • your boss • the client

    • your colleagues • other stakeholders The Requirements Document
  18. What are we building? ! We are building a data

    import system for Hiera which allows secure delegated access to end users. The system filters data, and can import data from various external systems.
  19. • Import filtered data from various sources to a database.

    ! • That database is secondary Hiera backend datastore. ! • Adding additional import sources should be simple. ! • Easy to understand where keys are imported from. Goals
  20. How will we know when it’s done? The first version

    will be complete once we: • Build a prototype • Document the solution • Test importing data from a few sources • Create a deployment plan • Deploy to production
  21. Everyone Else! ! UPDATE windows! SET value=‘[“server1.corp”, “server2.corp”]! WHERE key=‘ntp::servers’;

    DevOps Team hiera We need a way to delegate access to a few Hiera keys. PostgreSQL &! hiera-postgresql- backend ! - fqdn/%{::fqdn}! - lifecycle/%{::lifecycle}! - location/%{::location}! - os/windows.sql! - common windows.sql! ———! ntp::servers: SELECT value FROM windows WHERE key=‘ntp::servers’; Single SQL Hiera Backend
  22. Importer ! App Puppet! Master Node Node resource resource resource

    resource resource resource resource resource DevOps Team Delegated Hiera DB Primary Hiera DB filter Everyone Else Import Plugin 1 Import Plugin 2 External Data Source 2 White List! (What keys & namespaces are allowed) Authoritative Hiera Data External Data Source 1 Simple data import script (run via cron) The slightly better solution (logical diagram)
  23. Custom Hiera Backend The slightly better solution (with implementation detail)

    Importer ! App Puppet! Master Node Node resource resource resource resource resource resource resource resource DevOps Team Delegated Hiera DB Primary Hiera DB filter Everyone Else Import Plugin 1 Import Plugin 2 External Data Source 2 External Data Source 1 Python import script, with pluggable import backends PostgreSQL DB CMDB API, and LDAP .yaml files stored in git
  24. Useful Resources Good Design: https:/ /www.vitsoe.com/us/about/good-design Learn More about Hiera:

    http:/ /garylarizza.com/blog/2013/12/08/when-to-hiera/ Postgres Hiera Backend: https:/ /github.com/adrianlzt/hiera-postgres-backend Hiera Encryption (eyaml): https:/ /github.com/TomPoulton/hiera-eyaml Requirements: http:/ /en.wikipedia.org/wiki/Requirements_analysis