Monday, August 25, 2014

Playing with puppet vol IV - Centos 6

Previously I've been playing with resources on Centos 7. Now I'll try to apply these resources on Centos 6.

I've installed Centos 6 system with basic packages. At first I was trying to use puppet 2.7 from epel6 but I was not successful. Agent generates CSR with MD5 digest and I was not able to persuade 3.6 puppet master to sign it. Therefore I've installed puppet 3.6 from puppetlabs yum repo:

[root@puppet6 ~]# rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm
Retrieving http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm
warning: /var/tmp/rpm-tmp.doHTGx: Header V4 RSA/SHA1 Signature, key ID 4bd6ec30: NOKEY
Preparing...                ########################################### [100%]
   1:puppetlabs-release     ########################################### [100%]
[root@puppet6 ~]# yum install puppet
.
.
.

I'll start the puppet agent:

[root@puppet6 ~]# chkconfig --list puppet
puppet          0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@puppet6 ~]# chkconfig --level 2345 puppet on
[root@puppet6 ~]# service puppet start
Starting puppet agent:                                     [  OK  ]

I'll sign certificate on the master side:

[root@puppet vajko-basic]# puppet cert list
  "puppet6" (SHA256) D7:A2:AC:29:1D:F0:F6:DB:F1:D6:55:BC:08:6B:6F:3E:FB:63:B5:A0:1A:7A:19:42:B1:F8:88:AA:87:66:60:62
[root@puppet vajko-basic]# puppet cert sign puppet6
Notice: Signed certificate request for puppet6
Notice: Removing file Puppet::SSL::CertificateRequest puppet6 at '/var/lib/puppet/ssl/ca/requests/puppet6.pem'

I'll add new node to site manifest:

[root@puppet vajko-basic]# cat /etc/puppet/manifests/site.pp 
    node 'puppet7.localdomain', 'puppet6' {
        include basic
    }

I'll get error on agent while apllying the catalog:

Error: Execution of '/usr/bin/yum -d 0 -e 0 -y list bash-completion' returned 1: Error: No matching Packages to list
Error: /Stage[main]/Basic/Package[bash-completion]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y list bash-completion' returned 1: Error:
 No matching Packages to list
.
.
.
Error: /Stage[main]/Basic/Package[telnet]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y list telnet' returned 1: Error: xz compression not available

First error occured because I'm trying to install bash-completion package which is from epel repo. But epel repo is not installed. I'm missing dependency. I'll add the dependency into the basic module:

    # Packages
    package { ['telnet', 'wget', 'tree', 'bash-completion']:
        ensure => installed,
        require => Yumrepo['epel'],
    }

Second error is a little bit complicated. I'm not sure what exactly is the problem. But I has something to do with epel repo. According to epel resource definiton, puppet has installed epel repository for rhel/centos 7 on centos 6 machine. I need to update epel resource definition to use correct repo version depending on agent machine OS version. I'll use operatingsystemmajrelease fact for this. Here are values for this fact on centos 6 and 7:

[root@puppet6 ~]# facter operatingsystemmajrelease
6
[root@puppet7 ~]# facter operatingsystemmajrelease
7

Here comes updated version of epel resource:

      yumrepo { 'epel':
          descr => "Extra Packages for Enterprise Linux $::operatingsystemmajrelease - \$basearch",
          ensure => 'present',
          enabled => true,
          mirrorlist => "https://mirrors.fedoraproject.org/metalink?repo=epel-$::operatingsystemmajrelease&arch=\$basearch",
          failovermethod => 'priority',
          gpgcheck => 0,
          gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$::operatingsystemmajrelease",
      }

I've rebuild and reinstalled the module and this is the output:

[root@puppet6 ~]$ puppet agent -t
.
.
.
Error: Execution of '/usr/bin/yum -d 0 -e 0 -y list bash-completion' returned 1: Error: xz compression not available
Error: /Stage[main]/Basic/Package[bash-completion]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y list bash-completion' returned 1: Error: xz compression not available
Error: Execution of '/usr/bin/yum -d 0 -e 0 -y list vim-enhanced' returned 1: Error: xz compression not available
Error: /Stage[main]/Basic/Package[vim-enhanced]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y list vim-enhanced' returned 1: Error: xz compression not available
Notice: /Stage[main]/Basic/File[vim-config]: Dependency Package[vim-enhanced] has failures: true
Warning: /Stage[main]/Basic/File[vim-config]: Skipping because of failed dependencies
Notice: /Stage[main]/Basic/File[/root/.vim]: Dependency Package[vim-enhanced] has failures: true
Warning: /Stage[main]/Basic/File[/root/.vim]: Skipping because of failed dependencies
Error: Execution of '/usr/bin/yum -d 0 -e 0 -y list telnet' returned 1: Error: xz compression not available
Error: /Stage[main]/Basic/Package[telnet]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y list telnet' returned 1: Error: xz compression not available
Notice: /Stage[main]/Basic/File[/root/.vim/plugin]: Dependency Package[vim-enhanced] has failures: true
Warning: /Stage[main]/Basic/File[/root/.vim/plugin]: Skipping because of failed dependencies
Notice: /Stage[main]/Basic/File[comments-plugin]: Dependency Package[vim-enhanced] has failures: true
Warning: /Stage[main]/Basic/File[comments-plugin]: Skipping because of failed dependencies

This got xz compression error. I'll clean yum cache and give it another try:

[root@puppet6 ~]$ yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras puppetlabs-deps puppetlabs-products updates
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@puppet6 ~]$ puppet agent -t
.
.
.
Notice: /Stage[main]/Basic/Package[bash-completion]/ensure: created
Notice: /Stage[main]/Basic/Package[vim-enhanced]/ensure: created
Notice: /Stage[main]/Basic/File[vim-config]/content:
Notice: /Stage[main]/Basic/File[vim-config]/content: content changed '{md5}a350a86ba75d8da0d3ae5ad4d49ce60d' to '{md5}2d932152e2a2659805bfda707b909605'
Notice: /Stage[main]/Basic/File[/root/.vim]/ensure: created
Notice: /Stage[main]/Basic/Package[telnet]/ensure: created
Notice: /Stage[main]/Basic/File[/root/.vim/plugin]/ensure: created
Notice: /Stage[main]/Basic/File[comments-plugin]/ensure: defined content as '{md5}83925d5459bb4e033f2773ee3d4fd85e'
Notice: Finished catalog run in 53.66 seconds

Next time I'll look at Centos 5. Nope. On Centos 5 it is working same as on Centos 6.

No comments:

Post a Comment