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

DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代

DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代

scott.liao (Mr. 沙先生)

September 10, 2018
Tweet

More Decks by scott.liao (Mr. 沙先生)

Other Decks in Technology

Transcript




  1. -- We can do it.
    scott.liao Mr.

    View full-size slide

  2. 104

    DevOps, AWS and more …
    • Blog Mr.
    • Gitbook Puppet
    • Github @shazi7804
    • iT
    Ops - Puppet

    View full-size slide

  3. Puppet x 104

    View full-size slide

  4. What’s Puppet

    View full-size slide





  5. "
    Github !
    AWS

    View full-size slide

  6. Who cares
    ⣐褕茒▁ U

    View full-size slide



  7. 1 2 3
    PLANNING

    View full-size slide



  8. 1 2 3
    PLANNING
    • Users, Groups
    • SNMP
    • Hostname
    • Motd
    • Profile
    • NTP
    • Backup

    View full-size slide



  9. 1 2 3
    PLANNING
    • Users, Groups
    • SNMP
    • Hostname
    • Motd
    • Profile
    • NTP
    • Backup
    • Apache / Tomcat / Java
    • Apache / PHP
    • Nginx / NodeJS
    • Nginx / PHP
    • Nginx / Python

    View full-size slide



  10. 1 2 3
    PLANNING
    • Users, Groups
    • SNMP
    • Hostname
    • Motd
    • Profile
    • NTP
    • Backup
    • Apache / Tomcat / Java
    • Apache / PHP
    • Nginx / NodeJS
    • Nginx / PHP
    • Nginx / Python



    • All Server

    View full-size slide

  11. Manifest node ^www\.104\.com\.tw$ {
    # manage basic configuration
    package { 'ntp': ensure => present }
    # manage users and groups
    group { 'devopsdays': ensure => present }
    user { 'scott.liao':
    ensure => present,
    comment => ’DevOpsDays Taipei 2018 speaker',
    home => '/104corp/scott.liao',
    groups => 'devopsdays',
    }
    # manage application
    package { 'apache2': ensure => present }
    package { 'php7.0': ensure => present }
    }


    • Ansible playbook
    • Puppet
    Coding

    View full-size slide

  12. Coding
    Module



    class basic {
    package { 'ntp': ensure => present }
    }
    class users {
    group { 'devopsdays': ensure => present }
    user { 'scott.liao':
    ensure => present,
    comment => 'DevOpsDays Taipei 2018 speaker',
    home => '/104corp/scott.liao',
    groups => 'devopsdays',
    }
    }
    class web {
    package { 'apache2': ensure => present }
    package { 'php7.0': ensure => present }
    }

    View full-size slide

  13. Coding
    Role and Profile



    class role::web {
    include profile::basic
    include profile::users
    include profile::web
    }
    class profile::basic { … }
    class profile::users { … }
    class profile::web { … }
    node ^www\.104\.com\.tw$ {
    include role::web
    }

    View full-size slide

  14. Sync of puppet
    runinterval (default)

    View full-size slide

  15. Sync of puppet
    fqdn_rand
    # When reboot after sync puppet
    @reboot /opt/puppetlabs/bin/puppet agent –t
    # Generates random time of sync puppet
    2,12,22,32,42,52 * * * * sleep 12; /opt/puppetlabs/bin/puppet agent –t
    • Hash with fqdn
    • random and limit

    View full-size slide

  16. IaC with Puppet
    CI / CD




    • hiera

    |-- Gemfile
    |-- Puppetfile
    |-- Rakefile
    |-- autosign.conf
    |-- data
    |-- environments
    |-- dev
    |-- production
    |-- hiera.yaml
    |-- private
    |-- profile
    |-- role
    |-- spec
    # module manage
    # node auto sign
    # hiera data
    # manifests
    # hiera config
    # private module
    # profile
    # role
    # test case

    View full-size slide

  17. IaC with Puppet
    Module manage
    • Framework
    • r10k
    • librarian-puppet
    • Module provider
    • Puppetlabs
    • voxpupuli (Github)
    • official

    View full-size slide

  18. IaC with Puppet
    Test Framework
    • rspec-puppet (unit test)
    • puppet-lint (coding style)
    • puppetlabs_spec_helper (module testing)
    • beaker-rspec (acceptance test)

    View full-size slide

  19. Facter and Dashboard
    Node PuppetDB Dashboard
    • Dashboard
    • Puppet Enterprise
    • Puppetboard
    • Grafana with prometheus_reporter
    • Custom from Puppetdb

    View full-size slide

  20. Puppet in 104 Corp
    727
    Population
    118401
    Resource
    1Y7M
    Time
    10
    Module

    View full-size slide

  21. We can do it.

    View full-size slide