How to setup Puppet Master and Clients on Ubuntu 18.04 Server:
*****************************************************************************************************
This entire process has been divided into the following six parts.
1. Base server configuration.
2. Puppet repo configuration.
3. Puppet master configuration.
4. Puppet client configuration.
5. Initiating the Puppet Modules.
6. Module testing.
Assuming We having three Ubuntu systems with the following configurations:
1. One Ubuntu 18.04, 64 bit Server with 4+ Gib RAM, 4+ core processor, and 100 Gib HDD space.
2. Two or more Ubuntu 18.04, 64 bit Server/Desktop with 2+ Gib RAM, 2+ core processor and 100+ Gib HDD space.
Step 1.
Base server configuration.
First of all, we are going to set up a Puppet master server.
A. Configure Static IP :
Open file : /etc/netplan/50-cloud-init.yaml, and made it as follows:
# vim /etc/netplan/50-cloud-init.yaml
**********************************************************
network:
ethernets:
ens3:
addresses:
- (IP Address)/(Subnet)
dhcp4: false
gateway4: (Router IP)
nameservers:
addresses:
- 8.8.8.8
search: [your Domain Name]
version: 2
**********************************************************
Apply your changed IP in your system :
# netplan apply
B. Change the host name with FQDN
Open a file called:
/etc/cloud/cloud.cfg
and change preserve_hostname: false to preserve_hostname: true
Then Open file called
/etc/hosts
# vim /etc/hosts
and defien your FQDN along with the IP as well disable all IPV 6
**********************************************************
(your system IP) (your FQDN)
**********************************************************
Then open file called:
/etc/hostnameame
and define your FQDN here.
#vim /etc/hostnameame
**********************************************************
(your FQDN)
**********************************************************
Then change your FQDN as:
# hostnamectl set-hostname (your FQDN)
Reboot the system:
# init 6
Step 2.
Puppet repo configuration.
Add these repo to the file called : /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu bionic universe
deb http://archive.ubuntu.com/ubuntu bionic-security universe
deb http://archive.ubuntu.com/ubuntu bionic-updates univers
# vim /etc/apt/sources.list
**********************************************************
deb http://archive.ubuntu.com/ubuntu bionic main
deb http://archive.ubuntu.com/ubuntu bionic-security main
deb http://archive.ubuntu.com/ubuntu bionic-updates main
#######
deb http://archive.ubuntu.com/ubuntu bionic universe
deb http://archive.ubuntu.com/ubuntu bionic-security universe
deb http://archive.ubuntu.com/ubuntu bionic-updates universe
**********************************************************
Then update and upgrade your system:
# apt update && apt upgrade
Now Downlaod puppetlabs repo and install:
# wget https://apt.puppetlabs.com/puppet6-release-bionic.deb
Install above downloaded pack:
# dpkg -i puppet6-release-bionic.deb
Update & upgrade the system:
# apt update && apt upgrade
Step 3.
Puppet master server configuration:
Installing the puppet Master server
# apt-get install puppetserver
Allocate memory to puppet master server:
Open a file called: /etc/default/puppetserver and find the following line
JAVA_ARGS="-Xms2g -Xmx2g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger"
In above line Change -Xms2g -Xmx2g by -Xms1g -Xmx1g
Now open a file called: /etc/puppetlabs/puppet/puppet.conf and make it as follows:
# vim /etc/puppetlabs/puppet/puppet.conf
**********************************************************
[master]
vardir = /opt/puppetlabs/server/data/puppetserver
logdir = /var/log/puppetlabs/puppetserver
rundir = /var/run/puppetlabs/puppetserver
pidfile = /var/run/puppetlabs/puppetserver/puppetserver.pid
codedir = /etc/puppetlabs/code
dns_alt_names = (your system FQDN)
environment_timeout = 0
[main]
certname = (your system FQDN)
server = (your system FQDN)
environment = production
runinterval = 35m
**********************************************************
Again, open a file called: /etc/puppetlabs/code/environments/production/environment.conf and uncomment following line:
modulepath = ./modules:$basemodulepath
# vim /etc/puppetlabs/code/environments/production/environment.conf
**********************************************************
# Allowed settings and default values:
modulepath = ./modules:$basemodulepath
**********************************************************
Reboot the system:
# init 6
Step 4.
Puppet client configuration.
Follow above Step 1 and Step 2 in your Puppet server clients.
Then Install Puppet Agent in your Puppet client server:
# apt install puppet-agent
Now open a file called: /etc/puppetlabs/puppet/puppet.conf and edit as follows:
# vim /etc/puppetlabs/puppet/puppet.conf
**********************************************************
[main]
certname = (your puppet client FQDN)
server = (your puppet master FQDN)
environment = production
runinterval = 35m
**********************************************************
Reboot the system:
# init 6
Step 5.
Initiating the Puppet Modules.
Log in into your Puppet master system
Create CA for Puppet Master Server
# systemctl disable puppetserver
# systemctl stop puppetserver
# /opt/puppetlabs/bin/puppetserver ca setup
Start your puppet master server.
# systemctl start puppetserver
# systemctl enable puppetserver
Log in into your puppet client/s server/s and start your puppet agent
# systemctl start puppet
# systemctl enable puppet
Again Log in into your Puppet master system
Find the certificate signing request from puppet client/s
# /opt/puppetlabs/bin/puppetserver ca list
First time the output lookalike :
Requested Certificates:
(your puppet client FQDN)(SHA256) B9:A1:16:D2:7D:BD:12:44:A4:C8:15:16:7A:A5:88:A7:D1:2C:20:AD:16:C4:AE:04:1A:F8:11:A4:FF:B2:15:AD
Need to accept certificate signing request by your puppet master server
# /opt/puppetlabs/bin/puppetserver ca sign --certname (your puppet client FQDN as displayed in Requested Certificates)
Now log in into your puppet client/s system and put below command
# /opt/puppetlabs/bin/puppet agent -t
If the output are as mentioned below..... then all is good !
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for (your puppet client FQDN)
Info: Applying configuration version '1545417591'
Notice: Applied catalog in 0.14 seconds
Step 6.
Module testing.
In module testing, I am going to create
1. A file "ajay.txt"
2. Create a n user "karn"
in puppet client/s from my puppet master server.
For this, go to the directory :
/etc/puppetlabs/code/environments/production/manifests/ and create a file "nodes.pp".
# vim nodes.pp
**********************************************************
node '(your puppet client FQDN)' {
file { '/home/ajay/test.txt':
content => "This is a test file\n",
}
user { 'karn':
ensure => present,
home => '/home/karn',
managehome => true,
password => '$6$WNZOtHIQZEnok$q6.uPSlTqbrrzLdvi/5wTjgKVHP5TY06A5Yh7H4xS9STSHo0e.Tyqt2XLpca5Y7AV2H7q7SzQ/9z.NMfVm/H7.',
}
}
**********************************************************
For password, I used SHA1 password hash.
Log in to a system and use following command to create SHA1 password has
# mkpasswd -m sha-512
Now restart puppet master server:
# systemctl restart puppetserver
# systemctl enable puppetserver
Then log in to your puppet client server and run this command if want to execute module instantly, else it will auto execute after define time as in your puppet master server
# /opt/puppetlabs/bin/puppet agent -t
Now check the file and user in your puppet client.
Hoping... you can able to find both.
© Ajay Kumar Karn-2018-19
No comments:
Post a Comment