Skip to content

Instantly share code, notes, and snippets.

@Ancillas
Last active December 15, 2015 10:48
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 Ancillas/5248102 to your computer and use it in GitHub Desktop.
Save Ancillas/5248102 to your computer and use it in GitHub Desktop.
# == Class: dns
#
# This module creates a DNS configuration file for the supplied nameservers and
# domain. It also supports an optional options string.
#
# === Supported Operating-Systems
#
# Ubuntu
#
# === Other Requirements
#
# Hiera
#
# === Parameters
#
# [*nameservers*]
# An array of nameservers.
#
# [*domain*]
# The domain to be used for DNS search.
#
# [*options*]
# A space-delimited string of DNS options.
#
# === Variables
#
# None
#
# === Examples
#
# include dns
#
# or
#
# class { 'dns':
# nameservers => ['1.1.1.1', '2.2.2.2'],
# domain => 'domain.com',
# options => 'ndots:2 timeout:3',
# }
#
# Be careful when using resource-like class instantiation as the class {}
# syntax can only be applied once per class per catalog.
#
# === Authors
#
# Me
#
# === Copyright
#
# Me
#
class dns(
$nameservers = hiera('dns::nameservers'),
$domain = hiera('dns::domain'),
$options = hiera('dns::options'),
) {
case $::operatingsystem {
'Ubuntu': {
$dns_config_file = '/etc/resolv.conf'
}
default: {
fail("$::operatingsystem is not supported.")
}
}
class{'dns::config': } ->
Class['dns']
}
class facts {}
# == Class: hosts
#
# Manages the hosts file.
#
# === Parameters
#
# None
#
# === Variables
#
# None
#
# === Todo
#
# Use Concat to allow host entries from other modules.
# Parameterize this class to allow for host entries to be passed in.
#
# === Examples
#
# class { 'hosts':
# }
#
# === Authors
#
# Me
#
# === Copyright
#
# Me
#
class hosts(
) {
$hostspath = $::operatingsystem {
'Ubuntu' => '/etc/hosts',
default => unset,
}
if $hostspath == unset {
fail('$::operatingsystem is not supported.')
}
$private_ip = $::ipaddress_eth1
file { "$hostspath":
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => template('hosts/hosts.erb')
}
}
class role::default {
$allow_group = hiera('centrify::allow_group')
$apt_url = hiera('role::apt_url')
$apt_pubkey_fingerprint = hiera('role::apt_pubkey_fingerprint')
Class['dns'] -> Apt::Source <| |>
Class['apt'] -> Package <| |>
Exec['apt_update'] -> Package <| |>
Apt::Source <| |> -> Package <| |>
Centrify::Allow_group <| |> -> Anchor['role::default::end']
anchor {'role::default::start': }
class {'facts': } ->
class {'hosts': } ->
class {'dns': } ->
class {'apt':
always_apt_update => true,
} ->
class {'ntp': } ->
class {'ufw': } ->
class {'lastlog': } ->
class {'fail2ban': } ->
class {'sudo': } ->
class {'sshd': } ->
class {'pe_puppetagent': } ->
class {'centrify': } ->
anchor {'role::default::end':
require =>
[
Apt::Source["${apt_url}-stable"],
Anchor['role::default::start'],
],
}
centrify::allow_group { $allow_group : }
apt::source { "${apt_url}-stable":
location => "http://${apt_url}",
key => "${apt_pubkey_fingerprint}",
key_source => "http://${apt_url}/pubkey.gpg",
repos => 'stable',
include_src => false,
require => Class['dns'],
}
}
class role::apps::myapp {
$allow_group = hiera('centrify::allow_group')
$apt_url = hiera('role::apt_url')
$apt_pubkey_fingerprint = hiera('role::apt_pubkey_fingerprint')
Exec['apt_update'] -> Package <| |>
Apt::Source <| |> -> Package <| |>
Class['apt'] -> Package <| |>
include role::default
Class['role::default'] ->
anchor {'role::apps::myapp::start': } ->
class {'apps': } ->
anchor {'role::apps::myapp::end':
require =>
[
Apps::Application['myapp'],
Anchor['role::apps::myapp::start'],
],
}
apps::application { "myapp":
common_name => "myapp-common_name",
doc_root => "myapp_doc_root",
datasource => "myapp_datasource",
}
apt::source { "${apt_url}-myapp":
location => "http://${apt_url}",
repos => 'myapp',
key => "${apt_pubkey_fingerprint}",
key_source => "http://${apt_url}/pubkey.gpg",
include_src => false,
}
}
### Setup File Bucket ###
filebucket { 'main':
server => 'puppet.domain.com',
path => false,
}
File { backup => 'main' }
notify{ "Running in the ${::environment} environment": }
node default {
include role::apps::myapp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment