Bootstrap a Node 2 and Deploy Apache Web Server

Share via:

Bootstrap a Node 2 and Deploy Apache Web Server

In this article,we will see Bootstrap a Node 2 and Deploy Apache Web Server.

Implementation Steps

Bootstrap a Node 2

  1. Check Availability Zone of your workstation.
  2. Create a Node “Chef-Node-1” by launching instance.
  3. Open your workstation Linux terminal through putty.
  4. Switch to root user.
  5. Go to chef-repo.
  6. Run bootstrap command to bootstrap a node 2.
  7. Verify bootstrap nodes.

Deploy an Apache Web Server

  1. Attach recipe “ktexperts-apache-recipe’rb” to node “ktexperts-node 2”.
  2. Verify recipe in run list.
  3. Connect to node 2 “Chef-Node-2” Linux Terminal through putty.
  4. Switch to root user.
  5. Open “crontab” file inside the /etc directory and write script to run automatically.
  6. Run chef-client.
  7. Verify the content of node 2 “Chef-Node-2”.
  8. Modify recipe “ktexperts-apache-recipe.rb”.
  9. Upload cookbook to chef server.
  10. Verify the content of node 1 “Chef-Node-1”.

Check Availability Zone of your workstation

we can see the Availability Zone “ap-south-1a” of your workstation.

Note

Workstation is in ap-south-1a AZ.

we create a node in the same Availability Zone “ap-south-1a”.

we need to open SSH and HTTP ports.

Create a Node “Chef-Node-2” 

Launch Linux EC2 Instance

Check below link to Launch Linux EC2 Instance.

Launch Linux EC2 Instance

We can see the node  “Chef-Node-2” which was created earlier.

Open your workstation Linux terminal through putty

Using username “ec2-user”. Authenticating with public key “imported-openssh-key” Last login: Fri Dec 27 09:02:29 2019 from 124.123.103.5 __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/

Switch to root user

[ec2-user@ip-172-31-42-243 ~]$ sudo su [root@ip-172-31-42-243 ec2-user]#

Go to chef-repo 

[root@ip-172-31-42-243 ec2-user]# cd chef-repo/ [root@ip-172-31-42-243 chef-repo]#

Run bootstrap command to bootstrap a node 2

we need specify private IP key file of chef-node-1 in bootstrap command.

Copy private IP of chef-node-2

Specify username,private IP(chef-node-2) and pem key “chef.pem” (chef-node-2) in the bootstrap command.

Note

Two actions will be done while bootstrapping.

Adding node to chef server.

Installing chef package.

 Verify bootstrap nodes

To the bootstrap nodes

The ktexperts-node2 has added to chef server successfully.

 

Deploy an Apache Web Server

We have already uploaded the recipe to chef server.

Attach recipe “ktexperts-apache-recipe’rb” to node “ktexperts-node 2”

Verify recipe in run list

Connect to node 2 “Chef-Node-2” Linux Terminal through putty

Switch to root user

 

Open “crontab” file inside the /etc directory and write script to run automatically

In the crontab file we set the time interval to run the chef-client depends on interval.

Note 

We have provide space in between stars.

Note

:wq! — to quit.

Run chef-client 

Note

Once run the chef-client in the node 1 then the node became a Apache Web Server.

Verify the content of node 2 “Chef-Node-2”

Copy the IPV4 Public IP of node 1″Chef-Node-2″

Search IPV4 Public IP in browserWe can able to see the content of node 1 “Chef-Node-2”

Modify recipe “ktexperts-apache-recipe.rb” 

 

Note

:wq! — to quit.

Upload cookbook to chef server

we can’t upload individual recipes so,we can upload cookbook that the recipe present inside the cookbook itself.

Verify the content of node 1 “Chef-Node-1”

Refresh IPV4 Public IP the browser

we can see the content has been modified successfully.

Thank you for giving your valuable time to read the above information.

Follow us on 

Website :  www.ktexperts.com

Facebook Page : KTexperts

Linkedin Page : KT EXPERTS

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading...

One thought on “Bootstrap a Node 2 and Deploy Apache Web Server

Add Comment