Skip to content


putty, Xming and Linux GUI

The painless configuration procedure.

a. on the linux host where you want to run GUI

# yum -y install xauth

This is done so the ~/.Xauthority file can be created/used at your first login and any time after.

b. Configure “putty” session X11 options to “Enable X11 forwarding”, do not set “X11 display location” – leave the field blank, and set MIT-Magic-Cookie-1. Save the session!

c. Start Xming on your WIN desktop

d. Login to LINUX host, validate that the .Xauthority was created and fire GUI application you desire to run.

It all looks peachy till another (non-root) user logs in and switches (su – oracle, for example) to another account and suddenly the X does not work ….. To solve it so he/she can run the Oracle’s Database Configuration Assistant (DBCA) do the next step as this user. Validate that he/she can do “xclock” to their desktops and if so execute the next command.

[heshe@mymachine ~]# xauth list
mymachine/unix:10  MIT-MAGIC-COOKIE-1  a9b8dc99a910db2f2a5caae639c8016b

Next, the user has to become “oracle” and he/she has to modify oracle user authorization keys list with the values you just produced above.

[root@mymachine ~]# su - oracle
[oracle@mymachine ~]$ xauth add localhost:10.0 MIT-MAGIC-COOKIE-1  a9b8dc99a910db2f2a5caae639c8016b

Now “xclock” or the “DBCA” should work (assuming Xming has been installed on the “oracle’s” user WIN Desktop. πŸ™‚

Posted in LINUX.

Tagged with , , .


Satellite 5.x tags

A comma delimted file list hostname, application name and its owner or owners. For example

law1,KGB_Detector,James Bond/Gold Member
law2,KGB_Detector,James Bond/Gold Member
law3,KGB_Detector,James Bond/Gold Member

We need to simultaneously create and populate tags with the values from the provided data file (called DataFile.dat).

#!/bin/bash
cat DataFile.dat | awk -F ',' '{print $1, $2, $3}' | while read client application owner
do
  Application=$(echo $application | sed -r 's/\s/\\ /')
  Owner=$(echo $owner | sed -r 's/\s/\\ /g')
  spacecmd -u satadmin -p K@rma0118 custominfo_createkey owner
  spacecmd -u satadmin -p K@rma0118 system_addcustomvalue owner $Owner $client
  spacecmd -u satadmin -p K@rma0118 custominfo_createkey application
  spacecmd -u satadmin -p K@rma0118 system_addcustomvalue application $Application $client
done

Keep in mind, it is an error to create an existing key…. So if you re-execute this scripts you will get errors.

Posted in LINUX.

Tagged with , , .


edit /etc/sudoers with pssh

I have to find a way to manage /etc/sudoers on a global scale like for example with AD…? But till I reach this stage, here is a one liner that I use to append to a specific line in this file.
In this case, I need to add to the end of line that starts with ‘User_Alias DBAS =’. Here is the one liner stored in a file called ‘editSuers’:

#!/bin/bash
sed --in-place '/^User_Alias DBAS =/s/.*/&, new_user/' /etc/sudoers

In the line above, the ‘new_user’ will be replaced with login name of the user we need to add to the DBAS alias.
To run in across a number of hosts (which names are stored in the file called someHosts) using ‘pssh’, I do as shown next.

# pssh -h someHosts -P -I <./editSudoers

Posted in LINUX.

Tagged with , , , .


Tagging systems in RHEL Satellite 5

There are two ways to attach “information” to a system in Satellite. “Notes” as the name implies are to attach non-ordered data. “Custom info” on the other hand allows us creates named keys and to associated with them a specific data objects – almost a database….
Both “Keys” and their data are created on Satellite with the spacecmd command as show next.

# spacecmd
spacecmd {SSM:0}> custominfo_createkey owner
Description: Host Owner
spacecmd {SSM:0}> custominfo_createkey application
Description: Application Name

The “Description” is the label associated with the key that will be visible via Satellite GUI
To associate data with the just created keys and specific system (oravsrv) registered with a Satellite:

spacecmd {SSM:0}> system_addcustomvalue  owner 'mark duszyk' oravsrv
spacecmd {SSM:0}> system_addcustomvalue  application 'my tools forge' oravsrv
spacecmd {SSM:0}> exit
#

The information can be “viewed” from the Satellite GUI or with the “spacecmd” command.

spacecmd {SSM:0}> system_listcustomvalues oravsrv
owner = mark duszyk
application = tools forge
# spacecmd -u satadministrator -p xxxxxxx system_listcustomvalues oravsrv
INFO: Spacewalk Username: satadministrator
INFO: Connected to https://localhost/rpc/api as satadministrator
owner = mark duszyk
application = tools forge

Posted in LINUX.


the replacement for ansible?

I use Ansible for more than two years simply because I have not discovered “this thing” earlier…. I found “pssh” set of utilities this week as I was looking for tools to scan a few hundred machines for a presence of certain files and processes, which produces a better formatted output (not one clattered by flying cows – don’t get me wrong, nothing against animals – I have two dogs and two cats!).
What I found is called “parallel ssh”. It looks (to me) like Ansible has been build on “pssh” functionality or general idea…..?

So in some cases it could be pssh and at a different occasion ansible or something else that comes along…. πŸ™‚


Example 1: copy a file to multiple hosts at once

# prsync -h ./hosts ./xxxx.tgz /root/


Example 2: execute a command on a number of UNIX hosts

# pssh -h ./hosts -o /tmp/scan.out tar xzvf /root/xxxx.tgz


Example 3: execute a script from the “pssh” host on a group of remote hosts

# pssh -h ./hosts -o /tmp/scan.out -I <./LongRiver


Example 4: execute a script from the “pssh” host on a single remote host

# pssh -H myhost.wmd.edu -o /tmp/myhost -I <./MyVeryOldPerlStuff.pl

Above, the “./hosts” file contains the names of the target hosts. The “/tmp/scan.out” indicates output location where the “interaction” between “pssh” and each host is stored in a separate sub-directory.
How to get all these goodies? I installed them on RedHat and Oracle Linuxes with “pip”. These operation will install all of the “parallel” ssh utilities like pssh, prsync, pscp, pnuke and pslurp.

# pip install pssh

Based on the limited amount of time i use “pssh”, I suggest you make sure to disable “getty” requirement in “/etc/sudoers” on all of your target machines. I do not believe that there is any harm in doing so.

Defaults:      !requiretty


Example run against a group hosts defined in the “./hosts” inventory file:

# pssh -h ./hosts -l root -o /tmp/libout -P 'getconf GNU_LIBPTHREAD_VERSION'
WMDBIPPL2: NPTL 2.12
[1] 12:57:54 [SUCCESS] WMDBIPPL2
WMDOIFPL1: NPTL 2.12
[2] 12:57:54 [SUCCESS] WMDOIFPL1
WMDOIMPL3: NPTL 2.12
[3] 12:57:54 [SUCCESS] WMDOIMPL3
WMDOIFPL2: NPTL 2.12
[4] 12:57:54 [SUCCESS] WMDOIFPL2
WMDWEBPL1: NPTL 2.12
[5] 12:57:54 [SUCCESS] WMDWEBPL1
WMDWEBPL2: NPTL 2.12
[6] 12:57:54 [SUCCESS] WMDWEBPL2
WMDOIMPL4: NPTL 2.12
[7] 12:57:55 [SUCCESS] WMDOIMPL4
WMDBIPPL1: NPTL 2.12
[8] 12:57:56 [SUCCESS] WMDBIPPL1

The output will also be written into the “/tmp/libout” directory – each host will have a file with the same name containing the output of the command.Β 

Posted in LINUX.


use ansible to scan for a process

How to scan a group of hosts for a particular process with Ansible?

---
- hosts: all
  gather_facts: no
  vars_prompt:
   - name: "proc_name"
     prompt: "Enter process name to look for"
     private: no

  tasks:
  - name: "check for the {{ proc_name }} process"
    shell: "ps -e | grep -v grep | grep -w {{ proc_name }}"
    register: ps_output
    failed_when: false
    no_log: True
  - debug:
      msg: "{{ ps_output.stdout_lines }}"
    when: ps_output.rc == 0

To do something similar from a command line – for example to find all hosts running “kworker” process or processes:

# ansible all -m shell -a "ps -e | grep -v grep | grep -w kworker"

Posted in LINUX.


syntax checking your yaml code – ansible playbooks

I find yamllint quite useful while scripting in “yaml”. Install it with pip as it is a python package.

# pip install yamllint
Collecting yamllint
  Downloading yamllint-1.10.0-py2.py3-none-any.whl (42kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 51kB 1.8MB/s
Collecting pathspec>=0.5.3 (from yamllint)
  Downloading pathspec-0.5.5.tar.gz
Requirement already satisfied: pyyaml in /usr/lib64/python2.7/site-packages (from yamllint)
Installing collected packages: pathspec, yamllint
  Running setup.py install for pathspec ... done
Successfully installed pathspec-0.5.5 yamllint-1.10.0
#  yamllint
usage: yamllint [-h] [-c CONFIG_FILE | -d CONFIG_DATA]
                [-f {parsable,standard}] [-s] [-v]
                FILE_OR_DIR [FILE_OR_DIR ...]

Posted in LINUX.


ansible dynamic inventory from Satellite 5.8

This is a bash example (SatAnsInv.bash):

#!/bin/bash
### W.M. Duszyk 12/8/17

if [ "$1" == "--host" ]
  then
    echo '{}'
    exit 0
fi
jhosts="{"

for HostGroup in `/usr/bin/spacecmd --nossl group_list -q`
do
  jhosts="$jhosts $HostGroup: ["
  for host in `/usr/bin/spacecmd --nossl group_listsystems $HostGroup -q`
    do
        jhosts="$jhosts$host,"
    done
  jhosts=$jhosts"],"
done

jhosts="$jhosts _meta: { hostvars: {}}}"
printf "$jhosts"

To use it with all hosts registered with Satellite server:

# ansible all -i ./SatAnsInv.bash -m ping

If you have a host group defined under the name of “Unmanaged”:

# ansible Unmanaged -i ./SatAnsInv.bash -m ping

Satellite access info (its hostname, login name and password) are stored in the file ./.spacecmd/configure.

Posted in LINUX, Satellite, scripts.

Tagged with , , .


re-enable “EPEL” repos

Trying to run the yum update and failing with the following message:

warning: /var/cache/yum/x86_64/7Server/prodclone-epel_repo_rhel7_x86_64/packages/R-core-3.3.3-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for R-core-3.3.3-1.el7.x86_64.rpm is not installed

The last line explains what is needed – the key, so lets get it for the current version of RedHat (RH7)

# rpm -ivh https://mirrors.cat.pdx.edu/epel/7/x86_64/e/epel-release-7-9.noarch.rpm

No problems any more….. ir if they are still present

For RHEL 7:

# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

For RHEL 6:

# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

Followed with

# yum -y install ./epel-release-latest-*.noarch.rpm

Posted in LINUX.


mount WIN cifs home directory on RedHat box

my WIN home folder which is defined as //wmd.edu/personalshare/HD3/duszyk “follows” me whenever I go and attaches itself to whatever WIN contraption I login. Now, I want it to be present on a LINUX box as well.
So, I make this entry into the /etc/fstab

\\wmd.edu\personalshare\HD3\duszyk /home/wmd   cifs  _netdev,username=duszyk,dir_mode=0755,file_mode=0755,uid=923810,gid=216

Execution of the mount command triggers request for my password which if corrects allows the share to be mounted as /home/wmd.

For a normal user the mount has to be sudoed and I suggest to include it in the .bashrc and the umount of the share in the .bash_logout as well.

Posted in LINUX.




Copyright © 2016 - 2018 Waldemar Mark Duszyk. All Rights Reserved. Created by Blog Copyright.