Category Archives: Server

Create RPM from tar (extract only)


title: “Create RPM from tar (extract only)”
date: 2016-01-14T10:16:13
slug: create-rpm-from-tar-extract-only


Install fpm

gem install fpm
fpm -s tar -t rpm --name tomcat7 --version 7.0.67 apache-tomcat-7.0.67.tar.gz

Mit

--prefix <path>

kann der Target Pfad mit angegeben werden.

Static DNS with DHCP (Ubuntu & Centos)


title: “Static DNS with DHCP (Ubuntu & Centos)”
date: 2016-01-14T09:18:40
slug: static-dns-with-dhcp-ubuntu-centos


Ubuntu:

vi /etc/dhcp/dhclient.conf

Remove the DNS and Serarch opteion (if needed)

request subnet-mask, broadcast-address, time-offset, routers,
 domain-name, host-name,
 dhcp6.name-servers, dhcp6.domain-search,
 netbios-name-servers, netbios-scope, interface-mtu,
 rfc3442-classless-static-routes, ntp-servers,
 dhcp6.fqdn, dhcp6.sntp-servers;

Add the Static DNS and Search Values:

vi /etc/network/interfaces.d/eth0.cfg
# The primary network interface
auto eth0
iface eth0 inet dhcp
dns-nameservers 172.31.8.224
dns-search nyc2.example.com

Centos

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Change PEERDNS=”yes” to PEERDNS=”no”

DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
USERCTL="yes"
PEERDNS="no"
IPV6INIT="no"
PERSISTENT\_DHCLIENT="1"

Set the required Values in /etc/resolv.conf

vi /etc/resolv.conf
; generated by /usr/sbin/dhclient-script
nameserver 172.31.8.224
search nyc2.example.com

Apache Configuration


title: “Apache Configuration”
date: 2016-01-13T20:25:01
slug: apache-configuration


class { 'apache': # use the "apache" module
 default\_vhost => false, # don't use the default vhost
 default\_mods => false, # don't load default mods
 mpm\_module => 'prefork', # use the "prefork" mpm\_module
 }
 include apache::mod::php # include mod php
 apache::vhost { 'example.com': # create a vhost called "example.com"
 port => '80', # use port 80
 docroot => '/var/www/html', # set the docroot to the /var/www/html
 }
 apache::listen { '80': } #Create Listen Entry
 apache::vhost { 'first.example.com':
 ip => '10.0.0.10',
 docroot => '/var/www/first',
 ip\_based => true,
}

CheetSheet


title: “CheetSheet”
date: 2016-01-13T20:16:54
slug: cheetsheet


# execute 'apt-get update'
exec { 'apt-update': # exec resource named 'apt-update'
 command => '/usr/bin/apt-get update' # command this resource will run
}

# install apache2 package
package { 'apache2':
 require => Exec['apt-update'], # require 'apt-update' before installing
 ensure => installed,
}

# ensure apache2 service is running
service { 'apache2':
 ensure => running,
}

# install mysql-server package
package { 'mysql-server':
 require => Exec['apt-update'], # require 'apt-update' before installing
 ensure => installed,
}

# ensure mysql service is running
service { 'mysql':
 ensure => running,
}

# install php5 package
package { 'php5':
 require => Exec['apt-update'], # require 'apt-update' before installing
 ensure => installed,
}

# ensure info.php file exists
file { '/var/www/html/info.php':
 ensure => file,
 content => '<?php phpinfo(); ?>', # phpinfo code
 require => Package['apache2'], # require 'apache2' package before creating
}

Create new vhost on webXX Nodes


title: “Create new vhost on webXX Nodes”
date: 2016-01-13T20:13:35
slug: create-new-vhost-on-webxx-nodes


node /^www\d+$/ {
 class { 'apache': } # use apache module
 apache::vhost { 'example.com': # define vhost resource
 port => '80',
 docroot => '/var/www/html'
 }
}

Create User


title: “Create User”
date: 2016-01-13T20:09:29
slug: create-user


user { 'mitchell':
 ensure => present,
 uid => '1000',
 gid => '1000',
 shell => '/bin/bash',
 home => '/home/mitchell'
}

Restart a service after file creation


title: “Restart a service after file creation”
date: 2016-01-13T15:57:19
slug: restart-a-service-after-file-creation


file { '/etc/apache2/sites-enabled/mysite':
 owner => root, group => root, mode => 0644,
 source => "puppet:///files/mysite/mysite\_apache.conf",
 notify => Service['apache2'],
}

Create a file (with class)


title: “Create a file (with class)”
date: 2016-01-13T15:53:50
slug: create-a-file-with-class


Creates the files /usr/local/sbin/puppetsimple.sh with owner=root, group=root, mode=0755

file {'/usr/local/sbin/puppetsimple.sh':
 owner => root, group => root, mode => 0755,
 content => "#!/bin/sh
puppet agent --onetime --no-daemonize --verbose $1
",
}

Define a class (container) that do this and execute the class/container

class toolbox{
 file {'/usr/local/sbin/puppetsimple.sh':
 owner => root, group => root, mode => 0755,
 content => "#!/bin/sh
puppet agent --onetime --no-daemonize --verbose $1
",
 }
}

include toolbox