puppet
Linux

10 most used puppet commands on Linux

We have already seen how to install puppet on CentOS 7 / RHEL 7, in this article we will list the 10 most used puppet commands.

Check the puppet version :

[root@puppet-master ~]# /opt/puppetlabs/bin/puppet --version
4.10.12

Troubleshoot puppet agent connection :

[root@puppet-agent ~]# puppet agent -t --DEBUG
Debug: Applying settings catalog for sections main, agent, ssl
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Using settings: adding file resource 'confdir': 'File[/etc/puppetlabs/puppet]{:path=>"/etc/puppetlabs/puppet", :ensure=>:directory, :loglevel=>:debug, :links=>:follow, :backup=>false}'
Debug: Using settings: adding file resource 'codedir': 'File[/etc/puppetlabs/code]{:path=>"/etc/puppetlabs/code", :ensure=>:directory, :loglevel=>:debug, :links=>:follow, :backup=>false}'
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Failed to load library 'cfpropertylist' for feature 'cfpropertylist'
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Facter: searching for custom fact "operatingsystem".
Debug: Facter: searching for operatingsystem.rb in /opt/puppetlabs/puppet/cache/lib/facter.
Debug: Facter: searching for operatingsystem.rb in /opt/puppetlabs/puppet/cache/facts.
Debug: Facter: searching for operatingsystem.rb in /opt/puppetlabs/puppet/cache/lib/facter.
Debug: Facter: searching for operatingsystem.rb in /opt/puppetlabs/puppet/cache/facts.

If there are any issues you will get a message like below :

[root@puppet-master ~]# /opt/puppetlabs/bin/puppet agent -t --DEBUG
Debug: Applying settings catalog for sections main, agent, ssl
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Using settings: adding file resource 'confdir': 'File[/etc/puppetlabs/puppet]{:path=>"/etc/puppetlabs/puppet", :ensure=>:directory, :loglevel=>:debug, :links=>:follow, :backup=>false}'
Debug: Using settings: adding file resource 'codedir': 'File[/etc/puppetlabs/code]{:path=>"/etc/puppetlabs/code", :ensure=>:directory, :loglevel=>:debug, :links=>:follow, :backup=>false}'
.
.
.
.
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Could not find node statement with name 'default' or 'puppet-master, puppet-master.localdomain' on node puppet-master
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Debug: Dynamically-bound server lookup failed, falling back to report_server setting
Debug: Dynamically-bound port lookup failed; falling back to report_port setting

How to force synchronization :

Instead of respecting the « run interval » time, all updates can be performed manually using the command below :

[root@puppet-agent ~]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for puppet-agent
Info: Applying configuration version '1619614488'
Notice: Applied catalog in 0.14 seconds

Display pending certificate signing requests :

[root@puppet-master ~]# puppet cert list
"puppet-agent" (SHA256) 1F:6C:C2:57:5B:4A:B9:0B:68:E3:4C:BD:1B:44:69:2F:59:3E:72:1B:E8:EF:9B:4E:F0:DA:1E:00:F4:13:D7:F9

Delete a pending certificate :

[root@puppet-master ~]# puppet cert clean puppet-agent

Sign the certificate of a puppet agent:

[root@puppet-master ~]# puppet cert sign puppet-agent
Signing Certificate Request for:
"puppet-agent" (SHA256) 1F:6C:C2:57:5B:4A:B9:0B:68:E3:4C:BD:1B:44:69:2F:59:3E:72:1B:E8:EF:9B:4E:F0:DA:1E:00:F4:13:D7:F9
Notice: Signed certificate request for puppet-agent
Notice: Removing file Puppet::SSL::CertificateRequest puppet-agent at '/etc/puppetlabs/puppet/ssl/ca/requests/puppet-agent.pem'

List the modules installed :

[root@puppet-master ~]# puppet module list
/etc/puppetlabs/code/environments/production/modules
├── dalen-dnsquery (v3.0.0)
├── jgazeley-nagios (v0.4.0)
├── puppet-selinux (v1.6.1)
├── puppetlabs-apache (v1.3.0)
├── puppetlabs-concat (v4.2.1)
├── puppetlabs-firewall (v1.15.3)
├── puppetlabs-stdlib (v4.25.1)
├── puppetlabs-vcsrepo (v2.4.0)
├── saz-sudo (v4.2.0)
└── stahnma-epel (v1.3.1)
/etc/puppetlabs/code/modules (no modules installed)
/opt/puppetlabs/puppet/modules (no modules installed)

Install a module :

[root@puppet-master ~]# puppet module install garethr-docker
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
└─┬ garethr-docker (v5.3.0)
├── puppetlabs-apt (v3.0.0)
├── puppetlabs-stdlib (v4.25.1)
└── stahnma-epel (v1.3.1)

Find a module :

[root@puppet-master ~]# puppet module search docker
Notice: Searching https://forgeapi.puppet.com …

Uninstall a module :

[root@puppet-master ~]# puppet module uninstall garethr-docker
Notice: Preparing to uninstall 'garethr-docker' …
Removed 'garethr-docker' (v5.3.0) from /etc/puppetlabs/code/environments/production/modules

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *