Ansible Core Yum Update RHEL

Scenario: Patching run yum update using Ansible to RHEL 6/7 remote machine
System: RHEL 7, Ansible 2.6 (Callback and ansible log is active)
Remote System: RHEL 6/7 (not using ssh key), same root password.

Example yum update host group devservers, here my steps:
1) Empty ansible log.
# cat /dev/null > /var/log/ansible.log

2) Input hosts devservers in /etc/ansible/hosts
# vi /etc/ansible/hosts

[devservers]
192.168.99.18
192.168.99.19

Continue reading

Configure Samba File Sharing AD Auth on RHEL/CentOS 7

Scenario: How to configure file sharing using samba with AD authentification on CentOS/RHEL 7
System:
– CentOS/RHEL 7, IP address: 192.168.99.15, hostname: centos7ht
– Windows Server 2012 as AD Domain: toya.toyaseta.com, IP address: 192.168.99.10, also as DNS server.

Steps as root login:
1) Point cetos7ht DNS server to AD server and edit /etc/hosts
– Edit /etc/hosts.
# vi /etc/hosts

192.168.99.10 toya.toyaseta.com toya

– Edit DNS /etc/resolv.conf
# vi /etc/resolv.conf

# Generated by NetworkManager
search toya.toyaseta.com
nameserver 192.168.99.10
nameserver 192.168.99.1

Continue reading

Bash script to get list of local users on Linux

Scenario: How to get the list of normal users and System users in Linux.
System : CentOS/RHEL 6/7

Steps:
1) Login as local users (work without login to root), example I login as bachem.
2) Create the bash script file with file name listusers.sh
$ vi /home/bachem/listusers.sh
Continue reading

How to add sudo user on CentOS 7

Scenario: add sudo user on CentOS 7
System: CentOS 7

Steps to Create a New Sudo User
– Log in to your server as the root user.
– Use the adduser command to add a new user to your system,example add user with username bachem.

[root@horse ~]# useradd bachem
[root@horse ~]# passwd bachem
Changing password for user bachem.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@horse ~]#

Continue reading

Limit memory usage per user on CentOS/RHEL

Scenario: How to limit memory usage per user on CentOS/RHEL
System: CentOS/RHEL 6/7

I would like to cap the amount of memory the users on a server can use. The applications developed by our users have memory leaks and I want to prevent them from using all the memory and crashing the system.

Resolution
It is possible to limit the amount of memory that each process can allocate with the RLIMIT facility in Red Hat Enterprise Linux. RLIMIT_AS limits the size of the virtual address space and it is a suitable solution in many cases which require limiting per-process memory consumption even though there are many limits related to memory.
Continue reading

Using Ansible Callback

Scenario: Set up Ansible callback to monitor running task on remote machine.
Ansible system: CentOS 7, Ansible 2.6
Remote machines:
Both have same root password
1. CentOS 7, ip address: 192.168.99.18
2. CentOS 6, ip address: 192.168.99.19

I set up callback plugins to see running ansible-playbook task on remote machine and it is fun and useful.
To set up callback, edit /etc/ansible/ansible.cfg and change the value to minimal.

# vi /etc/ansible/ansible.cfg

stdout_callback = minimal

Continue reading