Skip to content

Solaris puppet env dirs

wordpress meta

title: 'Solaris 11 Enable Puppet Environment Directories'
date: '2017-08-01T17:08:19-05:00'
status: draft
permalink: /solaris-puppet-env-dirs
author: admin
excerpt: ''
type: post
id: 1117
category:
    - Uncategorized
tag: []
post_format: []

I recently changed a puppet environment to use environment directories and since this is on Solaris I made some notes. I do not include any puppet master or agent setup here only the changes I made to enable directory environments.

https://docs.puppet.com/puppet/3.7/environments_configuring.html

Since this is Solaris and using SMF we can't just edit puppet.conf

# svccfg -s svc:/application/puppet:master setprop config/environmentpath=/etc/puppet/environments
# svcadm refresh puppet:master
# svcadm restart puppet:master

root@usli-utility:/etc/puppet/environments/dev/manifests# more /etc/puppet/puppet.conf 
# WARNING: THIS FILE GENERATED FROM SMF DATA.
#     DO NOT EDIT THIS FILE.  EDITS WILL BE LOST.
#
# See puppet.conf(5) and http://docs.puppetlabs.com/guides/configuring.html
# for details.
[master]
environmentpath = /etc/puppet/environments 
logdest = /var/log/puppet/puppet-master.log 
server = puppetmaster.domain.com 

Take a look at the structure.

# pwd
/etc/puppet/environments

# tree
.
|-- dev
| |-- environment.conf
| |-- manifests
| | |-- site.pp
| | |-- node-eb31.pp
| | |-- node-eb32.pp
| | -- node-eb31.pp |-- modules
|-- dr
| |-- environment.conf
| |-- manifests
| | |-- site.pp
| | |-- node-eb01.pp
| | -- node-bk01.pp |-- modules
|-- production
| -- manifests | |-- site.pp | |-- node-ag11.pp | |-- node-em01.pp-- tst
|-- environment.conf
|-- manifests
| |-- site.pp
| -- node-ag11.pp-- modules
[/bash]

To reload configuration I am restarting puppet like this.

# svcadm disable puppet:master
# svcadm enable puppet:master

At the same time as enabling directory environments I simplified node manifests and captured here.
Node I could have used modules/classed but define is quicker and still fit my needs.

Add environments.onf file.

# pwd
/etc/puppet/environments/dev

# cat environment.conf 
manifest = manifests/

Using combination of site.pp and node specific manifests. I snipped both files for the relevant code.

# pwd
/etc/puppet/environments/dev/manifests

# cat site.pp
$custommsg= "
DEV environment puppet Config Management v0.9.4
IP Address : ${ipaddress_net0}
Environment : ${environment}
"
define check_project(
$msg = $params::msg, $g = $group ) {
#notify{ $g: }
$execPath = "/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
exec { "projmod max-sem-ids":
command => "projmod -sK 'project.max-sem-ids=(privileged,100,deny)' group.$g",
require => Exec["projadd group.$g"],
unless => "projects -l group.$g | grep max-sem-ids | grep -c 100",
path => $execPath,
}
}

if "-dsdb-" in $hostname {
#notify {"${hostname} identified as an Oracle DB server will apply project and network tuning steps":}
$execPath = "/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"

exec { "ipadm smallest_anon_port tcp":
command => "ipadm set-prop -p smallest_anon_port=9000 tcp",
path => $execPath,
onlyif => "ipadm show-prop -o CURRENT -c -p smallest_anon_port tcp | grep -v 9000"
}
}

node default {
}

# more node-eb31.pp
node 'node-eb31.domain.com' {

host { 'node-eb31.domain.com':
ip => '10.2.14.95',
host_aliases => ['node-eb31','loghost'],
}

$group = "ebsdev3"
$user = "ebsdev3_o"
$gid = "303"
$storage = "10.2.14.35"
$storage_archive = "10.2.14.33"
$A_environment = "EBSDEV3"

$execPath = "/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
exec { "projadd group.$group":
command => "projadd -U $user -G $group -p $gid group.$group",
require => User["$user"],
unless => "projects -l | grep -c group.$group",
path => $execPath,
}

exec { "usermod $user":
command => "usermod -K project=group.$group $user",
require => [User["$user"],Exec["projadd group.$group"],],
unless => "projects -l group.$group | grep users | grep -c $user",
path => $execPath,
}

#### DB and Project Setting Checks
exec { "projmod max-shm-memory":
command => "projmod -sK 'project.max-shm-memory=(privileged,10737418240,deny)' group.$group",
require => [User["$user"],Exec["projadd group.$group"],],
unless => "projects -l group.$group | grep project.max-shm-memory | grep -c 10737418240",
path => $execPath,
}

check_project { $group: }

$b1 = "/u01/oradata/$A_environment"

file {
[ "/u01" ]:
ensure => directory,
#group => '401',
mode => 0755;
[ "/software","/scratch" ]:
ensure => directory,
group => '401',
mode => 0775;
[ "/var/opt/oracle","/u01/oradata","/u01/app","/u01/diag","/u01/diag/${ARB_environment}","${b1}/data","${b1}/data1","${b1}/redo","${b1}/undo","${b1}/temp","${b1}/archdest1","${b1}/a
rchdest3","${b1}/fra", ]:
ensure => directory,
owner => "${user}",
group => "${group}",
mode => "775";
[ "/apps", "/apptmp" ]:
ensure => directory,
#group => "${group}",
mode => 0755;
}

#### NFS Mounts Start
$nfs_defaults1 = {
ensure => "present",
fstype => "nfs",
pass => "-",
options => "rw,bg,vers=3,proto=tcp,sec=sys,hard,intr,rsize=1048576,wsize=1048576,retrans=5,timeo=600",
atboot => yes,
blockdevice => '-'
}
$nfs_defaults2 = {
ensure => "present",
fstype => "nfs",
pass => "-",
options => "rw,bg,vers=3,proto=tcp,sec=sys,hard,nointr,llock,rsize=1048576,wsize=1048576,retrans=5,timeo=600",
atboot => yes,
blockdevice => '-'
}
$nfs_defaults3 = {
ensure => "present",
fstype => "nfs",
pass => "-",
options => "rw,bg,hard,rsize=1048576,wsize=1048576,vers=3,llock,nointr,proto=tcp,suid",
atboot => yes,
blockdevice => '-'
}
$nfs_defaults4 = {
ensure => "present",
fstype => "nfs",
pass => "-",
options => "rw,bg,hard,rsize=1048576,wsize=1048576,vers=3,nointr,proto=tcp,suid",
atboot => yes,
blockdevice => '-'
}

$nfs_mounts1 = {
'/u01/app' => {
device => "$storage:/export/USLI-MIDTIER/${ARB_environment}/DBHOME",
},
}
$nfs_mounts2 = {
'/apps' => {
device => "$storage:/export/USLI-MIDTIER/$ARB_environment/APPS_CLONED",
},
'/apptmp' => {
device => "$storage:/export/USLI-MIDTIER/$ARB_environment/APPTMP",
},
"/u01/diag/${ARB_environment}" => {
device => "$storage:/export/USLI-MIDTIER/${ARB_environment}/DIAG",
},
}
$nfs_mounts3 = {
"/u01/oradata/$ARB_environment/data" => {
device => "$storage:/export/USLI-MIDTIER/$ARB_environment/DBDBF_CLONED",
},
"/u01/oradata/$ARB_environment/data1" => {
device => "10.2.14.35:/export/USLI-HIGHTIER/$ARB_environment/DBDBF1_CLONED",
},
"/u01/oradata/$ARB_environment/redo" => {
device => "$storage:/export/USLI-HIGHTIER/EBSDEV3/DBREDO",
},
"/u01/oradata/$ARB_environment/undo" => {
device => "$storage:/export/USLI-MIDTIER/$ARB_environment/DBUNDO_CLONED",
},
"/u01/oradata/$ARB_environment/temp" => {
device => "$storage:/export/USLI-HIGHTIER/DBTEMP/EBSDEV3",
},
"/u01/oradata/$ARB_environment/archdest1" => {
device => "${storage}:/export/USLI-MIDTIER/DBARCH/${ARB_environment}_DEST_1",
},
"/u01/oradata/$ARB_environment/archdest3" => {
device => "${storage}:/export/USLI-HIGHTIER/DBARCH/EBSDEV3_DEST_3",
},
"/u01/oradata/$ARB_environment/fra" => {
device => "$storage:/export/USLI-MIDTIER/$ARB_environment/DBFRA",
},
}

$nfs_mounts4 = {
'/software' => {
device => "$storage_archive:/export/NONPRD/STAGING/software",
},
'/scratch' => {
device => "$storage:/export/USLI-MIDTIER/UTILITY/SCRATCH",
},
}

create_resources(mount, $nfs_mounts1, $nfs_defaults1)
create_resources(mount, $nfs_mounts2, $nfs_defaults2)
create_resources(mount, $nfs_mounts3, $nfs_defaults3)
create_resources(mount, $nfs_mounts4, $nfs_defaults4)

#### NFS Mounts End
}

# pwd
/etc/puppet/environments

root@usli-utility:/etc/puppet/environments# hg commit
root@usli-utility:/etc/puppet/environments# cd ..
root@usli-utility:/etc/puppet# rsync -a --no-owner --no-group * /net/usli-psst-zf01.mgmt.asg.ad/export/NONPRD/UTILITY/CHANGELOGS/puppet/usli/

### Client
# svccfg -s svc:/application/puppet:agent setprop config/environment=DEV
# svcadm refresh puppet:agent
# svcadm restart puppet:agent

cat /etc/puppet/puppet.conf
# WARNING: THIS FILE GENERATED FROM SMF DATA.
# DO NOT EDIT THIS FILE. EDITS WILL BE LOST.
#
# See puppet.conf(5) and http://docs.puppetlabs.com/guides/configuring.html
# for details.
[agent]
environment = dev
logdest = /var/log/puppet/puppet-agent.log
server = usli-utility.mgmt.asg.ad

# puppet agent --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for usli-dsdb-eb31.dev.asg.ad
Info: Applying configuration version '1501606469'
Notice: Finished catalog run in 3.43 seconds