Featured Post

Directory environments in Puppet

Environments are individual groups of Puppet agents each environment have there own completely different manifests and module-paths. This basically is useful for testing changes to our Puppet code before implementing them on production machines. There are two types of implementation of environments structure in Puppet one if directory based and another is config file based here we will see bit of an insight about directory based. As usual for more information about this you can visit puppetlabs official website. On the master node: Append following details in puppet.conf which is placed under /etc/puppet or /etc/puppetlabs/puppet:     Under [main] section add a variable called confdir with value as /etc/puppet or /etc/puppetlabs/puppet     confdir=/etc/puppet Then add information regarding environments/manifests and modulepath in it.      #environments     environmentpath = $confdir/environments     default_manfiest = $confdir/manifests     basemodulepath =

Un-revoke the revoked certificate in Puppet

If you revoked or deleted the puppet agent’s certificate accidentally.

Basically it is nearly impossible un-revoke a certificate.

  • The solution is to recover all revoked certificates then revoke other certificates which don’t need to be recovered. But if in-case you have thousands of revoked certificates then its a bit lengthy process.
  • Second one is to generate a new certificate for the client/agent and get that signed by the puppet master. 
List of all the certificates which are signed at the moment:

 [root@puppet requests]# puppet cert list --all
+ "fedora20"            (AE:57:40:F6:FC:E1:CD:DD:ED:EE:1E:8C:A7:81:0D:76)
+ "kubuntu14.sunny.com" (20:6B:A1:E2:A3:DE:B1:95:C8:80:4C:B4:27:2B:C0:A2)
+ "puppet.sunny.com"    (68:12:76:3C:D0:F8:0D:2D:8B:2B:40:E7:49:2D:55:5B) (alt names: "DNS:puppet", "DNS:puppet.sunny.com")
+ "rhel6.sunny.com"     (DC:6E:B1:FC:27:1D:7A:2A:85:E7:3E:3A:24:8B:64:D3)
[root@puppet requests]#


Now you want to revoke[or did accidentally] rhel6.sunny.com you can do that by the help of clean option

[root@puppet requests]#   puppet cert clean rhel6.sunny.com
notice: Revoked certificate with serial 14
notice: Removing file Puppet::SSL::Certificate rhel6.sunny.com at '/var/lib/puppet/ssl/ca/signed/rhel6.sunny.com.pem'
notice: Removing file Puppet::SSL::Certificate rhel6.sunny.com at '/var/lib/puppet/ssl/certs/rhel6.sunny.com.pem'
[root@puppet requests]#


Now if the agent wants to connect to the master it will throw a error as "SSL_connect returned=1 errno=0 state=SSLv3 read server session ticket A: sslv3 alert certificate revoked".

To get this working again what you can do is??

Firstly check where the certificate is located in the agent node.

[root@rhel6 ~]# puppet --genconfig | grep certdir
    certdir = /var/lib/puppet/ssl/certs
    # The default value is '$certdir/$certname.pem'.
    # The default value is '$certdir/ca.pem'.
[root@rhel6 ~]#


So its there in /var/lib/puppet/ssl/ directory.

Remove each and everything from this directory [on the agent node].

[root@rhel6 ssl]# pwd
/var/lib/puppet/ssl
[root@rhel6 ssl]# rm -rf *
[root@rhel6 ssl]#


Run puppet agent --test to create a new certificate on the agent side so that it can be signed again by the puppet master.

[root@rhel6 ssl]# puppet agent --test
info: Creating a new SSL key for rhel6.sunny.com
info: Caching certificate for ca
info: Creating a new SSL certificate request for rhel6.sunny.com
info: Certificate Request fingerprint (md5): 60:B9:2F:99:5C:A7:5E:81:8C:3A:65:F6:02:5A:69:92
Exiting; no certificate found and waitforcert is disabled
[root@rhel6 ssl]#


Go to the puppet master to check if the agent has requested any certificate or not.

[root@puppet requests]# puppet cert list
  "rhel6.sunny.com" (60:B9:2F:99:5C:A7:5E:81:8C:3A:65:F6:02:5A:69:92)
[root@puppet requests]#


Yups its there, now get the certificate signed.

[root@puppet requests]# puppet cert --sign rhel6.sunny.com
notice: Signed certificate request for rhel6.sunny.com
notice: Removing file Puppet::SSL::CertificateRequest rhel6.sunny.com at '/var/lib/puppet/ssl/ca/requests/rhel6.sunny.com.pem'
[root@puppet requests]# 


Now the certificate is signed, lets now try to run the puppet agent --test command on the agent side and check if our ssl issue has been resolved or not.

[root@rhel6 ssl]# puppet agent --test
info: Caching certificate for rhel6.sunny.com
info: Caching certificate_revocation_list for ca
info: Caching catalog for rhel6.sunny.com
info: Applying configuration version '1410275402'
notice: Finished catalog run in 0.35 seconds
[root@rhel6 ssl]#


Comments

Popular posts from this blog

Exec in Puppet

Dry run in Puppet --noop