Skip to content

Instantly share code, notes, and snippets.

@xmorales
Created September 18, 2013 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xmorales/6606262 to your computer and use it in GitHub Desktop.
Save xmorales/6606262 to your computer and use it in GitHub Desktop.
Puppetmaster and puppetdb installation with a puppet manifest. Just launch puppet apply puppet_install.pp to have it working. For a demo purpose only.
#!/bin/bash
sudo puppet module install puppetlabs-apache
sudo puppet module install puppetlabs-firewall
sudo touch /etc/puppet/manifests/site.pp
sudo chmod a+w /etc/puppet/manifests/site.pp
cat > /etc/puppet/manifests/site.pp <<EOF
node 'puppet' {
require firewall
#PuppetDB access and apache standard ports
firewall{ '100 allow apache and puppetdb access':
port => [80,8080,443],
proto => tcp,
action => accept,
}
class{ 'apache': }
}
EOF
sudo chmod 644 /etc/puppet/manifests/site.pp
sudo puppet agent -t -d
#Repositories needed to install puppetmaster
#yumrepo { 'epel':
# descr => 'Extra Packages for Enterprise Linux 6 - $basearch',
# enabled => '1',
# failovermethod => 'priority',
# gpgcheck => '0',
# mirrorlist => 'https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch',
#}
#yumrepo { 'puppetlabs-deps':
# baseurl => 'http://yum.puppetlabs.com/el/6/dependencies/$basearch',
# descr => 'Puppet Labs Dependencies El 6 - $basearch',
# enabled => '1',
# gpgcheck => '0',
#}
#yumrepo { 'puppetlabs-products':
# baseurl => 'http://yum.puppetlabs.com/el/6/products/$basearch',
# descr => 'Puppet Labs Products El 6 - $basearch',
# enabled => '1',
# gpgcheck => '0',
#}
package {'epel-release':
ensure => 'installed',
source => 'http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm',
provider => 'rpm',
}
package {'puppetlabs-release':
ensure => 'installed',
source => 'http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm',
provider => 'rpm',
}
package{
['vim-enhanced',
'screen',
'puppet-server',
'puppetdb',
'puppetdb-terminus',
]:
ensure => installed,
# require => [ Yumrepo['puppetlabs-products'], Yumrepo['epel'] ],
require => [ Package['puppetlabs-release'], Package['epel-release'] ],
}
service {'puppetmaster':
ensure => running,
enable => true,
require => Exec['set-hostname'],
}
#PuppetDB service configuration
service {'puppetdb':
ensure => running,
enable => true,
require => Service['puppetmaster']
}
$puppetdb_conf = '[main]
server = puppet
'
file{"/etc/puppet/puppetdb.conf":
content => $puppetdb_conf,
require => Package['puppetdb-terminus'],
notify => Service['puppetmaster'],
}
$puppetdb_route = '---
master:
facts:
terminus: puppetdb
cache: yaml
'
file{"/etc/puppet/routes.yaml":
content => $puppetdb_route,
require => Package['puppetdb-terminus'],
notify => Service['puppetmaster'],
}
#Workarround since there is no len in augeas for puppet.conf
exec{"config-puppetdb":
command => 'echo "[master]" >> /etc/puppet/puppet.conf; echo " storeconfigs = true" >> /etc/puppet/puppet.conf; echo " storeconfigs_backend = puppetdb" >> /etc/puppet/puppet.conf;',
unless => 'grep "\[master\]" /etc/puppet/puppet.conf',
path => ['/bin'],
require => Package['puppetdb-terminus'],
notify => Service['puppetmaster'],
}
#Workarround for first install problem
exec{"puppetdb-ssl-setup":
command => 'puppetdb-ssl-setup',
path => ['/bin', '/sbin', '/usr/sbin', '/usr/bin'],
require => Package['puppetdb'],
notify => Service['puppetdb'],
}
# Enables autosign node certificates
file {'/etc/puppet/autosign.conf':
ensure => present,
content => "*\n",
require => Package['puppet-server'],
notify => Service['puppetmaster'],
}
#Set master hostname into puppet.localdomain
file { "/etc/hostname":
ensure => present,
owner => root,
group => root,
mode => 644,
content => "puppet.localdomain\n",
notify => Exec["set-hostname"],
}
exec { "set-hostname":
command => "/bin/hostname -F /etc/hostname",
unless => "/usr/bin/test `hostname` = `/bin/cat /etc/hostname`",
}
host { 'localhost':
ensure => 'absent',
}
host { 'localhost4':
ensure => 'present',
host_aliases => ['puppet', 'puppet.localdomain', 'puppetdb', 'localhost', 'localhost.localdomain', 'localhost4.localdomain4'],
ip => '127.0.0.1',
target => '/etc/hosts',
require => Exec['set-hostname'],
}
host { 'localhost6':
ensure => 'present',
host_aliases => ['puppet', 'puppet.localdomain', 'puppetdb', 'localhost', 'localhost.localdomain', 'localhost6.localdomain6'],
ip => '::1',
target => '/etc/hosts',
require => Exec['set-hostname'],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment