Posts in Category: uncategorized

Linux – The dig command

You can use the nslookup command to find what ip address a url resolves to. But another way to do this is by using the dig command:

$ dig +short
{list of ip address}

This gives a list of ip addresses, since website is load-balanced across several servers.

To find which dns servers gave this resolution info, do:

$ dig ns +short
{list of urls}

These are the urls of dns servers.

If you want to find out what a server’s fqdn is, then do:

$ dig -x {ip-addr}

This will give the same info that you would get if you had ssh’d into the server and ran the ‘hostname’ command.

Also you can specify what dns server to use when using dig:

$ dig @ 

This is using google’s dns. If you want to use your company’s

AWS – Increasing the size of an EC2 instance’s primary EBS volume

This is really good guide:

basically stop your instance, detach the primary volume (/dev/sda1), create a snapshot from this ebs volume, create a volume (with increased diskspace) from the snapshot, attach the new bigger volume to the ec2 instance, as /dev/sda1.

start the instance again.

spacewalk – notes

deregister vm from spacewalk:

rm /etc/sysconfig/rhn/systemid

Upload rpm to spacewalk

$ Rpm --addsign name.rpm
$ Rhnpush -c {channel's-label} --server localhost name.rpm

Foreman – Render provisioning templates

#!/usr/bin/env ruby

require “erb”
require ‘ostruct’

class Basicerb

def initialize name
@name = name
@template =‘/root/index.erb’)

def render
@person = = “John Smith”
@person.age = 70
@person.pension = 300“

Hello ERB World!!

<%= %>

“).result( binding )

test = “wow”

puts test.render

yum error – Public key for *.rpm is not installed

the dirty way aroung this is doing:

$ yum install {package-name} --nogpgcheck

But best practice is:

first cd to:

$ cd /etc/pki/rpm-gpg

Then do a wget command, here’s an example:

$ wget -O

then import it into rpm db like this:

$ rpm --import RPM-GPG-KEY-foreman

You can list all the imported keys like this:

$ rpm -qa gpg*

then to check it have worked, you can do:

$ rpm -qi gpg-pubkey-225c9b71-54fda121
 Name : gpg-pubkey Relocations: (not relocatable)
 Version : 225c9b71 Vendor: (none)
 Release : 54fda121 Build Date: Wed 28 Oct 2015 11:41:38 AM GMT
 Install Date: Wed 28 Oct 2015 11:41:38 AM GMT Build Host: localhost
 Group : Public Keys Source RPM: (none)
 Size : 0 License: pubkey
 Signature : (none)
 Summary : gpg(Foreman Release Signing Key (1.8) <>)
 Description :

Foreman – triggering a puppet run from the gui interface

On the agent, add the following near to the top of the file:

# vim /etc/puppet/auth.conf
path /run
allow *

Note: later on change the “*” to the fqdn of the puppetmaster fqdn.

On the puppetmaster enable mcollective:

$ cat /etc/foreman-proxy/settings.d/puppet.yml
.# valid providers:
#   puppetrun   (for puppetrun/kick, deprecated in Puppet 3)
#   mcollective (uses mco puppet)
#   puppetssh   (run puppet over ssh)
#   salt        (uses salt
#   customrun   (calls a custom command with args)
:puppet_provider: mcollective

Foreman gui:
on foreman settings (More -> Settings -> “Puppet”tab), set puppetrun to “true”.

Edit the master sudoers file as described here:

On the agent add the following to sudoers file:

# /etc/sudoers
foreman-proxy ALL=(ALL) NOPASSWD: ALL

On foreman, You might need to do