Posted on 1 Comment

Centos cluster IP resource in stopped state – pacemaker

When a two nodes pcs cluster is created without a stonith device the below error may appear when creating an IPaddr2 cluster resource. After the creation the resource cannot be brought online.

In order to resolve the issue stonith-enabled setting should be disabled. Afterwards the resource would become online as shown on the below screenshot.

Posted on 2 Comments

Manage Windows machines with Ansible (winrm)

Ansible is a very powerful automation tool that is developed from RedHat. Many large organizations rely on Ansible to automate tasks and procedures. In this article I will explain how one can use ansible to manage windows clients and servers.

In order to manage windows hosts ansible winrm plugin should be used to communicate with the client/server machine.

The first step is to verify that ansible is installed.

Alongside with ansible, on the control node the pywinrm module should be also installed. By default this one is not installed and one should do it manually.

The managed Windows client/server machines should be configured to allow remote connections. A very useful power shell script is already developed from other users and it needs only to be executed on the managed host.

If your execution policy is prohibiting this script to be executed, you should set-execution policy to RemoteSigned as shown below and then execute the powershell.

Control node should have network connectivity with the managed hosts.

Some environmental variables should be used, so that ansible knows how the connection will be performed (winrm). I included those variables in my inventory file as I created this lab just for demonstration. My inventory file looks like below:

[test_servers_group]
192.168.12.130

[all]
localhost
192.168.12.130

[all:vars]
ansible_winrm_server_cert_validation = ignore
ansible_connection = winrm
ansible_user = ansible
ansible_password =

Lastly make sure that the user that is used for the connection has administrative rights on the managed windows hosts. Otherwise some error codes will be returned.

Lastly confirm ansible on managed host is working by using win_ping module.

Documentation:

https://www.ansible.com/blog/connecting-to-a-windows-host

Posted on Leave a comment

Configure HAproxy to load balance Centos httpd containers

In this article I will explain a HAproxy installation on docker centos images. First things first, 3 centos images should be deployed. Two of them will be simple web servers with httpd installed and the third one will have haproxy installed to load balance between the two web servers.

In order to deploy 3 new centos docker images you should first download the latest centos image.

Just pull the Centos docker image from dockerHub by using the below command

docker pull centos

And then deploy 3 instances of it:

docker container run -it --name centos-lab1 -d centos:latest
docker container run -it --name centos-lab2 -d centos:latest
docker container run -it --name centos-lab3 -d centos:latest

Verify that containers have been deployed succesfully and execute some interactive commands on them.

docker exec -it centos-lab1 uname -r

You will get a result like the below, depending on the image you have installed.

4.19.76-linuxkit

Install httpd package on the two web servers. I am using portainer so that I can interact easier with containers. You could also execute an interactive command as shown below.

yum install httpd
docker exec -it centos-lab2 yum install httpd

Lastly you should install haproxy package for the third server that will be used as a load balancer.

yum install haproxy
[root@ad1d23c22355 /]# haproxy -v
HA-Proxy version 1.8.15 2018/12/13
Copyright 2000-2018 Willy Tarreau

Verify connectivity between your containers. Based on the default network that have been deployed on my computer I get the following 3 IP’s.

172.17.0.4 , 172.17.0.5 , 172.17.0.6

Install a test html page on web servers that will be used to identify the node.

echo "this is centos-lab1" > /var/www/html/index.html
echo "this is centos-lab2" > /var/www/html/index.html

Enable and start httpd server on web servers and test that their page is up and running by running a curl from load balancer (server 3). You will get a respond like the below:

apache is running and responding on web servers 1,2

In order to use systemctl and systemd commands, check my previous article about deploying a Centos Image with systemd enabled.

Edit haproxy configuration setting under /etc/haproxy/haproxy.cfg and add your two webservers as backend servers of app section.

haproxy configuration

Restart haproxy so that configuration changes are loaded:

systemctl restart haproxy

Curl loadbalancer and verify from the results that load is balanced between centos-1 and centos-2 webservers:

Posted on 1 Comment

Deploy a CentOS container image with systemd enabled

In order to deploy a CentOS container with systemd enabled to perform and use commands as systemctl you could do the following:

Download the official Centos image with systemd integrated from DockerHub and create a file name Dockerfile on your current working directory. The following dockerfile will install/enable httpd package with yum and systemctl.

FROM centos/systemd
MAINTAINER "Your Name" you@example.com
RUN yum -y install httpd; yum clean all; systemctl enable httpd.service
EXPOSE 80
CMD ["/usr/sbin/init"]

Build your image:

docker build --rm --no-cache -t centos-sd-1 .

And then deploy a new container from your created image:

docker run --privileged --name centos-sd-1 -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 -d centos-sd-1

Verify that you can run successfully systemd commands:

[root@179a5c228835 /]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2020-04-05 13:18:06 UTC; 9min ago
Docs: man:httpd(8)
man:apachectl(8)