Chef Server Installation and Configuration in Centos 7
Prerequisite
Get a 64 Bit CENTOS VM
An x86_64 compatible system architecture; Red Hat Enterprise Linux and CentOS may require updates prior to installation
A resolvable hostname that is specified using a FQDN or an IP address
A connection to Network Time Protocol (NTP) to prevent clock drift
A local mail transfer agent that allows the Chef server to send email notifications
Using cron and the /etc/cron.d directory for periodic maintenance tasks
Disabling the Apache Qpid daemon on CentOS and Red Hat systems
Setup a hostname by editing a /etc/hosts
sudo vi /etc/hosts
Modify the line #1 from
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
To
127.0.1.1 192.168.43.144 chef-server
127.0.0.1 localhost
192.168.43.144 192.168.43.144 chef-server
and, you /etc/hosts file should look like somthing like this...
127.0.1.1 192.168.43.144 chef-server
127.0.0.1 localhost
192.168.43.144 192.168.43.144 chef-server
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Setup a hostname
$ hostnamectl set-hostname chef-server
Restart your networking service
$ service network restart
Verify the hostname using following commands.
$ hostname
$ hostname -f
Verify the hostname using following commands.
$ hostname
Run the yum update
$ sudo yum update
Download
Please download the package from https://downloads.chef.io/chef-server/redhat/.
$ cd /opt
$ yum install wget -y
$ wget https://packages.chef.io/files/stable/chef-server/12.17.33/el/7/chef-server-core-12.17.33-1.el7.x86_64.rpm
# Chef Server Can be downloaed from https://downloads.chef.io/chef-server
Installation
Please locate the rpm package and run the following commands.
$ rpm -Uvh chef-server-core-12.17.33-1.el7.x86_64.rpm
Configuration
Run the following commands to configured the chef server
$ chef-server-ctl reconfigure
Status Verification
Run the following commands to verify the chef server installation and configuration.
$ chef-server-ctl status
# ================== OUTPUT =========================
[root@ip-10-0-0-195 opt]# chef-server-ctl status
run: bookshelf: (pid 4832) 82s; run: log: (pid 4858) 82s
run: nginx: (pid 4647) 86s; run: log: (pid 5226) 78s
run: oc_bifrost: (pid 4552) 88s; run: log: (pid 4630) 87s
run: oc_id: (pid 4634) 87s; run: log: (pid 4641) 86s
run: opscode-erchef: (pid 5059) 80s; run: log: (pid 4998) 81s
run: opscode-expander: (pid 4714) 83s; run: log: (pid 4779) 83s
run: opscode-solr4: (pid 4683) 84s; run: log: (pid 4700) 84s
run: postgresql: (pid 4497) 89s; run: log: (pid 4533) 88s
run: rabbitmq: (pid 5507) 73s; run: log: (pid 5235) 78s
run: redis_lb: (pid 29615) 224s; run: log: (pid 5222) 78s
[root@ip-10-0-0-195 opt]#
Creating first Chef Administrator using command line
Run the following commands to verify the chef server installation and configuration.
$ cd /opt
$ mkdir .chef
$ chef-server-ctl user-create USER_NAME FIRST_NAME LAST_NAME EMAIL 'PASSWORD' --filename ~/.chef/username.pem
exmaple
$ chef-server-ctl user-create rajeshkumar Rajesh Kumar devops@RajeshKumar.xyz 'password123' --filename rajeshkumar.pem
$ chef-server-ctl user-list
pivotal
rajeshkumar
Creating Chef organization
Run the following commands to verify the chef server installation and configuration.
$ chef-server-ctl org-create short_name 'full_organization_name' --association_user user_name --filename ORGANIZATION-validator.pem
short_name should be in normal case.
example
$ chef-server-ctl org-create 4thcoffee 'Fourth Coffee, Inc.' --association_user stevedanno --filename /path/to/4thcoffee-validator.pem
$ chef-server-ctl org-list
scm2galaxy
Install Chef Manage
The Chef management console enables the management of nodes, data bags, roles, environments, and cookbooks by using a web user interface. In addition, access to nodes, data bags, roles, environments, and cookbooks is configurable using role-based access control (RBAC).
$ chef-server-ctl install help
help does not appear to be a valid addon name. Valid names include: chef-ha, chef-manage, opscode-push-jobs-server, opscode-reporting.
# List of Chef Supported Addon - chef-ha, chef-manage, opscode-push-jobs-server, opscode-reporting
$ chef-server-ctl install chef-manage
then;
$ chef-server-ctl reconfigure
and then;
$ chef-manage-ctl reconfigure
or;
$ chef-manage-ctl reconfigure --accept-license
Verify chef server installation
$ sudo chef-server-ctl test
How to Access over the browsers
Stop the firewall for temporary to check the installation. Later you can up the firewall and add the 80 port in the exceptions.
$ systemctl stop firewalld
Browse a website using http://localhost or http://ipaddress
Some useful commands
Check the chef server each componnent running status.
$ chef-server-ctl status
List the all the services in Chef Server
$ chef-server-ctl service-list
The tail subcommand is used to follow all of the Chef server logs for all services. This command can also be run for an individual service by specifying the name of the service in the command.
$ chef-server-ctl tail SERVICE_NAME
Some important directories
/opt/chef-server – The installation from the package is here.
/etc/chef-server – The API specific configuration files and keys are here.
/var/opt/chef-server – The dependent services such as RabbitMQ, Nginx and so on are here, including the PostgreSQL database, SOLR indexes.
/var/log/chef-server – All the runit services write their output here.
Chef Server Configuration file location
/etc/chef-server/chef-server.rb
/etc/chef/client.rb
~/.chef/knife.rb
Reference
1. https://docs.chef.io/ctl_chef_server.html
2. https://www.digitalocean.com/community/tutorials/how-to-set-up-a-chef-12-configuration-management-system-on-ubuntu-14-04-servers
3. https://docs.chef.io/install_server.html
4. https://www.youtube.com/watch?v=egvEPsVMfK0