Monday, 10 July 2017

Glimpse on Systemd: A Modern Service Manager for Linux


  • Systemd is a system and service manager for Linux operating systems. It is designed to be backwards compatible with SysV init scripts, and provides a number of features such as parallel startup of system services at boot time, on-demand activation of daemons, support for system state snapshots, or dependency-based service control logic. It may refer to all the packages, utilities and libraries around daemon.
  • Systemd was designed to overcome the shortcomings of init and itself is a background processes which is designed to start processes in parallel, thus reducing the boot time and computational overhead. It has a lot other features as compared to init.
Why there was a need to replace init?
  • A init process starts serially i.e., one task starts only after the last task startup was successful and it was loaded in the memory. This often resulted into delayed and long booting time. However, systemd was not designed for speed but for getting the things done neatly which in turns avoid all the UN-necessary delay.

Systemd_cheatsheet:




Thanks to tecmint for made such a clarity post on init and systemd concepts.

Tuesday, 4 July 2017

Steps to install pssh on CentOS7:

Here are the simple steps for the installation of pssh on CentOS7:

pssh is a program for executing ssh in parallel on a number of hosts. It provides features such as sending input to all of the processes, passing a password to ssh, saving output to files, and timing out.

Install epel:

# yum install epel-release

Install pssh:

# yum install pssh

create pssh_hosts.txt file and enter the hosts need to target:

# cat pssh_hosts.txt
# write hosts per line like follows
#user@target_ip
root@192.168.100.100

we should do key-pair between the master host and targets, this is the only way to get things done.(simply login the target from master node for Host key verification)

# ssh root@192.168.100.100

Test with single commands

# pssh -h /path/to/pssh_hosts.txt -A -O PreferredAuthentications=password -i "hostname"
# pssh -h /path/to/pssh_hosts.txt -A -O PreferredAuthentications=password -i "uptime"

Output:

[root@master pssh]# pssh -h ./pssh_hosts.txt -A -O PreferredAuthentications=password -i "uptime"
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password:
[1] 16:27:59 [SUCCESS] root@192.168.100.100
21:27:57 up 1 day,  1:30,  1 user,  load average: 0.00, 0.01, 0.05

To executes scripts on the target machines:


# cat pssh/tst.sh
#!/bin/bash
touch /root/CX && echo "File created"

# pssh -h ./pssh_hosts.txt -A -O PreferredAuthentications=password -I<./tst.sh

make it simple:

# pssh -H '192.168.100.101' -l 'root' -A -O PreferredAuthentications=password -I< ./tst.sh

Output:

[root@master pssh]# pssh -H '192.168.100.101' -l 'root' -A -O PreferredAuthentications=password -I< ./tst.sh
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password:
[1] 16:24:30 [SUCCESS] 192.168.100.101

To execute commands without password prompting, we need to create key-pair between the servers.


Creating key pair:

We are trying to attempt login serverB from serverA

Create SSH-Kegen Keys on serverA:

# ssh-keygen -t rsa

Copy the 'id_rsa.pub' file from serverA to master serverB:

# ssh-copy-id root@<serverB-ip>

Now try logging into the machine, with:   "ssh 'root@serverB-IP'"
and check to make sure that only the key(s) you wanted were added.

(or)

# cat .ssh/id_rsa.pub | ssh root@<serverB-ip> 'cat >> .ssh/authorized_keys'

Now try to login the serverB from serverA:

# ssh root@serverB-IP

Output:

Last login: d.a.t.e a.n.d t.i.m.e from serverA-ip

Okay, Lets try the commands without password:


Through pssh_hosts.txt file:

# pssh -h '/path/to/pssh_hosts.txt' -i 'hostname'
[1] 13:27:56 [SUCCESS] root@192.168.100.100
Master

For single host:

# pssh -H '192.168.100.101' -i 'hostname'
[1] 13:31:16 [SUCCESS] 192.168.100.101
master

Well, executing script this time,

Through pssh_hosts.txt file:

# pssh -h '/root/pssh/pssh_hosts.txt' -I<./tst.sh
[1] 13:32:23 [SUCCESS] root@192.168.100.100

For single host:

# pssh -H '192.168.100.101' -I<./tst.sh
[1] 13:33:42 [SUCCESS] 192.168.100.101

Thanks.

Wednesday, 28 June 2017

A Step by Step Guide to install rundeck on ubuntu 17.04(zesty):


Here is a Step by Step Guide to install rundeck on ubuntu 17.04(zesty):


As we know 'Rundeck is open source software that helps you automate routine operational procedures in data center or cloud environments, it allows you to run tasks on any number of nodes from a web-based or command-line interface.' from the previous post Rundeck installation on CentOS.

I'm installing rundeck on ubuntu 17.04(zesty)(my server ip is: 192.168.225.231)

pre-requirements:


Installing java:

# apt-get install openjdk-8-jdk

A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)


Setting up java home:

Add the below contents in file: /etc/profile.d/java.sh
#!/bin/bash
JAVA_HOME=/usr/bin/java
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME
export CLASSPATH=.


# source /etc/profile.d/java.sh

A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)

Firewall setup:

We can enable the ufw and allow port 4440.


A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)

Let us download the rundeck package(.deb) from: http://rundeck.org/downloads.html


A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)

we can start the rundeck installation:

# dpkg -i rundeck-2.8.2-1-GA.deb


A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)

post-installation steps:

Comment out the following line in file: /etc/rundeck/rundeck-config.properties

# Comment this out from:
grails.serverURL=http://localhost:4440

# To:
# grails.serverURL=http://localhost:4440


Modify the below lines in file: /etc/rundeck/framework.properties

framework.server.name = localhost
framework.server.hostname = localhost
framework.server.port = 4440
framework.server.url = http://localhost:4440

to

framework.server.name = 192.168.225.231
framework.server.hostname = 192.168.225.231
framework.server.port = 4440
framework.server.url = http://192.168.225.231:4440


We can enable the rundeckd service, so that it will automatically start on boot

# systemctl enable rundeckd



A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)

Also we can use below commands to,

stop rundeck:

# systemctl stop rundeckd

start rundeck:

# systemctl start rundeckd

restart rundeck:

# systemctl restart rundeckd

status rundeck:

# systemctl status rundeckd

Server has been restarted to update the changes, now the rundeck service also up and running.


A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)

try to reach the rundeck by accessing: http://your-server-ip:4440 http://192.168.225.231:4440


A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)

Username: admin
Password: admin


A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)


created test project(ranjith-test) and you can see the rundeck server node listed on the page.

A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)

Server node details:

A Step by Step Guide to install rundeck on ubuntu 17.04(zesty)


Thanks.

Monday, 19 June 2017

5 Easy Steps to Install Rundeck on CentOS

Rundeck is all about ....!


Well, Rundeck is open source software that helps you automate routine operational procedures in data center or cloud environments, it allows you to run tasks on any number of nodes from a web-based or command-line interface.

Rundeck also includes other features that make it easy to scale up your automation efforts including: access control, workflow building, scheduling, logging, and integration with external sources for node and option data. Refer introduction and essential-concepts URL for more details.

Pre-requirements and preparing the server to install rundeck:


The following operating systems are known to support Rundeck:

  • Linux: Most recent distributions are likely to work
  • Windows: XP, Server and above
  • Mac OS X 10.4 or later 
     
Root (or Administrator on Windows) is not required or recommended. We recommend using a dedicated user account such as "rundeck". If there is need for root access, please set up the Rundeck user to have access via sudo.

step1 - Install java:


java JDK must be installed. Install any JDK that is 1.7+.

# yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel -y

Add the below contents into file: /etc/profile.d/java.sh
#!/bin/bash
JAVA_HOME=/usr/bin/java
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME
export CLASSPATH=.

# source /etc/profile.d/java.sh


Install Rundeck on CentOS

step2 - Network access:

Add below line into file: /etc/sysconfig/iptables

-A INPUT -p tcp -m state --state NEW -m tcp --dport 4440 -j ACCEPT

# /etc/init.d/iptables restart

Step 3 - Installing with RPM...:


The latest install documentation is available at http://rundeck.org/downloads.html, To install it using yum, first install the yum repo package and then run yum install:


# yum install rundeck

# /etc/init.d/rundeckd start

Install Rundeck on CentOS

Install Rundeck on CentOS


Install Rundeck on CentOS

Post installation steps:

To make sure the service is running:

When the server starts, it binds to several TCP ports by default:

# /etc/init.d/rundeckd status

# netstat -anp | grep '4440\|4443'


Install Rundeck on CentOS


The default username and password is admin:admin, if you want to change the password for admin user then edit the file: /etc/rundeck/realm.properties

Install Rundeck on CentOS

 step 4 - Comment out the following line in file: /etc/rundeck/rundeck-config.properties

# Comment this out from:
grails.serverURL=http://localhost:4440

# To:
# grails.serverURL=http://localhost:4440

step 5 - Modify the below lines in file: /etc/rundeck/framework.properties(this might prevent the redirect to localhost issue after login).

framework.server.name = localhost
framework.server.hostname = localhost
framework.server.port = 4440
framework.server.url = http://localhost:4440

to

framework.server.name = <your-server-ip>
framework.server.hostname = <your-server-ip>
framework.server.port = 4440
framework.server.url = http://<your-server-ip>:4440

Install Rundeck on CentOS

Now, lets restart the service and try to login:

Install Rundeck on CentOS

Install Rundeck on CentOS


Install Rundeck on CentOS

Install Rundeck on CentOS