Posts

How to clean all the foreman task and locked task

1.- First make su to postgres user su -s /bin/bash - postgres  2.-Execute psql psql  3.- connect to the foreman database \c foreman;  4.- Delete all the foreman task and foreman task locks delete from foreman_tasks_tasks;  delete from foreman_tasks_locks;  5.- Quit from postgres and exit \q  exit  6. Restart all the services for s in {qpidd,pulp_celerybeat,pulp_ resource_manager,pulp_workers, httpd}; do sudo service $s restart; done  Update in todays foreman you can clean the task using the following command: foreman-rake foreman_tasks:cleanup

Migration Script from Winbind to SSSD

#!/bin/bash echo Disable winbind authconfig --disablewinbindauth  --disablewinbind --disablekrb5 --updateall service winbind stop chkconfig winbind off echo Setup Kerberos rm -f /etc/krb5.conf  cat > /etc/krb5.conf << "EOF" [logging]  default = FILE:/var/log/krb5libs.log  kdc = FILE:/var/log/krb5kdc.log  admin_server = FILE:/var/log/kadmind.log [libdefaults]  default_realm = EXAMPLE.COM  dns_lookup_realm = true  dns_lookup_kdc = true  ticket_lifetime = 24h  renew_lifetime = 7d  forwardable = true [realms]  EXAMPLE.COM = {   kdc = ad.example.com   admin_server = ad.example.com  } [domain_realm]  example.com = EXAMPLE.COM  .example.com= EXAMPLE.COM EOF echo Samba Setup rm -f /etc/samba/smb.conf  cat > /etc/samba/smb.conf << "EOF" [global]         workgroup = EXAMPLE   ...

Postgresql BDR Setup

yum install http://packages.2ndquadrant.com/postgresql-bdr94-2ndquadrant/yum-repo-rpms/postgresql-bdr94-2ndquadrant-redhat-1.0-2.noarch.rpm yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm yum update yum install postgresql-bdr94-bdr Initialize Node1 and 2 database /usr/pgsql-9.4/bin/postgresql94-setup initdb Setup Postgresql.conf and hba node 1 /var/lib/pgsql/9.4-bdr/data/postgresql.conf listen_addresses = '*'  port = 5598   shared_preload_libraries = 'bdr'     wal_level = 'logical'     track_commit_timestamp = on     max_connections = 100     max_wal_senders = 10     max_replication_slots = 10     # Make sure there are enough background worker slots for BDR to run     max_worker_processes = 10     # These aren't required, but are useful for diagnosing problems     #log_error_verbosity = verbose ...

Script to ask Network configuration via kickstart

%pre #!/bin/bash echo -n "Enter FQDN Hostname: " > /dev/tty1 read HOSTN echo -n "Enter IP Address:" > /dev/tty1 read IP echo -n "Enter the Netmask:" > /dev/tty1 read MASK echo -n "Enter Gateway:" > /dev/tty1 read GW echo -n "Enter Nameserver:" > /dev/tty1 read DNS echo "network --device eth0 --bootproto=static --ip=${IP} --netmask=${MASK} --gateway=${GW} --nameserver=${DNS} --hostname=${HOSTN}" > /tmp/network.txt %post --noroot #!/bin/bash # bring in hostname collected from %pre, then source it ###### cp -Rvf /etc/sysconfig/network /mnt/sysimage/etc/sysconfig/network cp -Rvf /etc/sysconfig/resolv.conf /mnt/sysimage/etc/resolv.conf # Set-up eth0 with hostname cp /etc/sysconfig/network-scripts/ifcfg-eth0  /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-eth0 # force hostname change /mnt/sysimage/bin/hostname $HOSTNAME rhn-profile-sync

Kickstar script to join linux machine to FreeIPA

First create the host on IPA Server and provide one time password in this example the password is "secret" # Get the hostname to set as the host principal chvt 3 exec </dev/tty3> /dev/tty3 clear /bin/hostname > /tmp/hostname.txt # Run the client install script echo Installing IPA Client sleep 5 /usr/sbin/ipa-client-install --domain=ipdomain.example.com --enable-dns-updates --mkhomedir -w secret --realm=IPADOMAIN.EXAMPLE.COM --server=server01.ipdomain.example.com --unattended rm -f /etc/krb5.conf cat > /etc/krb5.conf << "EOF" includedir /var/lib/sss/pubconf/krb5.include.d/ [logging]  default = FILE:/var/log/krb5libs.log  kdc = FILE:/var/log/krb5kdc.log  admin_server = FILE:/var/log/kadmind.log [libdefaults]  default_realm = IPADOMAIN.EXAMPLE.COM  dns_lookup_realm = false  dns_lookup_kdc = true  rdns = false  ticket_lifetime = 24h  forwardable = yes  udp_preferen...

Installation Script for Splunk

#!/bin/bash echo "Splunk Installation" yum install splunk<version> -y --nogpgcheck usermod -G <group that splunk is going to be join> splunk /opt/splunkforwarder/bin/splunk enable boot-start -user splunk --accept-license su splunk -c "/opt/splunkforwarder/bin/splunk add forward-server splunk.example.com:9997" su splunk -c "/opt/splunkforwarder/bin/splunk edit user admin -password password -auth admin:password" su splunk -c "/opt/splunkforwarder/bin/splunk start" for dir in $(find /var/point -mindepth 1 -maxdepth 1 -type d) do su splunk -c "/opt/splunkforwarder/bin/splunk add monitor $dir/logs -index $env -sourcetype $(basename $dir)" done chkconfig splunk on echo "Installation complete"

Hardening Script

#!/bin/bash function set_parameter { sed -i -e "s|^$2.*|$2$3|" $1 egrep "^$2*" $1 > /dev/null ||echo "$2$3" >> $1 } #--------------------------------------------------------------------------------------------------------------- function add_line { egrep "^$2" $1 > /dev/null || echo "$2" >> $1 } #--------------------------------------------------------------------------------------------------------------- echo '# This file contains the auditctl rules that are loaded # whenever the audit daemon is started via the initscripts. # The rules are simply the parameters that would be passed # to auditctl. # First rule - delete all -D # Increase the buffers to survive stress events. # Make this bigger for busy systems -b 8192 # Feel free to add below this line. See auditctl man page -a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -k timechange ...