132
1 | 10 1 | 9 Super Sunday | WebLogic Hackathon Provisioning WebLogic using Puppet Ronald van Luttikhuizen December 1st | UKOUG Tech 2013

WebLogic Hackathon: Automated Provisioning using Puppet

Embed Size (px)

DESCRIPTION

This presentation accompanies a hands-on-lab session in which Puppet will be used to automatically provision Oracle WebLogic Server. Puppet is a tool to automate configuration management. Together with Chef it's one of the more popular configuration management tools at the moment. Puppet allows you to describe the desired (to-be) state of your servers by declaring resources. These declarations can describe user accounts, security settings, packages, directories, files, executable statements, services, and so on. Manifests are the files in which resource declarations are listed. Puppet periodically applies manifests by translating manifests into specific commands (catalogs) and executes those on the managed servers. Puppet is capable of inspecting the machines so it only applies those changes that are necessary. If a machine is already in the desired state Puppet will apply no changes.

Citation preview

Page 1: WebLogic Hackathon: Automated Provisioning using Puppet

1 | 10 1 | 9

Super Sunday | WebLogic Hackathon

Provisioning WebLogic using Puppet Ronald van Luttikhuizen

December 1st | UKOUG Tech 2013

2 | 10 2 | 9

Important | Before you start hellip

The powerpoint for this hands-on-lab contains several tasks for the

participants Most of the tasks are explained in more detail in the

sheets following the task description So make sure you inspect

the next sheets before starting on a new task

A lot of tasks in this hands-on-lab depend on the use of ldquovirdquo as

text editor Please help each other (yoursquore working in teams of

three) or shout for help if you donrsquot know vi Of course you are

allowed to use other text editors as well

3 | 10 3 | 9

Agenda

Labs

1 Setup amp preparation

2 Puppet Hello World

3 Provision JDK 7 using Puppet (and reusing the silent install scripts)

4 Provision WebLogic Server 12c using Puppet (and reusing the silent install scripts)

5 Bonus (1) Rewrite the Puppet modules (3 and 4) so we use native Puppet declarations instead of executing shell scripts

6 Bonus (2) Expand the Puppet ldquoweblogicrdquo module (4) with additional logic

References

1 Running PuTTY on Windows to edit files and run commands on VM

2 Running WinSCP on Windows to copy and move files to and from VM

3 Puppet Master installation

4 Puppet Agent installation

5 Useful Puppet commands and links

4 | 10 4 | 9

SETUP amp PREPARATION

Labs

5 | 10 5 | 9

VM ldquoUKOUG13_PuppetMasterrdquo

Puppet Enterprise (Master incl DB and Dashboard)

JDK 7 WLS 12c

Browser

pro

visi

on

ing

pro

vision

ing

dashboard

VM ldquoUKOUG13_PuppetAgent1rdquo

Puppet Enterprise (Agent 1)

JDK 7 WLS 12c pro

visi

on

ing

pro

vision

ing

VM ldquoUKOUG13_PuppetAgent2rdquo

Puppet Enterprise (Agent 2)

JDK 7 WLS 12c pro

visi

on

ing

pro

vision

ing

puppet catalogs puppet catalogs

Setup

6 | 10 6 | 9

Setup

Hostnames

Puppet Master puppetmasterlocaldomain

State Puppet Enterprise already installed

Dashboard usernamepassword masterukougorgwelcome1

Puppet Agent 1 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

Puppet Agent 2 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

7 | 10 7 | 9

Preparation

Summary

Form teams of three decide who will run the Puppet Master VM

(1x) and who will run the Puppet Agent VMs (2x)

Download andor install the necessary software

Perform a connectivity test since the Agents need to be able to

connect to the Master and vice versa

Inspect the Puppet Dashboard

8 | 10 8 | 9

Preparation

Form teams of 3 persons

One person is going to run a node with the Puppet Master (also

acts as local Puppet Agent)

VM requires 4GB of RAM

Two persons are going to run a node with a Puppet Agent

VM requires 2GB of RAM

All three will rollout a working Oracle WebLogic Server 12c

environment including JDK 7 using Puppet

9 | 10 9 | 9

Preparation

Start downloads of required software Oracle VirtualBox 432+ and VirtualBox Extension Pack 432+ Required to run VMs Download URL httpswwwvirtualboxorgwikiDownloads

Action Install on host machine

PuTTY Command-line tool that can be useful to interact with VMs from Windows Download URL httpwwwchiarkgreenendorguk~sgtathamputtydownloadhtml

Action Install on host machine (optional)

WinSCP Tool that can be useful to copy and move files between host (Windows) and VMs Download URL httpwinscpnetengdownloadphp

Action Install on host machine (optional)

JDK 7u45 Linux i586 (targz) Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkjavajavasedownloadsjdk7-downloads-1880260html

Action Copy to software directory of your VM using eg WinSCP

WebLogic 12c (1212) Generic Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkmiddlewareweblogicdownloadswls-for-dev-1703574html

Action Copy to software directory of your VM using eg WinSCP

Already present Puppet Enterprise (installed on the Puppet Master and the Puppet Agents)

10 | 10 10 | 9

Preparation | import appliance into VirtualBox

Puppet Master (1 person)

Import ldquoUKOUG_2013_Puppet_Masterovardquo

Puppet Agent (2 persons)

Import ldquoUKOUG_2013_Puppet_Agentovardquo

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 2: WebLogic Hackathon: Automated Provisioning using Puppet

2 | 10 2 | 9

Important | Before you start hellip

The powerpoint for this hands-on-lab contains several tasks for the

participants Most of the tasks are explained in more detail in the

sheets following the task description So make sure you inspect

the next sheets before starting on a new task

A lot of tasks in this hands-on-lab depend on the use of ldquovirdquo as

text editor Please help each other (yoursquore working in teams of

three) or shout for help if you donrsquot know vi Of course you are

allowed to use other text editors as well

3 | 10 3 | 9

Agenda

Labs

1 Setup amp preparation

2 Puppet Hello World

3 Provision JDK 7 using Puppet (and reusing the silent install scripts)

4 Provision WebLogic Server 12c using Puppet (and reusing the silent install scripts)

5 Bonus (1) Rewrite the Puppet modules (3 and 4) so we use native Puppet declarations instead of executing shell scripts

6 Bonus (2) Expand the Puppet ldquoweblogicrdquo module (4) with additional logic

References

1 Running PuTTY on Windows to edit files and run commands on VM

2 Running WinSCP on Windows to copy and move files to and from VM

3 Puppet Master installation

4 Puppet Agent installation

5 Useful Puppet commands and links

4 | 10 4 | 9

SETUP amp PREPARATION

Labs

5 | 10 5 | 9

VM ldquoUKOUG13_PuppetMasterrdquo

Puppet Enterprise (Master incl DB and Dashboard)

JDK 7 WLS 12c

Browser

pro

visi

on

ing

pro

vision

ing

dashboard

VM ldquoUKOUG13_PuppetAgent1rdquo

Puppet Enterprise (Agent 1)

JDK 7 WLS 12c pro

visi

on

ing

pro

vision

ing

VM ldquoUKOUG13_PuppetAgent2rdquo

Puppet Enterprise (Agent 2)

JDK 7 WLS 12c pro

visi

on

ing

pro

vision

ing

puppet catalogs puppet catalogs

Setup

6 | 10 6 | 9

Setup

Hostnames

Puppet Master puppetmasterlocaldomain

State Puppet Enterprise already installed

Dashboard usernamepassword masterukougorgwelcome1

Puppet Agent 1 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

Puppet Agent 2 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

7 | 10 7 | 9

Preparation

Summary

Form teams of three decide who will run the Puppet Master VM

(1x) and who will run the Puppet Agent VMs (2x)

Download andor install the necessary software

Perform a connectivity test since the Agents need to be able to

connect to the Master and vice versa

Inspect the Puppet Dashboard

8 | 10 8 | 9

Preparation

Form teams of 3 persons

One person is going to run a node with the Puppet Master (also

acts as local Puppet Agent)

VM requires 4GB of RAM

Two persons are going to run a node with a Puppet Agent

VM requires 2GB of RAM

All three will rollout a working Oracle WebLogic Server 12c

environment including JDK 7 using Puppet

9 | 10 9 | 9

Preparation

Start downloads of required software Oracle VirtualBox 432+ and VirtualBox Extension Pack 432+ Required to run VMs Download URL httpswwwvirtualboxorgwikiDownloads

Action Install on host machine

PuTTY Command-line tool that can be useful to interact with VMs from Windows Download URL httpwwwchiarkgreenendorguk~sgtathamputtydownloadhtml

Action Install on host machine (optional)

WinSCP Tool that can be useful to copy and move files between host (Windows) and VMs Download URL httpwinscpnetengdownloadphp

Action Install on host machine (optional)

JDK 7u45 Linux i586 (targz) Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkjavajavasedownloadsjdk7-downloads-1880260html

Action Copy to software directory of your VM using eg WinSCP

WebLogic 12c (1212) Generic Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkmiddlewareweblogicdownloadswls-for-dev-1703574html

Action Copy to software directory of your VM using eg WinSCP

Already present Puppet Enterprise (installed on the Puppet Master and the Puppet Agents)

10 | 10 10 | 9

Preparation | import appliance into VirtualBox

Puppet Master (1 person)

Import ldquoUKOUG_2013_Puppet_Masterovardquo

Puppet Agent (2 persons)

Import ldquoUKOUG_2013_Puppet_Agentovardquo

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 3: WebLogic Hackathon: Automated Provisioning using Puppet

3 | 10 3 | 9

Agenda

Labs

1 Setup amp preparation

2 Puppet Hello World

3 Provision JDK 7 using Puppet (and reusing the silent install scripts)

4 Provision WebLogic Server 12c using Puppet (and reusing the silent install scripts)

5 Bonus (1) Rewrite the Puppet modules (3 and 4) so we use native Puppet declarations instead of executing shell scripts

6 Bonus (2) Expand the Puppet ldquoweblogicrdquo module (4) with additional logic

References

1 Running PuTTY on Windows to edit files and run commands on VM

2 Running WinSCP on Windows to copy and move files to and from VM

3 Puppet Master installation

4 Puppet Agent installation

5 Useful Puppet commands and links

4 | 10 4 | 9

SETUP amp PREPARATION

Labs

5 | 10 5 | 9

VM ldquoUKOUG13_PuppetMasterrdquo

Puppet Enterprise (Master incl DB and Dashboard)

JDK 7 WLS 12c

Browser

pro

visi

on

ing

pro

vision

ing

dashboard

VM ldquoUKOUG13_PuppetAgent1rdquo

Puppet Enterprise (Agent 1)

JDK 7 WLS 12c pro

visi

on

ing

pro

vision

ing

VM ldquoUKOUG13_PuppetAgent2rdquo

Puppet Enterprise (Agent 2)

JDK 7 WLS 12c pro

visi

on

ing

pro

vision

ing

puppet catalogs puppet catalogs

Setup

6 | 10 6 | 9

Setup

Hostnames

Puppet Master puppetmasterlocaldomain

State Puppet Enterprise already installed

Dashboard usernamepassword masterukougorgwelcome1

Puppet Agent 1 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

Puppet Agent 2 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

7 | 10 7 | 9

Preparation

Summary

Form teams of three decide who will run the Puppet Master VM

(1x) and who will run the Puppet Agent VMs (2x)

Download andor install the necessary software

Perform a connectivity test since the Agents need to be able to

connect to the Master and vice versa

Inspect the Puppet Dashboard

8 | 10 8 | 9

Preparation

Form teams of 3 persons

One person is going to run a node with the Puppet Master (also

acts as local Puppet Agent)

VM requires 4GB of RAM

Two persons are going to run a node with a Puppet Agent

VM requires 2GB of RAM

All three will rollout a working Oracle WebLogic Server 12c

environment including JDK 7 using Puppet

9 | 10 9 | 9

Preparation

Start downloads of required software Oracle VirtualBox 432+ and VirtualBox Extension Pack 432+ Required to run VMs Download URL httpswwwvirtualboxorgwikiDownloads

Action Install on host machine

PuTTY Command-line tool that can be useful to interact with VMs from Windows Download URL httpwwwchiarkgreenendorguk~sgtathamputtydownloadhtml

Action Install on host machine (optional)

WinSCP Tool that can be useful to copy and move files between host (Windows) and VMs Download URL httpwinscpnetengdownloadphp

Action Install on host machine (optional)

JDK 7u45 Linux i586 (targz) Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkjavajavasedownloadsjdk7-downloads-1880260html

Action Copy to software directory of your VM using eg WinSCP

WebLogic 12c (1212) Generic Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkmiddlewareweblogicdownloadswls-for-dev-1703574html

Action Copy to software directory of your VM using eg WinSCP

Already present Puppet Enterprise (installed on the Puppet Master and the Puppet Agents)

10 | 10 10 | 9

Preparation | import appliance into VirtualBox

Puppet Master (1 person)

Import ldquoUKOUG_2013_Puppet_Masterovardquo

Puppet Agent (2 persons)

Import ldquoUKOUG_2013_Puppet_Agentovardquo

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 4: WebLogic Hackathon: Automated Provisioning using Puppet

4 | 10 4 | 9

SETUP amp PREPARATION

Labs

5 | 10 5 | 9

VM ldquoUKOUG13_PuppetMasterrdquo

Puppet Enterprise (Master incl DB and Dashboard)

JDK 7 WLS 12c

Browser

pro

visi

on

ing

pro

vision

ing

dashboard

VM ldquoUKOUG13_PuppetAgent1rdquo

Puppet Enterprise (Agent 1)

JDK 7 WLS 12c pro

visi

on

ing

pro

vision

ing

VM ldquoUKOUG13_PuppetAgent2rdquo

Puppet Enterprise (Agent 2)

JDK 7 WLS 12c pro

visi

on

ing

pro

vision

ing

puppet catalogs puppet catalogs

Setup

6 | 10 6 | 9

Setup

Hostnames

Puppet Master puppetmasterlocaldomain

State Puppet Enterprise already installed

Dashboard usernamepassword masterukougorgwelcome1

Puppet Agent 1 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

Puppet Agent 2 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

7 | 10 7 | 9

Preparation

Summary

Form teams of three decide who will run the Puppet Master VM

(1x) and who will run the Puppet Agent VMs (2x)

Download andor install the necessary software

Perform a connectivity test since the Agents need to be able to

connect to the Master and vice versa

Inspect the Puppet Dashboard

8 | 10 8 | 9

Preparation

Form teams of 3 persons

One person is going to run a node with the Puppet Master (also

acts as local Puppet Agent)

VM requires 4GB of RAM

Two persons are going to run a node with a Puppet Agent

VM requires 2GB of RAM

All three will rollout a working Oracle WebLogic Server 12c

environment including JDK 7 using Puppet

9 | 10 9 | 9

Preparation

Start downloads of required software Oracle VirtualBox 432+ and VirtualBox Extension Pack 432+ Required to run VMs Download URL httpswwwvirtualboxorgwikiDownloads

Action Install on host machine

PuTTY Command-line tool that can be useful to interact with VMs from Windows Download URL httpwwwchiarkgreenendorguk~sgtathamputtydownloadhtml

Action Install on host machine (optional)

WinSCP Tool that can be useful to copy and move files between host (Windows) and VMs Download URL httpwinscpnetengdownloadphp

Action Install on host machine (optional)

JDK 7u45 Linux i586 (targz) Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkjavajavasedownloadsjdk7-downloads-1880260html

Action Copy to software directory of your VM using eg WinSCP

WebLogic 12c (1212) Generic Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkmiddlewareweblogicdownloadswls-for-dev-1703574html

Action Copy to software directory of your VM using eg WinSCP

Already present Puppet Enterprise (installed on the Puppet Master and the Puppet Agents)

10 | 10 10 | 9

Preparation | import appliance into VirtualBox

Puppet Master (1 person)

Import ldquoUKOUG_2013_Puppet_Masterovardquo

Puppet Agent (2 persons)

Import ldquoUKOUG_2013_Puppet_Agentovardquo

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 5: WebLogic Hackathon: Automated Provisioning using Puppet

5 | 10 5 | 9

VM ldquoUKOUG13_PuppetMasterrdquo

Puppet Enterprise (Master incl DB and Dashboard)

JDK 7 WLS 12c

Browser

pro

visi

on

ing

pro

vision

ing

dashboard

VM ldquoUKOUG13_PuppetAgent1rdquo

Puppet Enterprise (Agent 1)

JDK 7 WLS 12c pro

visi

on

ing

pro

vision

ing

VM ldquoUKOUG13_PuppetAgent2rdquo

Puppet Enterprise (Agent 2)

JDK 7 WLS 12c pro

visi

on

ing

pro

vision

ing

puppet catalogs puppet catalogs

Setup

6 | 10 6 | 9

Setup

Hostnames

Puppet Master puppetmasterlocaldomain

State Puppet Enterprise already installed

Dashboard usernamepassword masterukougorgwelcome1

Puppet Agent 1 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

Puppet Agent 2 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

7 | 10 7 | 9

Preparation

Summary

Form teams of three decide who will run the Puppet Master VM

(1x) and who will run the Puppet Agent VMs (2x)

Download andor install the necessary software

Perform a connectivity test since the Agents need to be able to

connect to the Master and vice versa

Inspect the Puppet Dashboard

8 | 10 8 | 9

Preparation

Form teams of 3 persons

One person is going to run a node with the Puppet Master (also

acts as local Puppet Agent)

VM requires 4GB of RAM

Two persons are going to run a node with a Puppet Agent

VM requires 2GB of RAM

All three will rollout a working Oracle WebLogic Server 12c

environment including JDK 7 using Puppet

9 | 10 9 | 9

Preparation

Start downloads of required software Oracle VirtualBox 432+ and VirtualBox Extension Pack 432+ Required to run VMs Download URL httpswwwvirtualboxorgwikiDownloads

Action Install on host machine

PuTTY Command-line tool that can be useful to interact with VMs from Windows Download URL httpwwwchiarkgreenendorguk~sgtathamputtydownloadhtml

Action Install on host machine (optional)

WinSCP Tool that can be useful to copy and move files between host (Windows) and VMs Download URL httpwinscpnetengdownloadphp

Action Install on host machine (optional)

JDK 7u45 Linux i586 (targz) Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkjavajavasedownloadsjdk7-downloads-1880260html

Action Copy to software directory of your VM using eg WinSCP

WebLogic 12c (1212) Generic Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkmiddlewareweblogicdownloadswls-for-dev-1703574html

Action Copy to software directory of your VM using eg WinSCP

Already present Puppet Enterprise (installed on the Puppet Master and the Puppet Agents)

10 | 10 10 | 9

Preparation | import appliance into VirtualBox

Puppet Master (1 person)

Import ldquoUKOUG_2013_Puppet_Masterovardquo

Puppet Agent (2 persons)

Import ldquoUKOUG_2013_Puppet_Agentovardquo

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 6: WebLogic Hackathon: Automated Provisioning using Puppet

6 | 10 6 | 9

Setup

Hostnames

Puppet Master puppetmasterlocaldomain

State Puppet Enterprise already installed

Dashboard usernamepassword masterukougorgwelcome1

Puppet Agent 1 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

Puppet Agent 2 puppetagent1localdomain

State Puppet Enterprise installed but not yet configured

7 | 10 7 | 9

Preparation

Summary

Form teams of three decide who will run the Puppet Master VM

(1x) and who will run the Puppet Agent VMs (2x)

Download andor install the necessary software

Perform a connectivity test since the Agents need to be able to

connect to the Master and vice versa

Inspect the Puppet Dashboard

8 | 10 8 | 9

Preparation

Form teams of 3 persons

One person is going to run a node with the Puppet Master (also

acts as local Puppet Agent)

VM requires 4GB of RAM

Two persons are going to run a node with a Puppet Agent

VM requires 2GB of RAM

All three will rollout a working Oracle WebLogic Server 12c

environment including JDK 7 using Puppet

9 | 10 9 | 9

Preparation

Start downloads of required software Oracle VirtualBox 432+ and VirtualBox Extension Pack 432+ Required to run VMs Download URL httpswwwvirtualboxorgwikiDownloads

Action Install on host machine

PuTTY Command-line tool that can be useful to interact with VMs from Windows Download URL httpwwwchiarkgreenendorguk~sgtathamputtydownloadhtml

Action Install on host machine (optional)

WinSCP Tool that can be useful to copy and move files between host (Windows) and VMs Download URL httpwinscpnetengdownloadphp

Action Install on host machine (optional)

JDK 7u45 Linux i586 (targz) Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkjavajavasedownloadsjdk7-downloads-1880260html

Action Copy to software directory of your VM using eg WinSCP

WebLogic 12c (1212) Generic Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkmiddlewareweblogicdownloadswls-for-dev-1703574html

Action Copy to software directory of your VM using eg WinSCP

Already present Puppet Enterprise (installed on the Puppet Master and the Puppet Agents)

10 | 10 10 | 9

Preparation | import appliance into VirtualBox

Puppet Master (1 person)

Import ldquoUKOUG_2013_Puppet_Masterovardquo

Puppet Agent (2 persons)

Import ldquoUKOUG_2013_Puppet_Agentovardquo

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 7: WebLogic Hackathon: Automated Provisioning using Puppet

7 | 10 7 | 9

Preparation

Summary

Form teams of three decide who will run the Puppet Master VM

(1x) and who will run the Puppet Agent VMs (2x)

Download andor install the necessary software

Perform a connectivity test since the Agents need to be able to

connect to the Master and vice versa

Inspect the Puppet Dashboard

8 | 10 8 | 9

Preparation

Form teams of 3 persons

One person is going to run a node with the Puppet Master (also

acts as local Puppet Agent)

VM requires 4GB of RAM

Two persons are going to run a node with a Puppet Agent

VM requires 2GB of RAM

All three will rollout a working Oracle WebLogic Server 12c

environment including JDK 7 using Puppet

9 | 10 9 | 9

Preparation

Start downloads of required software Oracle VirtualBox 432+ and VirtualBox Extension Pack 432+ Required to run VMs Download URL httpswwwvirtualboxorgwikiDownloads

Action Install on host machine

PuTTY Command-line tool that can be useful to interact with VMs from Windows Download URL httpwwwchiarkgreenendorguk~sgtathamputtydownloadhtml

Action Install on host machine (optional)

WinSCP Tool that can be useful to copy and move files between host (Windows) and VMs Download URL httpwinscpnetengdownloadphp

Action Install on host machine (optional)

JDK 7u45 Linux i586 (targz) Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkjavajavasedownloadsjdk7-downloads-1880260html

Action Copy to software directory of your VM using eg WinSCP

WebLogic 12c (1212) Generic Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkmiddlewareweblogicdownloadswls-for-dev-1703574html

Action Copy to software directory of your VM using eg WinSCP

Already present Puppet Enterprise (installed on the Puppet Master and the Puppet Agents)

10 | 10 10 | 9

Preparation | import appliance into VirtualBox

Puppet Master (1 person)

Import ldquoUKOUG_2013_Puppet_Masterovardquo

Puppet Agent (2 persons)

Import ldquoUKOUG_2013_Puppet_Agentovardquo

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 8: WebLogic Hackathon: Automated Provisioning using Puppet

8 | 10 8 | 9

Preparation

Form teams of 3 persons

One person is going to run a node with the Puppet Master (also

acts as local Puppet Agent)

VM requires 4GB of RAM

Two persons are going to run a node with a Puppet Agent

VM requires 2GB of RAM

All three will rollout a working Oracle WebLogic Server 12c

environment including JDK 7 using Puppet

9 | 10 9 | 9

Preparation

Start downloads of required software Oracle VirtualBox 432+ and VirtualBox Extension Pack 432+ Required to run VMs Download URL httpswwwvirtualboxorgwikiDownloads

Action Install on host machine

PuTTY Command-line tool that can be useful to interact with VMs from Windows Download URL httpwwwchiarkgreenendorguk~sgtathamputtydownloadhtml

Action Install on host machine (optional)

WinSCP Tool that can be useful to copy and move files between host (Windows) and VMs Download URL httpwinscpnetengdownloadphp

Action Install on host machine (optional)

JDK 7u45 Linux i586 (targz) Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkjavajavasedownloadsjdk7-downloads-1880260html

Action Copy to software directory of your VM using eg WinSCP

WebLogic 12c (1212) Generic Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkmiddlewareweblogicdownloadswls-for-dev-1703574html

Action Copy to software directory of your VM using eg WinSCP

Already present Puppet Enterprise (installed on the Puppet Master and the Puppet Agents)

10 | 10 10 | 9

Preparation | import appliance into VirtualBox

Puppet Master (1 person)

Import ldquoUKOUG_2013_Puppet_Masterovardquo

Puppet Agent (2 persons)

Import ldquoUKOUG_2013_Puppet_Agentovardquo

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 9: WebLogic Hackathon: Automated Provisioning using Puppet

9 | 10 9 | 9

Preparation

Start downloads of required software Oracle VirtualBox 432+ and VirtualBox Extension Pack 432+ Required to run VMs Download URL httpswwwvirtualboxorgwikiDownloads

Action Install on host machine

PuTTY Command-line tool that can be useful to interact with VMs from Windows Download URL httpwwwchiarkgreenendorguk~sgtathamputtydownloadhtml

Action Install on host machine (optional)

WinSCP Tool that can be useful to copy and move files between host (Windows) and VMs Download URL httpwinscpnetengdownloadphp

Action Install on host machine (optional)

JDK 7u45 Linux i586 (targz) Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkjavajavasedownloadsjdk7-downloads-1880260html

Action Copy to software directory of your VM using eg WinSCP

WebLogic 12c (1212) Generic Will be provisioned on VMs using Puppet Download URL httpwwworaclecomtechnetworkmiddlewareweblogicdownloadswls-for-dev-1703574html

Action Copy to software directory of your VM using eg WinSCP

Already present Puppet Enterprise (installed on the Puppet Master and the Puppet Agents)

10 | 10 10 | 9

Preparation | import appliance into VirtualBox

Puppet Master (1 person)

Import ldquoUKOUG_2013_Puppet_Masterovardquo

Puppet Agent (2 persons)

Import ldquoUKOUG_2013_Puppet_Agentovardquo

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 10: WebLogic Hackathon: Automated Provisioning using Puppet

10 | 10 10 | 9

Preparation | import appliance into VirtualBox

Puppet Master (1 person)

Import ldquoUKOUG_2013_Puppet_Masterovardquo

Puppet Agent (2 persons)

Import ldquoUKOUG_2013_Puppet_Agentovardquo

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 11: WebLogic Hackathon: Automated Provisioning using Puppet

11 | 10 11 | 9

Preparation | import appliance into VirtualBox

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 12: WebLogic Hackathon: Automated Provisioning using Puppet

12 | 10 12 | 9

Preparation | import appliance into VirtualBox

Make sure that you put a check mark in Reinitialize the MAC address of all network cards If you do not do this we will end up with several machines with the same MAC address which can mean that the network will not work Make sure that you allocate at least 4096 MB for the Puppet Master and 2048 MB for the Puppet Agent

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 13: WebLogic Hackathon: Automated Provisioning using Puppet

13 | 10 13 | 9

Preparation | import appliance into VirtualBox

You might get a warning about network interfaces when importing the VM In this case click ldquoChange Network Settingsrdquo and continue This should resolve the issue

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 14: WebLogic Hackathon: Automated Provisioning using Puppet

14 | 10 14 | 9

Preparation | network setup

Steps for all Start VM

Login on CentOS Namepwd rootwelcome1

Inspect the ip address of ldquoeth0rdquo [rootpuppetagent1 ~] ip addr show

or

[rootpuppetagent1 ~] ifconfig

If only ldquolordquo is listed and not ldquoeth0rdquo then run [rootpuppetagent1 ~] ~deleteUdevRulessh

[rootpuppetagent1 ~] shutdown ndashr now

Retry

Note Press ldquoF1rdquo when Linux is booting to see details about what is happening

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 15: WebLogic Hackathon: Automated Provisioning using Puppet

15 | 10 15 | 9

Preparation | network setup

Steps for all (continued) Make sure that the firewall(s) on the host machines donrsquot block traffic between the VMs running the Puppet Master and Puppet Agents

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 16: WebLogic Hackathon: Automated Provisioning using Puppet

16 | 10 16 | 9

Preparation | network setup

Steps for Puppet Master None

Steps for Puppet Agent 1 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent1 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master

[rootpuppetagent1 ~] ping puppetmaster

[rootpuppetagent1 ~] ping puppetmasterlocaldomain

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 17: WebLogic Hackathon: Automated Provisioning using Puppet

17 | 10 17 | 9

Preparation | network setup

Steps for Puppet Agent 2 Change the VM hostname to puppetagent2 by editing the file etcsysconfignetwork

[rootpuppetagent2 ~] vi etcsysconfig

Change puppetagent1 to puppetagent2 Enable lookup and ping of the Puppet Master by editing the file etchosts

[rootpuppetagent2 ~] vi etchosts

Add a new line 1921681107 puppetmaster puppetmasterlocaldomain

In which you replace 1921681107 with the actual IP-address of the Puppet Master

Verify that you can ping the Puppet Master run

[rootpuppetagent2 ~] ping puppetmaster

[rootpuppetagent2 ~] ping puppetmasterlocaldomain

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 18: WebLogic Hackathon: Automated Provisioning using Puppet

18 | 10 18 | 9

Preparation | network setup

Verify network settings Run the following on the Puppet Agent 1 and Puppet Agent 2

[rootpuppetagent2 ~] telnet puppetmaster 8141

or

[rootpuppetagent2 ~] nmap -P0 -p 8140 puppetmaster

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 19: WebLogic Hackathon: Automated Provisioning using Puppet

19 | 10 19 | 9

Preparation | time

Make sure that the VMsrsquo clocks are in sync Run the following command on the Master and Agents at (almost) the same time to synch the clocks

[rootpuppetmaster ] date +T -s hhmmss where hh = hours mm = minutes and ss = seconds for example [rootpuppetmaster ] date +T -s 141000 ndashu

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 20: WebLogic Hackathon: Automated Provisioning using Puppet

20 | 10 20 | 9

For your information | puppet agent status

Puppet status By default the Puppet Agent runs every 30 min as a background process To have a better view of what is going on the Agent process is disabled on the VMs

[rootpuppetagent1] etcinitdpe-puppet status

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 21: WebLogic Hackathon: Automated Provisioning using Puppet

21 | 10 21 | 9

For your information | directories

Puppet directories Puppet Enterprise is installed in optpuppet Puppet configuration files including modules and manifests are stored in etcpuppetlabspuppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 22: WebLogic Hackathon: Automated Provisioning using Puppet

22 | 10 22 | 9

Installing Puppet

Confirm installation by retrieving Puppet version

[rootpuppetagent1] puppet --version

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 23: WebLogic Hackathon: Automated Provisioning using Puppet

23 | 10 23 | 9

Installing Puppet

Confirm installation by retrieving facts of the system

[rootpuppetagent1] facter

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 24: WebLogic Hackathon: Automated Provisioning using Puppet

24 | 10 24 | 9

Inspect the Puppet Console and create users

1 Open browser and navigate to https[puppetmaster] where

[puppetmaster] is the IP-address or server name of the server

where the Puppet Master runs

2 Login using masterukougorgwelcome1

3 Inspect the Puppet Console

4 Add users agent1ukougorg and agent2ukougorg (both with

password welcome1 and admin role) by navigating to master

(dropdown in top-right corner) Admin Tools

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 25: WebLogic Hackathon: Automated Provisioning using Puppet

25 | 10 25 | 9

Inspect the Puppet Console | login

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 26: WebLogic Hackathon: Automated Provisioning using Puppet

26 | 10 26 | 9

Inspect the Puppet Console | homepage

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 27: WebLogic Hackathon: Automated Provisioning using Puppet

27 | 10 27 | 9

Inspect the Puppet Console | add users

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 28: WebLogic Hackathon: Automated Provisioning using Puppet

28 | 10 28 | 9

Inspect the Puppet Console | user activation

Click activation link per new user (link may need rewriting)

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 29: WebLogic Hackathon: Automated Provisioning using Puppet

29 | 10 29 | 9

Inspect the Puppet Console | user activation

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 30: WebLogic Hackathon: Automated Provisioning using Puppet

30 | 10 30 | 9

Inspect the Puppet Console | user activation

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 31: WebLogic Hackathon: Automated Provisioning using Puppet

31 | 10 31 | 9

PUPPET HELLO WORLD

Labs

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 32: WebLogic Hackathon: Automated Provisioning using Puppet

32 | 10 32 | 9

Puppet Hello World

Summary

Create your first Puppet Manifest and run it locally (serverless

Puppet)

Enlist the Puppet Agent with the Puppet Master and run the

Manifest in a MasterAgent setup

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 33: WebLogic Hackathon: Automated Provisioning using Puppet

33 | 10 33 | 9

Puppet Hello World | create your first manifest

Create top-level manifest directory for Puppet in

homepuppetmanifests

[rootpuppetmaster ] cd home

[rootpuppetmaster home] mkdir puppet

[rootpuppetmaster home] cd puppet

[rootpuppetmaster puppet] mkdir manifests

[rootpuppetmaster puppet] cd manifests

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 34: WebLogic Hackathon: Automated Provisioning using Puppet

34 | 10 34 | 9

Puppet Hello World | create your first manifest

Create sitepp manifest

[rootpuppetmaster manifests] vi sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 35: WebLogic Hackathon: Automated Provisioning using Puppet

35 | 10 35 | 9

Puppet Hello World | create your first manifest

Validate sitepp manifest

[rootpuppetmaster manifests] puppet parser validate sitepp

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 36: WebLogic Hackathon: Automated Provisioning using Puppet

36 | 10 36 | 9

Puppet Hello World | create your first manifest

Simulate run of sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp --noop

Indicates that two file resources are absent and would be created

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 37: WebLogic Hackathon: Automated Provisioning using Puppet

37 | 10 37 | 9

Puppet Hello World | create your first manifest

Run sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 38: WebLogic Hackathon: Automated Provisioning using Puppet

38 | 10 38 | 9

Puppet Hello World | create your first manifest

Verify that file is created

[rootpuppetmaster manifests] cat tmppuppetdemohelloworldtxt

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 39: WebLogic Hackathon: Automated Provisioning using Puppet

39 | 10 39 | 9

Puppet Hello World | create your first manifest

Rerun sitepp manifest

[rootpuppetmaster manifests] puppet apply sitepp

No changes applied system is in desired state

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 40: WebLogic Hackathon: Automated Provisioning using Puppet

40 | 10 40 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] vi tmppuppetdemohelloworldtxt

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 41: WebLogic Hackathon: Automated Provisioning using Puppet

41 | 10 41 | 9

Puppet Hello World | create your first manifest

Edit tmppuppetdemohelloworldtxt and rerun manifest

[rootpuppetmaster manifests] puppet apply sitepp

One change applied only file contents are changed by Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 42: WebLogic Hackathon: Automated Provisioning using Puppet

42 | 10 42 | 9

Puppet Hello World | enlisting agents

Trigger enlistment of Agent to Master by running the

puppet agent command on agent1 and agent2

[rootpuppetagent1 ~] puppet agent --test

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 43: WebLogic Hackathon: Automated Provisioning using Puppet

43 | 10 43 | 9

Puppet Hello World | enlisting agents

Console Node Requests (2) Pending node requests (2)

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 44: WebLogic Hackathon: Automated Provisioning using Puppet

44 | 10 44 | 9

Puppet Hello World | enlisting agents

Accept requests Accept All

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 45: WebLogic Hackathon: Automated Provisioning using Puppet

45 | 10 45 | 9

Puppet Agent | rerun Hello World as Agent

Rerun puppet agent --test on the Puppet Agents and Master

to retrieve required Puppet configuration (after this steps

the nodes are listed in the Console)

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 46: WebLogic Hackathon: Automated Provisioning using Puppet

46 | 10 46 | 9

Puppet Hello World | enlisting agents

Nodes are enlisted

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 47: WebLogic Hackathon: Automated Provisioning using Puppet

47 | 10 47 | 9

Puppet Agent | rerun Hello World as Agent

Delete tmppuppetdemo on both Puppet Agents and Master [rootpuppetagent1 ~] rm -rf tmppuppetdemo

Edit the Puppet Master sitepp manifest [rootpuppetmaster ~] vi etcpuppetlabspuppetmanifestssitepp

Add the two file resources to the sitepp file (just above the node declaration) that we added earlier to the local sitepp

file tmppuppetdemo

ensure =gt directory

file tmppuppetdemohelloworldtxt

content =gt Hello World Puppet

require =gt File[tmppuppetdemo]

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 48: WebLogic Hackathon: Automated Provisioning using Puppet

48 | 10 48 | 9

Puppet Agent | rerun Hello World as Agent

Run from Console Live Management Control Puppet Runonce Run

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 49: WebLogic Hackathon: Automated Provisioning using Puppet

49 | 10 49 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 50: WebLogic Hackathon: Automated Provisioning using Puppet

50 | 10 50 | 9

Puppet Agent | inspect the state and changes in Console

Nodes All select node Select latest report

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 51: WebLogic Hackathon: Automated Provisioning using Puppet

51 | 10 51 | 9

Puppet Agent | compare resources of nodes in Console

Live Management Browse Resources Inspect All

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 52: WebLogic Hackathon: Automated Provisioning using Puppet

52 | 10 52 | 9

PROVISIONING JDK 7

Labs

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 53: WebLogic Hackathon: Automated Provisioning using Puppet

53 | 10 53 | 9

Provision JDK 7 on VMs using Puppet

Summary

Inspect the directories and files in the module ldquojavardquo

Create the module ldquojavardquo on Puppet Master with an initpp manifest for installing JDK 7

Include the ldquojavardquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify JDK 7 installation

Inspect Puppet Console

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 54: WebLogic Hackathon: Automated Provisioning using Puppet

54 | 10 54 | 9

Provision JDK 7 on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the jdk-7u45-linux-i586targz locally

Copy the JDK file from your local machine (host) to the

software directory of the VM (guest) You can use WinSCP for

this See the following section in this presentation ldquoRunning

WinSCP on Windows to copy and move files to and from VMrdquo

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 55: WebLogic Hackathon: Automated Provisioning using Puppet

55 | 10 55 | 9

Inspect ldquojavardquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetJavaModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetJavaModulejavafilesscripts

Inspect the directory structure

Directory Description

java Root directory of the Puppet ldquojavardquo module A module is a self-contained bundle of code and data

javamanifests Directory containing the resource declarations (Puppet code) for this module The file initpp is mandatory

javafiles Directory containing the files (scripts binaries etc) that are needed by this module

javafilesscripts Subdirectory containing scripts from the silent install lab that will be used to install JDK 7 using Puppet

javafilessoftware Subdirectory that will contain the JDK 7 binary

javalib Directory containing plugins for the module

javalibfacter Subdirectory that contains a custom fact (in Ruby) that determines if JDK 7 has been installed or not

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 56: WebLogic Hackathon: Automated Provisioning using Puppet

56 | 10 56 | 9

Inspect ldquojavardquo module

Inspect the java_directory_existsrb file in the javalibfacter directory This file contains a (simplified) Ruby script that checks if JDK 7 has been installed This is done by checking the existence of the u01apporacleproductjdk170_45 directory The result will be stored in the custom fact ldquojava_directory_existsrdquo We donrsquot want Puppet to reinstall JDK 7 everytime the Puppet Agent runs We need a way to let Puppet know that JDK 7 has been installed using a fact

Inspect the initpp file in the javamanifests directory This file contains the manifest (Puppet code or system declaration) for installing JDK 7 It will check the ldquojava_directory_existsrdquo fact to determine if JDK 7 needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install JDK 7

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 57: WebLogic Hackathon: Automated Provisioning using Puppet

57 | 10 57 | 9

Create ldquojavardquo module on Puppet Master

Create ldquojavardquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesjava

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetJavaModulejava

etcpuppetlabspuppetmodulesjava

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 58: WebLogic Hackathon: Automated Provisioning using Puppet

58 | 10 58 | 9

Include ldquojavardquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Replace the node declaration (ldquonode default rdquo) with the following node puppetmaster puppetagent1 puppetagent2

include java

This will apply the Java class (JDK 7 installation) to the puppetmaster puppetagent1 and puppetagent2 nodes

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 59: WebLogic Hackathon: Automated Provisioning using Puppet

59 | 10 59 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 60: WebLogic Hackathon: Automated Provisioning using Puppet

60 | 10 60 | 9

Verify JDK 7 installation

[rootpuppetmaster ] cd u01apporacleproductjdk170_45bin

[rootpuppetmaster ] java -version

[rootpuppetagent1 ] java -version

[rootpuppetagent2 ] java -version

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 61: WebLogic Hackathon: Automated Provisioning using Puppet

61 | 10 61 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 62: WebLogic Hackathon: Automated Provisioning using Puppet

62 | 10 62 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent2 select report

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 63: WebLogic Hackathon: Automated Provisioning using Puppet

63 | 10 63 | 9

Removing JDK 7

Rerun the Puppet Agent command Puppet knows that JDK 7 has been installed and wonrsquot perform any actions

If you want to reinstall JDK 7 using Puppet then remove JDK 7 by deleting the JDK directory

[rootpuppetmaster ] rm -rf u01apporacleproductjdk170_45

Or run softwarejavascriptsrollbacksh to delete all Oracle software

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 64: WebLogic Hackathon: Automated Provisioning using Puppet

64 | 10 64 | 9

PROVISIONING WLS 12C

Labs

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 65: WebLogic Hackathon: Automated Provisioning using Puppet

65 | 10 65 | 9

Provision WLS 12c on VMs using Puppet

Summary

Inspect the directories and files in the module ldquoweblogicrdquo

Create the module ldquoweblogicrdquo on Puppet Master with an initpp manifest for installing WebLogic Server 12c

Include the ldquoweblogicrdquo class in the Puppet Master sitepp manifest and declare it to have it applied

Trigger a run on the Puppet Agents and Puppet Master

Verify WebLogic 12c installation

Inspect Puppet Console

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 66: WebLogic Hackathon: Automated Provisioning using Puppet

66 | 10 66 | 9

Provision WLS 12c on VMs using Puppet

Preparation

Puppet Agents normally retrieve binaries (and other large files)

from a central location such as yum Puppet Master artifact

repository etc To avoid overloading of the SuperSunday network

though we need to copy the wls_121200jar locally Copy the

WLS file from your local machine (host) to the software

directory of the VM (guest) You can use WinSCP for this See the

following section in this presentation ldquoRunning WinSCP on

Windows to copy and move files to and from VMrdquo

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 67: WebLogic Hackathon: Automated Provisioning using Puppet

67 | 10 67 | 9

Inspect ldquoweblogicrdquo module

Unpack the java module

[rootpuppetmaster ] cd software

[rootpuppetmaster ] unzip puppetWeblogicModulezip

Grant execute rights on the scripts that will be used

[rootpuppetmaster ] chmod -R a=rwx softwarepuppetWeblogicModuleweblogicfilesscripts

Inspect the directory structure

Directory Description

weblogic Root directory of the Puppet ldquoweblogicrdquo module A module is a self-contained bundle of code and data

weblogicmanifests Directory containing the resource declarations for this module The file initpp is mandatory

weblogicfiles Directory containing the files (scripts binaries etc) that are needed by this module

weblogicfilesscripts Subdirectory containing scripts from the silent install lab that will be used to install WLS using Puppet

weblogicfilessoftware Subdirectory that will contain the WLS binary

weblogiclib Directory containing plugins for the module

weblogiclibfacter Subdirectory that contains a custom fact (in Ruby) that determines if WLS 12c has been installed or not

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 68: WebLogic Hackathon: Automated Provisioning using Puppet

68 | 10 68 | 9

Inspect ldquoweblogicrdquo module

Inspect the rb files in the weblogiclibfacter directory This directory contains (simplified) Ruby scripts that check if WebLogic Server has been installed and the domain directory has been created This is done by checking the existence of certain directories The result will be stored in the custom facts ldquoweblogic_server_directory_existsrdquo and ldquoweblogic_domain_directory_existsrdquo We donrsquot want Puppet to reinstall WLS 12c everytime the Puppet Agent runs We need a way to let Puppet know that WLS 12c has been installed using a fact

Inspect the initpp file in the weblogicmanifests directory This file contains the manifest (Puppet code or system declaration) for installing WLS 12c It will check the ldquoweblogic_server_directory_existsrdquo fact to determine if WLS 12c needs to be installed If not it will create the necessary directories copy the required files to the Puppet Agent (remember the Puppet Master can also act as Puppet Agent) and then executes the silent install scripts we saw earlier to install WLS 12c and create the domain

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 69: WebLogic Hackathon: Automated Provisioning using Puppet

69 | 10 69 | 9

Create ldquoweblogicrdquo module on Puppet Master

Create ldquoweblogicrdquo module directory on Puppet Master [rootpuppetmaster ] mkdir etcpuppetlabspuppetmodulesweblogic

Copy module files from software directory on Puppet

Master [rootpuppetmaster ] cp -r softwarepuppetWeblogicModuleweblogic

etcpuppetlabspuppetmodulesweblogic

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 70: WebLogic Hackathon: Automated Provisioning using Puppet

70 | 10 70 | 9

Include ldquoweblogicrdquo class in sitepp manifest

Edit the sitepp file on Puppet Master [rootpuppetmaster ] vi etcpuppetlabspuppetmanifestssitepp

Expand the node declaration with the following node puppetmaster puppetagent1 puppetagent2

include java

include weblogic

Class[java] -gt Class[weblogic]

This will apply the ldquojavardquo and ldquoweblogicrdquo class to the puppetmaster puppetagent1 and puppetagent2 nodes The ldquoweblogicrdquo class is dependent on the ldquojavardquo class

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 71: WebLogic Hackathon: Automated Provisioning using Puppet

71 | 10 71 | 9

Trigger a run on the Puppet Master and Agents

[rootpuppetmaster ] puppet agent --test

[rootpuppetagent1 ] puppet agent --test

[rootpuppetagent2 ] puppet agent --test

The output of the install server and create domain scripts is only displayed after the installation so be patient when running the agent

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 72: WebLogic Hackathon: Automated Provisioning using Puppet

72 | 10 72 | 9

Verify WebLogic 12c installation

Inspect the WLS 12c directories in u01apporacle

Manually perform the steps from WebLogic Hackathon

WebLogic Server Installation and Automationpdf beginning

from ldquoStart the Node Managerrdquo

This should result in an up-and-running WebLogic Server

You can check the WebLogic Console

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 73: WebLogic Hackathon: Automated Provisioning using Puppet

73 | 10 73 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 74: WebLogic Hackathon: Automated Provisioning using Puppet

74 | 10 74 | 9

Inspect Puppet Console | node reports

Nodes Changed puppetagent1 select report

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 75: WebLogic Hackathon: Automated Provisioning using Puppet

75 | 10 75 | 9

Removing WLS 12c

Rerun the Puppet Agent command Puppet knows that WLS 12c has been installed and wonrsquot perform any actions

If you want to reinstall WLS 12c using Puppet then remove WLS 12c by running the rollback script Note this will also remove JDK 7

[rootpuppetmaster ] softwareweblogicscriptsrollbacksh

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 76: WebLogic Hackathon: Automated Provisioning using Puppet

76 | 10 76 | 9

Verify install after remainder of steps

Open the Oracle WebLogic Server 12c Console

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 77: WebLogic Hackathon: Automated Provisioning using Puppet

77 | 10 77 | 9

BONUS (1) REWRITE JAVA amp

WEBLOGIC MODULES

Labs

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 78: WebLogic Hackathon: Automated Provisioning using Puppet

78 | 10 78 | 9

Rewrite ldquojavardquo and ldquoweblogicrdquo modules

Objective

In the previous two labs we have reused the silent install scripts in

the Puppet modules ldquojavardquo and ldquoweblogicrdquo This way Puppet was

used as a wrapper that manages these scripts The commands in

these scripts also manage and alter resources (files directories

executions etc) that can also be directly managed by Puppet

Translate the commands in the scripts to Puppet resource types so

we wonrsquot be executing a bunch of specific scripts any more This

way we can run the modules on more platforms and operating

systems and parameterize the modules

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 79: WebLogic Hackathon: Automated Provisioning using Puppet

79 | 10 79 | 9

BONUS (2) EXPAND WEBLOGIC

MODULE

Labs

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 80: WebLogic Hackathon: Automated Provisioning using Puppet

80 | 10 80 | 9

Expand ldquoweblogicrdquo module

Objective

Expand the ldquoweblogicrdquo module so that it will

install WLS 12c and create a WLS domain when nothing is installed

yet

only create a WLS domain when WLS 12c is installed but no domain

has been created yet

Expand the ldquoweblogicrdquo module so that the Node Manager the

Admin Server and Managed Server are started automatically by

Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 81: WebLogic Hackathon: Automated Provisioning using Puppet

81 | 10 81 | 9

RUNNING PUTTY

References

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 82: WebLogic Hackathon: Automated Provisioning using Puppet

82 | 10 82 | 9

Running PuTTY | know SSH port to connect to VM

PuTTY connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 83: WebLogic Hackathon: Automated Provisioning using Puppet

83 | 10 83 | 9

Running PuTTY | start VM

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 84: WebLogic Hackathon: Automated Provisioning using Puppet

84 | 10 84 | 9

Running PuTTY | connect to VM using PuTTY

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 85: WebLogic Hackathon: Automated Provisioning using Puppet

85 | 10 85 | 9

Running PuTTY | edit file

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 86: WebLogic Hackathon: Automated Provisioning using Puppet

86 | 10 86 | 9

RUNNING WINSCP

References

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 87: WebLogic Hackathon: Automated Provisioning using Puppet

87 | 10 87 | 9

Running WinSCP| know SSH port to connect to VM

WinSCP connects to VM on the SSH port The default SSH port is 22

Exception when using NAT with port forwarding enabled you can

assign a different port that redirects to the SSH port of the VM

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 88: WebLogic Hackathon: Automated Provisioning using Puppet

88 | 10 88 | 9

Running WinSCP | start VM

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 89: WebLogic Hackathon: Automated Provisioning using Puppet

89 | 10 89 | 9

Running WinSCP| connect to VM using WinSCP

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 90: WebLogic Hackathon: Automated Provisioning using Puppet

90 | 10 90 | 9

PUPPET MASTER INSTALLATION

References

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 91: WebLogic Hackathon: Automated Provisioning using Puppet

91 | 10 91 | 9

Installing Puppet Master

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 92: WebLogic Hackathon: Automated Provisioning using Puppet

92 | 10 92 | 9

Installing Puppet Master

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 93: WebLogic Hackathon: Automated Provisioning using Puppet

93 | 10 93 | 9

Installing Puppet Master

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 94: WebLogic Hackathon: Automated Provisioning using Puppet

94 | 10 94 | 9

Installing Puppet Master

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 95: WebLogic Hackathon: Automated Provisioning using Puppet

95 | 10 95 | 9

Installing Puppet Master

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 96: WebLogic Hackathon: Automated Provisioning using Puppet

96 | 10 96 | 9

Installing Puppet Master

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 97: WebLogic Hackathon: Automated Provisioning using Puppet

97 | 10 97 | 9

Installing Puppet Master

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 98: WebLogic Hackathon: Automated Provisioning using Puppet

98 | 10 98 | 9

Installing Puppet Master

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 99: WebLogic Hackathon: Automated Provisioning using Puppet

99 | 10 99 | 9

Installing Puppet Master

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 100: WebLogic Hackathon: Automated Provisioning using Puppet

100 | 10 100 | 9

Installing Puppet Master

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 101: WebLogic Hackathon: Automated Provisioning using Puppet

101 | 10 101 | 9

Installing Puppet Master

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 102: WebLogic Hackathon: Automated Provisioning using Puppet

102 | 10 102 | 9

Installing Puppet Master

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 103: WebLogic Hackathon: Automated Provisioning using Puppet

103 | 10 103 | 9

Installing Puppet Master

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 104: WebLogic Hackathon: Automated Provisioning using Puppet

104 | 10 104 | 9

Installing Puppet Master

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 105: WebLogic Hackathon: Automated Provisioning using Puppet

105 | 10 105 | 9

Installing Puppet Master

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 106: WebLogic Hackathon: Automated Provisioning using Puppet

106 | 10 106 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 107: WebLogic Hackathon: Automated Provisioning using Puppet

107 | 10 107 | 9

Installing Puppet Master | verify by opening dashboard

Dashboard runs on httpslocalhost (default port 443 mind port number if using NAT and port forwarding for VM)

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 108: WebLogic Hackathon: Automated Provisioning using Puppet

108 | 10 108 | 9

Installing Puppet Master | verify by opening dashboard

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 109: WebLogic Hackathon: Automated Provisioning using Puppet

109 | 10 109 | 9

PUPPET AGENT INSTALLATION

References

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 110: WebLogic Hackathon: Automated Provisioning using Puppet

110 | 10 110 | 9

Installing Puppet Agent

Puppet Enterprise is already installed on the Puppet Master and Puppet Agents The Puppet Enterprise software is present on the VMs in the directory software

Log into the Puppet Agent VM and run

[rootpuppetagent1 software] tar -xzf puppet-enterprise-310-el-6-i386targz

[rootpuppetagent1 software] cd puppet-enterprise-310-el-6-i386

[rootpuppetagent1 puppet-enterprise-310-el-6-i386] puppet-enterprise-installer

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 111: WebLogic Hackathon: Automated Provisioning using Puppet

111 | 10 111 | 9

Installing Puppet Agent

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 112: WebLogic Hackathon: Automated Provisioning using Puppet

112 | 10 112 | 9

Installing Puppet Agent

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 113: WebLogic Hackathon: Automated Provisioning using Puppet

113 | 10 113 | 9

Installing Puppet Agent

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 114: WebLogic Hackathon: Automated Provisioning using Puppet

114 | 10 114 | 9

Installing Puppet Agent

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 115: WebLogic Hackathon: Automated Provisioning using Puppet

115 | 10 115 | 9

Installing Puppet Agent

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 116: WebLogic Hackathon: Automated Provisioning using Puppet

116 | 10 116 | 9

Installing Puppet Agent

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 117: WebLogic Hackathon: Automated Provisioning using Puppet

117 | 10 117 | 9

Installing Puppet Agent

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 118: WebLogic Hackathon: Automated Provisioning using Puppet

118 | 10 118 | 9

Installing Puppet Agent

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 119: WebLogic Hackathon: Automated Provisioning using Puppet

119 | 10 119 | 9

Installing Puppet Agent

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 120: WebLogic Hackathon: Automated Provisioning using Puppet

120 | 10 120 | 9

Installing Puppet Agent

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 121: WebLogic Hackathon: Automated Provisioning using Puppet

121 | 10 121 | 9

Installing Puppet Agent

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 122: WebLogic Hackathon: Automated Provisioning using Puppet

122 | 10 122 | 9

Installing Puppet Agent

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 123: WebLogic Hackathon: Automated Provisioning using Puppet

123 | 10 123 | 9

Installing Puppet | install puppet-lint

Install Puppet Lint (optional) for manifest checking

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 124: WebLogic Hackathon: Automated Provisioning using Puppet

124 | 10 124 | 9

USEFUL PUPPET COMMANDS amp

LINKS

References

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 125: WebLogic Hackathon: Automated Provisioning using Puppet

125 | 10 125 | 9

Puppet commands

Inspect Puppet version puppet --version

Run Puppet locally and apply manifest puppet apply xyzpp

Run Puppet locally and apply manifest with debug output puppet apply xyzpp ndashdebug

Run Puppet locally and apply manifest with summary puppet apply xyzpp --summarize

Dry-run Puppet locally and simulate applying manifest puppet apply xyzpp ndashnoop

Validate manifest syntax puppet parser validate xyzpp

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 126: WebLogic Hackathon: Automated Provisioning using Puppet

126 | 10 126 | 9

Puppet commands

Retrieve all node facts using Puppet facter

Retrieve single fact using Puppet facter [fact] for example facter processorcount

List all known resource types puppet describe -l

Describe (the use of) a specific resource type puppet describe [type] for example puppet describe user

Inspect state of all resources of a specific type puppet resource [type] for example puppet resource user

Inspect state of a specific resources puppet resource [type] [name] for example puppet resource user root

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 127: WebLogic Hackathon: Automated Provisioning using Puppet

127 | 10 127 | 9

Puppet commands

Trigger single Puppet Agent run (retrieves manifests from Puppet Master and applies them)

puppet agent

Trigger single Puppet Agent run with verbose output

puppet agent --test

Find Puppet Module in the Puppet Forge

puppet module search [module] for example puppet module search oracle

Install Puppet Module from the Puppet Forge

puppet module install [module] for example puppet module install puppetlabs-motd

puppet module install puppetlabs-motd

Add debug line to manifest using notify resource type

notify ldquoMy debug statementrdquo

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 128: WebLogic Hackathon: Automated Provisioning using Puppet

128 | 10 128 | 9

Links | Puppet Type Reference

httpdocspuppetlabscomreferenceslatesttypehtml

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 129: WebLogic Hackathon: Automated Provisioning using Puppet

129 | 10 129 | 9

Links | Puppet Language Reference

httpdocspuppetlabscompuppet3referencelang_summaryhtml

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 130: WebLogic Hackathon: Automated Provisioning using Puppet

130 | 10 130 | 9

Links | Puppet Style Guidelines

httpdocspuppetlabscomguidesstyle_guidehtml

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 131: WebLogic Hackathon: Automated Provisioning using Puppet

131 | 10 131 | 9

Other | puppet-lint to check style guidelines

[rootpuppetmaster ~] sudo gem install puppet-lint

[rootpuppetmaster ~] puppet-lint xyzpp

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom

Page 132: WebLogic Hackathon: Automated Provisioning using Puppet

132 | 10 132 | 9

Thank you

Ronald van Luttikhuizen RonaldvanLuttikhuizenoboxproductscom