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 google.com +short
{list of ip address}

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

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

$ dig google.com 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 https://example.com @8.8.8.8 

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:

http://cloud.tekgoblin.com/2013/04/29/aws-guides-how-to-increase-your-ec2-linux-root-volume-size/

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

https://fedorahosted.org/spacewalk/wiki/UploadFedoraContent


Foreman – Render provisioning templates

#!/usr/bin/env ruby

require “erb”
require ‘ostruct’

class Basicerb

def initialize name
@name = name
@template = File.read(‘/root/index.erb’)
end

def render
@person = OpenStruct.new
@person.name = “John Smith”
@person.age = 70
@person.pension = 300
ERB.new(“

Hello ERB World!!

<%= @person.name %>

“).result( binding )
end
end

test = Basicerb.new “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 http://yum.theforeman.org/releases/1.8/RPM-GPG-KEY-foreman

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) <packages@theforeman.org>)
 Description :
 -----BEGIN PGP PUBLIC KEY BLOCK-----

Foreman – triggering a puppet run from the gui interface

https://github.com/ripienaar/mcollective-vagrant

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 puppet.run)
#   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:

http://theforeman.org/manuals/1.8/index.html#4.3.7Puppet

On the agent add the following to sudoers file:

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


On foreman, You might need to do