Thursday, October 24, 2024
Almalinux Centos Chef Redhat 8 Rocky Linux

Cara Install Chef Infra pada AlmaLinux / CentOS 8 / Rocky Linux / Redhat 8

chef

“Cara Install Chef Infra pada AlmaLinux / CentOS 8 / Rocky Linux / Redhat 8”

Pengantar

Chef infra adalah salah satu alat Infrastruktur sumber terbuka sebagai Kode (IAC) populer yang digunakan dalam konfigurasi, administrasi, dan penyebaran sumber daya server di seluruh jaringan. CHEF ditulis dalam bahasa Ruby dan Erlang dan didistribusikan di bawah Lisensi Apache 2.0.

Chef architecture

Persiapan

On all the 3 servers

sudo hostnamectl set-hostname chef-server.example.com --static

sudo dnf -y install git vim wget curl bash-completion
sudo dnf -y update
sudo reboot

Setting NTP

sudo dnf install chrony -y
sudo systemctl start chronyd
sudo systemctl enable chronyd

Install Chef Infra

  • install wget
sudo yum -y install wget
wget https://packages.chef.io/files/stable/chef-server/${VER}/el/8/chef-server-core-${VER}-1.el7.x86_64.rpm
  • Install chef
dnf localinstall chef-server-core-${VER}-1.el7.x86_64.rpm
  • Configurasi Chef
sudo chef-server-ctl reconfigure

Setting Firewall

sudo firewall-cmd --permanent --add-service={http,https}
sudo firewall-cmd --reload

Buat Admin User

  • Buat admin
chef-server-ctl user create USERNAME FIRST_NAME [MIDDLE_NAME] LAST_NAME EMAIL PASSWORD
USERNAME="chefadmin"
FIRST_NAME="Chef"
LAST_NAME="Administrator"
EMAIL="chefadmin@games.com"
PASSWORD="Passw0rd"
KEY_PATH="/root/chefadmin.pem"
sudo chef-server-ctl user-create ${USERNAME} ${FIRST_NAME} ${LAST_NAME} ${EMAIL} ${PASSWORD} -f ${KEY_PATH}
  • Cek list User
sudo chef-server-ctl user-list
  • Buat Organisasi
sudo chef-server-ctl org-create techviewleo 'Techviewleo, Inc.' \
--association_user chefadmin \
--filename /root/techviewleo-validator.pem
  • Cek list organisasi
$ sudo chef-server-ctl org-list
  • Cek RSA key
sudo find /root -name "*.pem"
  • Install Chef Manage
sudo chef-server-ctl install chef-manage 
sudo chef-server-ctl reconfigure 
sudo chef-manage-ctl reconfigure
 https://serverip/login

Install Chef Workstation

  • Download chef workstation
wget https://packages.chef.io/files/stable/chef-workstation/${VER}/el/8/chef-workstation-${VER}-1.el8.x86_64.rpm
  • Install
sudo yum localinstall chef-workstation-${VER}-1.el8.x86_64.rpm
  • Cek version
chef --version
knife --version
  • Buat chef repo
chef generate repo chef-repo
  • buat directory
mkdir ~/chef-repo/.chef
cd chef-repo
  • Buat RSA key
ssh-keygen -b 4096
  • Upload public key ke chef server
ssh-copy-id root@192.168.205.2
  • copy perm ke chef workstation
scp root@192.168.205.2:/root/*.pem ~/chef-repo/.chef/
  • generate Chef cookbook
chef generate cookbook chef-first-cookbook

Configure Knife dan Bootstrap a Client Node

Pada Workstation node

  • edit file
nano ~/chef-repo/.chef/config.rb
current_dir = File.dirname(__FILE__)
log_level                :info
log_location             STDOUT
node_name                'chefadmin'
client_key               "chefadmin.pem"
validation_client_name   'techviewleo-validator'
validation_key           "techviewleo-validator.pem"
chef_server_url          'https://chef-server.example.com/organizations/techviewleo'
cache_type               'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path            ["#{current_dir}/../cookbooks"]
cd ~/chef-repo
 knife ssl fetch
cd ~/chef-repo/.chef
knife bootstrap 192.168.205.13 -x root -P ***** --node-name chef-client-node
  • cek node
knife node show chef-client-node
  • cek dashboard

Penutup

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai Cara Install Chef Infra pada AlmaLinux / CentOS 8 / Rocky Linux / Redhat 8 . Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

(Visited 623 times, 1 visits today)

Similar Posts