Skip to content

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 -o /tmp/myhost -I <./

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'
[1] 12:57:54 [SUCCESS] WMDBIPPL2
[2] 12:57:54 [SUCCESS] WMDOIFPL1
[3] 12:57:54 [SUCCESS] WMDOIMPL3
[4] 12:57:54 [SUCCESS] WMDOIFPL2
[5] 12:57:54 [SUCCESS] WMDWEBPL1
[6] 12:57:54 [SUCCESS] WMDWEBPL2
[7] 12:57:55 [SUCCESS] WMDOIMPL4
[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
   - name: "proc_name"
     prompt: "Enter process name to look for"
     private: no

  - 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 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):

### W.M. Duszyk 12/8/17

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

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

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

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

For RHEL 7:

# wget

For RHEL 6:

# wget

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 // “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

\\\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.

update Ansible to the latest…

# mkdir ansible; cd ansible
# git clone git:// --recursive
# git submodule update --init --recursiv
# make install
# ansible --version
ansible 2.4.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/share/ansible']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible-2.4.0-py2.7.egg/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

Posted in LINUX.

Tagged with , , .

xming, putty, linux

A few steps are required on linux and putty sides.

a. Install the following package if it is not present.

# yum -y install xorg-x11-xauth

b. Enable X11 forwarding in /etc/ssh/sshd_config

X11Forwarding yes

c. In putty check that SSH-> X11-> X11Forwarding is enabled and MIT-Magic-Cookie-1 is set.

d. On laptop side, start Xming, putty into your linux box, do not set DISPLAY! – all is ready to go.

Posted in LINUX.

Tagged with , , .

synchronize channels of Oracle SpaceWalk server

Busy day today….

To list Oracle Public Yum repo channels associated with a given SpaceWalk server, execute

# spacewalk-repo-sync -l

To upgrade / synchronize contents of these channels, execute

for repo in `spacewalk-repo-sync -l | grep http | awk -F '|' '{print $1}'`
 spacewalk-repo-sync -c $repo

and wait for this loop to finish…..

To synchronize a channel with a ULN repository, use the spacewalk-repo-sync -t uln command, and use the -c option to specify the channel label, for example:

# spacewalk-repo-sync -t uln -c ksplice-ol6-x86_64

Posted in LINUX.

Tagged with , , .

mounting cifs with RedHat

To mount cifs share verify that these packages are installed


Check that the following entry exists in /etc/request-key.conf

create  dns_resolver    *       *      /usr/sbin/cifs.upcall %k

Finally, mount the share using the associated with it login/password

# mount -t cifs  // /someLocalMount \
               -o username=Name,password=Password

Posted in Linux.

Tagged with , .

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