kernel
Puppet
RHEL7
package

RHEL 7 Puppetでパッケージインストールとカーネルパラメータ設定

概要

RHEL 7.2でパッケージのインストールとカーネルパラメータの設定をPuppetで実行する。 パッケージはPerlとgcc、カーネルパラメータはmsgmaxとmsgmnbを変更する。

環境

  • RHEL 7.2
  • Puppet 4.10.9

事前準備

  1. Puppetでカーネルパラメータを設定する為にモジュールを追加する

    $ puppet module install herculesteam/augeasproviders_sysctl
    Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules ...
    Notice: Downloading from https://forgeapi.puppet.com ...
    Notice: Installing -- do not interrupt ...
    /etc/puppetlabs/code/environments/production/modules
    └─┬ herculesteam-augeasproviders_sysctl (v2.2.0)
    └─┬ herculesteam-augeasproviders_core (v2.1.4)
    └── puppetlabs-stdlib (v4.24.0)
    

手順

  1. パッケージがインストールされてないことを確認

    $ yum list perl
    読み込んだプラグイン:product-id, search-disabled-repos, subscription-manager
    Repo rhel-7-server-extras-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-rt-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-optional-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    利用可能なパッケージ
    perl.x86_64                                      4:5.16.3-292.el7                                       rhel-7-server-rpms
    
    $ yum list gcc
    読み込んだプラグイン:product-id, search-disabled-repos, subscription-manager
    Repo rhel-7-server-extras-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-rt-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-optional-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    利用可能なパッケージ
    gcc.x86_64                                       4.8.5-16.el7_4.1                                       rhel-7-server-rpms
    
  2. 現状のカーネルパラメータを確認

    $ sudo sysctl -a | grep msgm
    kernel.auto_msgmni = 1
    kernel.msgmax = 8192
    kernel.msgmnb = 16384
    kernel.msgmni = 3676
    
  3. マニュフェストを作成

    $ cat manifest.pp 
    $packages = [
    'perl',
    'gcc',
    ]
    package { $packages:
    ensure => installed,
    }
    sysctl { 'kernel.msgmax': ensure => 'present', persist => true, value => '131072'}
    sysctl { 'kernel.msgmnb': ensure => 'present', persist => true, value => '131073'}
    
  4. マニュフェスト適用前に確認

    $ puppet apply --noop manufest.pp 
    Notice: Compiled catalog for rhel7 in environment production in 0.23 seconds
    Notice: /Stage[main]/Main/Package[perl]/ensure: current_value purged, should be present (noop)
    Notice: /Stage[main]/Main/Package[gcc-c++]/ensure: current_value purged, should be present (noop)
    Notice: /Stage[main]/Main/Package[make]/ensure: current_value purged, should be present (noop)
    Notice: /Stage[main]/Main/Sysctl[kernel.msgmax]/value: current_value 8192, should be 131072 (noop)
    Notice: /Stage[main]/Main/Sysctl[kernel.msgmnb]/value: current_value 16384, should be 131073 (noop)
    Notice: Class[Main]: Would have triggered 'refresh' from 5 events
    Notice: Stage[main]: Would have triggered 'refresh' from 1 events
    Notice: Applied catalog in 3.33 seconds
    
  5. 適用

    $ puppet apply manufest.pp 
    Notice: Compiled catalog for rhel7 in environment production in 0.33 seconds
    Notice: /Stage[main]/Main/Package[perl]/ensure: created
    Notice: /Stage[main]/Main/Package[gcc-c++]/ensure: created
    Notice: /Stage[main]/Main/Package[make]/ensure: created
    Notice: /Stage[main]/Main/Sysctl[kernel.msgmax]/value: changed configuration value from '8192' to '131072' and live value from '8192' to '131072'
    Notice: /Stage[main]/Main/Sysctl[kernel.msgmnb]/value: changed configuration value from '16384' to '131073' and live value from '16384' to '131073'
    Notice: Applied catalog in 79.53 seconds
    

動作確認

  1. パッケージを確認

    $yum list perl
    読み込んだプラグイン:product-id, search-disabled-repos, subscription-manager
    Repo rhel-7-server-extras-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-rt-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-optional-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    インストール済みパッケージ
    perl.x86_64                                      4:5.16.3-292.el7                                      @rhel-7-server-rpms
    
    $ yum list gcc
    読み込んだプラグイン:product-id, search-disabled-repos, subscription-manager
    Repo rhel-7-server-extras-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-rt-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    Repo rhel-7-server-optional-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/5565024692737445633-key.pem
    インストール済みパッケージ
    gcc.x86_64                                      4.8.5-16.el7_4.1                                       @rhel-7-server-rpms
    
  2. カーネルパラメータを確認
    再起動しなくても新しいパラメータに変わる。  もちろん、再起動しても変更後の値になる。

    $ sudo sysctl -a | grep msgm
    kernel.auto_msgmni = 1
    kernel.msgmax = 131072
    kernel.msgmnb = 131073
    kernel.msgmni = 3675