Skip to content

Instantly share code, notes, and snippets.

su - postgres -c "psql foreman -c \"select * from foreman_tasks_tasks where state = 'running' OR state = 'paused' OR state = 'planned';\""
@jnikolak
jnikolak / gist:686298f0dc06b58d1f521b83d7ab907b
Created October 26, 2016 13:47
Auto generate Hostname on Rhel 7 and auto-add into /etc/hosts
#!/bin/bash
#### This script will create hostname for rhel 7 and add dns entries into /etc/hosts.
#### There is also a way to generate a random hostname, but the code is commented out.
#### Future version, will try to make it work for when user doesn't have any entry.
dom='.china.com'
old=$(hostname -f)
#This is if you want random letters.
#new2=$(tr -dc 'a-z0-9' < /dev/urandom | head -c12)
#**************************************************************
# Version 0.3"
# Author: Jon Nikolakakis with assistance from Jamie Bainbridge
#**************************************************************
import time
correct = 0 # starting value as no values yet correct
index = 0 # starting the index at 0
# answers to all of the questions in array [0 to 8]
answers = ['false','d','mkdir','mount','d','c','b','a','d','a','a','ntp','fqdn','c']
questions = [
hammer host list --search "yourdomain.com" --per-page 100|grep yourEnvName|awk '{print $1}'|while read i; do hammer host update --id $i --domain-id 1 --subnet-id 1 --medium-id 7 --operatingsystem-id 2 --partition-table-id 13; done
#DELETE DUPLICATES
# Locate hosts in katello_systems and order themn
su - postgres -c "psql foreman -c \"select uuid,id from katello_systems ORDER BY uuid asc;\"" >/tmp/uuid.out
# In above we have 396 Duplicates Content hosts
# Take that data and uniquely sort out
sort | uniq -d -w 36 /tmp/uuid.out | wc -l
396
@jnikolak
jnikolak / gist:5c0eba5453a7d4912b4a700399a59040
Last active November 7, 2016 15:46
Install Satellite from Disconnected
#!/bin/bash
set -x # Comment this out for faster implementation.
#**************************************************************
## Version 0.1"
### Author: Jon Nikolakakis
#### change variable $dom if you don't want the domain china.com
##### This script will install and set up your hostname, then install Satellite of your choosing.
###### The goal is to do it quickly and without much interaction.
####### The installer requires that you have downloaded the disconnected satellite iso,
#!/bin/bash
set -x
mkdir -p /var/www/html/pub/sat-import/
for i in $(ls /source/sat-6-isos--rhel-7-server-x86_64*)
do
mkdir /mnt/iso
mount -o loop $i /mnt/iso
cp -ruv /mnt/iso/* /var/www/html/pub/sat-import/
sleep 10
#!/bin/bash
set -x
#oldName=$(grep DEVICE /etc/sysconfig/network-scripts/ifcfg-ens3 | awk -F '"' '{print $2}')
intName=$(ip link | egrep -v "lo|link" | awk -F ': ' '{print $2}')
ifcfgfile="/etc/sysconfig/network-scripts/ifcfg-$intName"
mv /etc/sysconfig/network-scripts/ifcfg-$intName /etc/sysconfig/network-scripts/ifcfg-$intName.bak
touch $ifcfgfile
for i in "DEVICE=$intName" "ONBOOT=yes"
@jnikolak
jnikolak / gist:48a2f148cd845061cbc8df0b0ab2dede
Last active November 3, 2016 07:42
Create Static Network Configuration
#!/bin/bash
set -x
### TODO DETERMINE HOW MANY INTERFACE ACTIVE AND WHICH ONE YOU WOULD LIKE TO CONFIGURE
curipaddr=$(ip link | egrep -v "lo|link" | awk -F ': ' '{print $2}')
curgateway=$(ip r s table all | egrep 'default v' | awk '{print $3}')
curdns=$(dig $(hostname -f) | egrep SERVER | awk -F '(' '{print $2}'| sed 's/)//')
#oldName=$(grep DEVICE /etc/sysconfig/network-scripts/ifcfg-ens3 | awk -F '"' '{print $2}')
@jnikolak
jnikolak / gist:b09d4a20f5150c65e05a8fe3421b160f
Last active May 29, 2018 00:47
automated script to setup provisioning
#!/bin/bash
#set -x
if [ -d /etc/foreman-installer ];then
password=$(grep admin_password /etc/foreman-installer/scenarios.d/satellite-answers.yaml| egrep -v pulp | awk '{print $2}')
else
password=$(grep admin_password /etc/katello-installer/answers.katello-installer.yaml| egrep -v pulp | awk '{print $2}')
fi
if [ -f ~/.hammer/cli_config.yml ];then
mv ~/.hammer/cli_config.yml /tmp/cli_config.yml