From 4e06b1eb56eac94676f7de85abcfbbf76cb9b442 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Thu, 19 Dec 2019 10:17:49 +0800 Subject: [PATCH] E37467 --- .DS_Store | Bin 6148 -> 8196 bytes data/common.yaml | 5 + site-modules/.DS_Store | Bin 6148 -> 6148 bytes site-modules/controlm/.DS_Store | Bin 0 -> 6148 bytes site-modules/controlm/README.md | 96 +++++++++++ site-modules/controlm/files/controlm.csh | 4 + site-modules/controlm/files/controlm.sh | 7 + .../controlm/files/controlm_agent_install.sh | 11 ++ site-modules/controlm/files/ctm.sh | 49 ++++++ site-modules/controlm/files/setup_patch.sh | 39 +++++ site-modules/controlm/files/sleep.sh | 48 ++++++ site-modules/controlm/files/ztest | 0 site-modules/controlm/manifests/.DS_Store | Bin 0 -> 6148 bytes .../controlm/manifests/controlm_agent.pp | 56 +++++++ .../manifests/controlm_agent/files.pp | 153 ++++++++++++++++++ .../manifests/controlm_agent/firewall.pp | 16 ++ .../manifests/controlm_agent/install.pp | 59 +++++++ .../manifests/controlm_agent/packages.pp | 16 ++ .../manifests/controlm_agent/users.pp | 38 +++++ .../controlm/manifests/controlm_agent/z1 | 10 ++ .../controlm/templates/agent_install.erb | 13 ++ .../templates/controlm_agent_install.erb | 71 ++++++++ .../controlm/templates/rc.agent_user.erb | 71 ++++++++ site-modules/controlm/templates/ztest | 0 site-modules/role/manifests/callaugeas.pp | 5 + 25 files changed, 767 insertions(+) create mode 100644 site-modules/controlm/.DS_Store create mode 100644 site-modules/controlm/README.md create mode 100644 site-modules/controlm/files/controlm.csh create mode 100644 site-modules/controlm/files/controlm.sh create mode 100644 site-modules/controlm/files/controlm_agent_install.sh create mode 100644 site-modules/controlm/files/ctm.sh create mode 100755 site-modules/controlm/files/setup_patch.sh create mode 100644 site-modules/controlm/files/sleep.sh create mode 100644 site-modules/controlm/files/ztest create mode 100644 site-modules/controlm/manifests/.DS_Store create mode 100644 site-modules/controlm/manifests/controlm_agent.pp create mode 100644 site-modules/controlm/manifests/controlm_agent/files.pp create mode 100644 site-modules/controlm/manifests/controlm_agent/firewall.pp create mode 100644 site-modules/controlm/manifests/controlm_agent/install.pp create mode 100644 site-modules/controlm/manifests/controlm_agent/packages.pp create mode 100644 site-modules/controlm/manifests/controlm_agent/users.pp create mode 100644 site-modules/controlm/manifests/controlm_agent/z1 create mode 100644 site-modules/controlm/templates/agent_install.erb create mode 100644 site-modules/controlm/templates/controlm_agent_install.erb create mode 100755 site-modules/controlm/templates/rc.agent_user.erb create mode 100644 site-modules/controlm/templates/ztest create mode 100644 site-modules/role/manifests/callaugeas.pp diff --git a/.DS_Store b/.DS_Store index 7df7881a6d6f33293963952cc6ba9fc958868e58..4e6741594879fa2f773326d61f99c03475aa6d6d 100644 GIT binary patch delta 596 zcmZoMXmOBWU|?W$DortDU;r^WfEYvza8E20o2aMA$hR?IH}hr%jz7$c**Q2SHn1@A zZRTMyW}M8+DqNpbUR;orlb;0Ca4M-FC$qT3z~DL~6Eh1d8&EM92Ny3_Y;ZMkZ!D3MM9owY8ia;;M$W zo(Z{?Rn;}Mb+drZ1p-D!2+hC`rD4=;AcK=3mm!fMk0FyGjUknxn4yHBxGcCRFDE}Q z9ViRZ$;A*b*@^YhK!-s%dKeg+80jb&S(sB829qza%5cEEyjh3m5i^$rH_+RzptP}B ckmEb^WPTCP$^JYX9Kg^3B^!p#@jP>w0XY_%l>h($ delta 121 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50$jH4hU^g=(_hudeW5&t8LQi?h zf{XHU^7GO``Zg9`XI#wA!6C>DE2lQoq009j3>w}1}2EPAgdTQ$Mei# F1^`?a6>9(h diff --git a/data/common.yaml b/data/common.yaml index 2baa62b..63da93f 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -1,2 +1,7 @@ --- message: "This node is using common data" +controlm::controlm_agent::agent2server_port: 17005 +controlm::controlm_agent::server2agent_port: 17006 +controlm::controlm_agent::tracker_port: 17035 +controlm::controlm_agent::server_host: ctmgnpappla013 +controlm::controlm_agent::primary_server_host: ctmgnpappla013.optus.com.au diff --git a/site-modules/.DS_Store b/site-modules/.DS_Store index 05b8c548c5cec8c7a987e951c10d055d6d3c3fb2..77db6da21a0779189aa064acdf105b587fbc20bc 100644 GIT binary patch delta 438 zcmZoMXfc=|#>B)qu~2NHo}wr_0|Nsi1A_nqLlHwhLk>f(XHI_dW=6*4jP)QX4u)i) za2`VmvUE~TeiBd)sE1J;NNfBD10V~F`lRyW0;u{^Nd-BX#U%y?*BP0ZSy&{F`1uBUN&&*57FL%l>%}Xf;8x#zY;Nalo;EWfLtgbdTG15^mvM{gJQK&XFGBMLp zFflQ#t>xqpS2eWtOvtUQs;;T6n+5brED$pSg9Z%vp)`z|4P;=1O<8bJUQT{qI#3Rz zkBuQ62um1J8HyQ7K*5R>Zmkp7$!(n1%(9uCgP#K!8^93%&ODi4#83dFvjJiP*z(N* HB3qaNYo}~@ delta 79 zcmZoMXfc=|#>CJ*u~2NHo}wr-0|Nsi1A_nqLncEGL#k&^esWUI#6opO=FLUSQ&~2# jJY(9-&cV+C)Uo*^^LOUS{33>o43lkmq<itY8KJ3{Mn; diff --git a/site-modules/controlm/.DS_Store b/site-modules/controlm/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8d96ecc3262f375d150528a2c647f0570ceaeb7f GIT binary patch literal 6148 zcmeH~&u-H|5XNWQ6gEMK9FR(Hz94akP!l3RLP#b}4?Q5E8o>cjYvYt!a=cOO5J8&C z7hVFMfLGxKcpUo8?t)w#q@EBeJJRg8e`cKQPu^WG5sASp?h>_$NWxhgEfgz^$JuMP zW_x&0=x5}6sd^iwDyqf04oAQd`1c6#+TEZdN+_ifRo5?X36J1+erVHwy%HJC^NC&Q z-=ayHt7LzNf=U_(omn2si@g39OrD zo6rB /apps/bmc/ctm/controlm_agent_install.hasrun + echo "exit status $RESULT" >> /apps/bmc/ctm/controlm_agent_install.hasrun + echo "do not remove this file unless you want to rerun the install" >> /apps/bmc/ctm/controlm_agent_install.hasrun + chmod 444 /apps/bmc/ctm/controlm_agent_install.hasrun + exit $RESULT + diff --git a/site-modules/controlm/files/ctm.sh b/site-modules/controlm/files/ctm.sh new file mode 100644 index 0000000..7f8dd3c --- /dev/null +++ b/site-modules/controlm/files/ctm.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Startup Script for Control-M Agent Daemons +# Creation Date: 2016-09-09 +# Created By: David Stephenson +# Version: 1.0 + +# chkconfig: 2345 99 05 +# description: Controlm agent + + +CTM_Dir=/apps/bmc/ctm +CTM_OWNER=ctmagent +CTM_GROUP=controlm + +chown $CTM_OWNER:$CTM_GROUP $CTM_Dir/proclog/*.log + +case "$1" in +'start') + cd $CTM_Dir/scripts + ./start-ag -u $CTM_OWNER -p ALL -s + if [ "$?" = 0 ] ; then + touch /var/lock/subsys/ctm + echo "Control-M Agent Started" + fi + ;; +'stop') + cd $CTM_Dir/scripts + echo "Stopping Control-M Agent" + ./shut-ag -u $CTM_OWNER -p ALL + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctm; + ;; +'mode_user') + cd $CTM_Dir/scripts + ./set_agent_mode -u $CTM_OWNER -o 1 + ;; +'mode_full') + cd $CTM_Dir/scripts + ./set_agent_mode -u $CTM_OWNER -o 2 + ;; +*) + echo "Usage: //ctm.sh { start | stop }" + echo "or, if using sudo...." + echo "Usage: sudo -u root ./ctm.sh { start | stop | mode_user | mode_full }" + ;; +esac +exit 0 + diff --git a/site-modules/controlm/files/setup_patch.sh b/site-modules/controlm/files/setup_patch.sh new file mode 100755 index 0000000..f572214 --- /dev/null +++ b/site-modules/controlm/files/setup_patch.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Description: +# This setup.sh find and run the install-bin that is compatible to the installing environment + +# Find this script's directory +utl_dir=`dirname $0` + +# set the INSTALL_BINs directory +bin_dir=$utl_dir + +# get all the INSTALL_BINs +install_bin_list=`ls $bin_dir | grep INSTALL.BIN` + +#get shell to be used to run "BIN" files + __machine=`uname` +shellInterpriter="/bin/ksh" +if [ $__machine = "Linux" ] ; then + shellInterpriter="/bin/sh" +fi + + +# loop on the install_bin_list and find the first one that is compatible with the environment +for install_bin in $install_bin_list +do + ${shellInterpriter} $bin_dir/$install_bin -m + if [ $? -eq 0 ];then + # Current install_bin is compatible with the environment was found, run it to install the FP + $bin_dir/$install_bin $@ + exit $? + fi +done + +echo ERROR: There is no available installation file for this platform: `uname -a` +echo Installation files were found for the following platforms: +echo ${install_bin_list}| tr " " "\n" | cut -f 2 -d_ | cut -f 1 -d. + +exit 1 + diff --git a/site-modules/controlm/files/sleep.sh b/site-modules/controlm/files/sleep.sh new file mode 100644 index 0000000..9d5fad7 --- /dev/null +++ b/site-modules/controlm/files/sleep.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Sleep Script for Control-M +# Use to Test Control-M Scheduling +# Creation Date: 2016-09-09 +# Created By: David Stephenson +# Version: 1.0 +exec 2> /dev/null +echo "********************************" +echo "** CONTROL-M Environment **" +echo "********************************" +echo PATH := $PATH +echo LD_LIBRARY_PATH:= $LD_LIBRARY_PATH +echo CONTROLM := $CONTROLM +echo "" +echo "********************************" +echo "** Arguments passed to script **" +echo "********************************" +echo Number of ARGS: = $# +echo ARGS := $* +echo "" +echo "********************************" +echo "** Script Run times **" +echo "********************************" +echo START := $(date) + +# Default RC to 0 +RC=0 + +# Search ARGS for RC=xxx If found Return an Error Code +while (( "$#" )); do + arg=$(echo $1 | awk '{ print $1 }') + if [ "$arg" -eq "$arg" ] 2>/dev/null; then + echo SLEEP := $arg SECONDS + sleep $1 > /dev/null + fi + echo $arg | grep -qi "rc=" + if [ "$?" -eq "0" ]; then + RC=$(echo $arg | grep -i "rc=" | awk -F= '{ print $2 }') + echo "RETURN CODE ARGUMENT: 'RC=$RC' FOUND. RETURN CODE '$RC' SENT TO CONTROL_M" + fi + shift +done + +echo END := $(date) +echo "" + +exit $RC + diff --git a/site-modules/controlm/files/ztest b/site-modules/controlm/files/ztest new file mode 100644 index 0000000..e69de29 diff --git a/site-modules/controlm/manifests/.DS_Store b/site-modules/controlm/manifests/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..133ed3656e394ea6bfc27642f0bc5e3c340f8830 GIT binary patch literal 6148 zcmeHKUrQT75T8xbc9YUJg@Sq97oiWKBr*6R!jbAj-h>l<&=T*GkQ|)1A-NdZH08dA zegi*>pP(P7&g`y1O{*^=MP^|3H#<8s$Nu)%KL8+F(_S5*3;+_9FjvIpFGAy_E0S}b z0-`WA#-JgFQ|Lgj63vePkpWt}_t3?4OCW{Y>obsH%Cr z(cG-6X0yIn6y@4_eY<^f`u)fJ=i=A7nHC8Ap^bcScmo$`JV@A?KTcwu3^0yre0+#p z_yQvs-J|#tvu;z2T^4458DIvUmI1fL$+u5ima8!X%)kp^fc6K4O6WPvESjwY8}kG} zq-&%RwCS2iIm)5uFtdmwD8i;9+En457{aEbU%5EXVP?^$gK&=z;l3=~3q_c(V|``9 zL3kFqWd@jmyA0%Qw@l~%?!Vvvcayls3@`&PiUCpB@poD{C3m*2OpeZ4g?fTYLUEbJ lWeOVRD8^ViiYur_(67iq^c-du(SyPl0Yd{f%)qlUa1DG|cj*8C literal 0 HcmV?d00001 diff --git a/site-modules/controlm/manifests/controlm_agent.pp b/site-modules/controlm/manifests/controlm_agent.pp new file mode 100644 index 0000000..378fbe6 --- /dev/null +++ b/site-modules/controlm/manifests/controlm_agent.pp @@ -0,0 +1,56 @@ +class controlm::controlm_agent { + + #used for the automated install file and firewall. + + #MUST HAVE THESE TWO IN HIERA, use fqdn for primary if host in diff domain. + #controlm::controlm_agent::primary_server_host: ctmgnpappla012.optus.com.au + #controlm::controlm_agent::server_host: ctmgnpappla012 + $server_host = hiera('controlm::controlm_agent::server_host','ctmgnpappla012') + $primary_server_host = hiera('controlm::controlm_agent::primary_server_host','ctmgnpappla012.optus.com.au') + + $tracker_port = hiera('controlm::controlm_agent::tracker_port','7035') + $a2s_port = hiera('controlm::controlm_agent::agent2server_port','7005') + $s2a_port = hiera('controlm::controlm_agent::server2agent_port','7006') + $tcp_timeout = hiera('controlm::controlm_agent::tcp_timeout','60') + $ignore_fail = hiera('controlm::controlm_agent::ignore_fail',false) + $force_upgrade = hiera('controlm::controlm_agent::force_upgrade',false) + + $software_version = hiera('controlm::controlm_agent::version','9.0.00-2') + + $patch_files = hiera('controlm::controlm_agent::patch_files',['PAKAI.9.0.00.100_Linux-x86_64_INSTALL.BIN','PAKAI.9.0.00.200_Linux-x86_64_INSTALL.BIN']) + # array of patch files so + # controlm::controlm_agent::patch_files: + # - file1 + # - file2 + # patch files are not installed separately from main install as timing that was + # not working. So if we get new patches probably best to install by hand or see + # if you can get a separate script happening. + +# also in hiera you need these, subbing PRD for GNP where needed +# isnd_linux::profiles::soe::login_accounts::groups: +# - 'ocaus01\ACL-GNP-CTRLM-rwx-SMT-ADMIN': +# additional_groups: +# - controlm +# - 'ocaus01\ACL-GNP-CTRLM-rx-SMT-SCHED': +# additional_groups: +# - controlm +# +# tpiam::profiles::sudoers: +# ocaus01aclgnpctrlmrwxsmtadmin: +# runas_users: +# - ctmagent +# commands: all_commands +# ocaus01aclgnpctrlmrxsmtsched: +# runas_users: +# - ctmagent +# commands: all_commands include controlm::controlm_agent::users + + include controlm::controlm_agent::users + include controlm::controlm_agent::packages + include controlm::controlm_agent::files + include controlm::controlm_agent::firewall + include controlm::controlm_agent::install + +} + + diff --git a/site-modules/controlm/manifests/controlm_agent/files.pp b/site-modules/controlm/manifests/controlm_agent/files.pp new file mode 100644 index 0000000..5d43a92 --- /dev/null +++ b/site-modules/controlm/manifests/controlm_agent/files.pp @@ -0,0 +1,153 @@ +class controlm::controlm_agent::files inherits controlm::controlm_agent { + +# Directories + unless defined(File['/apps']) { + file { [ '/apps', ]: + ensure => 'directory', + owner => 'root', + group => 'root', + mode => '0755', + } + } + + file { [ '/apps/bmc',]: + ensure => 'directory', + owner => 'root', + group => 'root', + mode => '0755', + require => File['/apps'], + } + file { [ '/apps/bmc/software','/apps/bmc/software/version_9/','/apps/bmc/software/version_9/fixes' ]: + ensure => 'directory', + owner => 'ctmagent', + group => 'controlm', + mode => '0755', + require => File['/apps/bmc'], + } + +# scripts_optus + + file { ['/apps/bmc/ctm/scripts_optus']: + ensure => directory, + owner => 'ctmagent', + group => 'controlm', + mode => '0775', + require => User['ctmagent'], + } + + file { '/apps/bmc/ctm/scripts_optus/sleep.sh': + ensure => file, + owner => 'ctmagent', + group => 'controlm', + mode => '0755', + source => 'puppet:///modules/controlm/sleep.sh', + require => [File['/apps/bmc/ctm/scripts_optus'],User['ctmagent'],], + } + + file { '/apps/bmc/ctm/scripts_optus/ctm.sh': + ensure => file, + owner => 'root', + group => 'root', + mode => '0755', + source => 'puppet:///modules/controlm/ctm.sh', + require => File['/apps/bmc/ctm/scripts_optus'], + } + + case $::os['release']['major']{ + '6': { + file { '/etc/rc.d/init.d/ctm.sh': + ensure => link, + target => '/apps/bmc/ctm/scripts_optus/ctm.sh', + owner => 'root', + group => 'root', + require => File['/apps/bmc/ctm/scripts_optus/ctm.sh'], + } + } + '7': { + + file { '/etc/rc.d/init.d/ctm.sh': + ensure => absent, + } + + file { '/etc/rc.d/init.d/ctm': + ensure => file, + owner => 'root', + group => 'root', + mode => '0755', + source => 'puppet:///modules/controlm/ctm.sh', + notify => Exec['systemctl reload daemon for Control-M agent'] + } + + exec{'systemctl reload daemon for Control-M agent': + path => $::path, + command => 'systemctl daemon-reload', + refreshonly => true, + } + + } + default: {fail "Unsupported Major version ${::os['release']['major']} detected"} + } + +#ctm/scripts + +# file { '/apps/bmc/ctm/scripts': +# ensure => link, +# target => '/apps/bmc/software/version_9/ctm/scripts', +# owner => 'root', +# group => 'root', +# require => Package['ctmagent_core_clean'], +# } + +# install scripts + + file { '/apps/bmc/ctm/ctm_silentinstall_optus.xml': + ensure => file, + owner => 'root', + group => 'root', + mode => '0755', + content => template('controlm/agent_install.erb'), + require => User['ctmagent'], + } + + file { '/apps/bmc/ctm/controlm_agent_install.sh': + ensure => file, + owner => 'root', + group => 'root', + mode => '0755', + content => template('controlm/controlm_agent_install.erb'), + require => User['ctmagent'], + } + + +# need to check status method and also if we need restart check. +# this should be in the install Iguess +# service { 'ctm.sh': +# ensure => running, +# enable => true, +# hasstatus => false, +# status => '', +# start => '', +# stop => '', +# subscribe => [ +# ], +# require => '/etc/rc.d/init.d/ctm.sh', +# } + +# profile scripts + file { '/etc/profile.d/controlm.csh': + ensure => file, + owner => 'root', + group => 'root', + mode => '0755', + source => 'puppet:///modules/controlm/controlm.csh', + } + + file { '/etc/profile.d/controlm.sh': + ensure => file, + owner => 'root', + group => 'root', + mode => '0755', + source => 'puppet:///modules/controlm/controlm.sh', + } + +} diff --git a/site-modules/controlm/manifests/controlm_agent/firewall.pp b/site-modules/controlm/manifests/controlm_agent/firewall.pp new file mode 100644 index 0000000..cddccd2 --- /dev/null +++ b/site-modules/controlm/manifests/controlm_agent/firewall.pp @@ -0,0 +1,16 @@ +class controlm::controlm_agent::firewall inherits controlm::controlm_agent { + + + firewall { '200 controlm tracker port hiera controlm_tracker_port': + action => 'accept', + proto => 'tcp', + dport => [$tracker_port], + } + + firewall { '210 controlm server to agent hiera controlm_server2agent_port': + action => 'accept', + proto => 'tcp', + dport => [$s2a_port], + } + +} diff --git a/site-modules/controlm/manifests/controlm_agent/install.pp b/site-modules/controlm/manifests/controlm_agent/install.pp new file mode 100644 index 0000000..4265669 --- /dev/null +++ b/site-modules/controlm/manifests/controlm_agent/install.pp @@ -0,0 +1,59 @@ +class controlm::controlm_agent::install inherits controlm::controlm_agent { + + +# set up /etc/services + + augeas { 'controlm': + context => '/files/etc/services', + changes => [ + "set service-name[port = '${s2a_port}'][protocol = 'udp'] ctmagent", + "set service-name[port = '${s2a_port}'][protocol = 'udp']/#comment 'Control-M server2agent'", + "set service-name[port = '${s2a_port}'][protocol = 'tcp'] ctmagent", + "set service-name[port = '${s2a_port}'][protocol = 'tcp']/#comment 'Control-M server2age nt'", + "set service-name[port = '${a2s_port}'][protocol = 'udp'] ctmagent", + "set service-name[port = '${a2s_port}'][protocol = 'udp']/#comment 'Control-M agent2servr'", + "set service-name[port = '${a2s_port}'][protocol = 'tcp'] ctmagent", + "set service-name[port = '${a2s_port}'][protocol = 'tcp']/#comment 'Control-M agent2server'", + ], + } + + + # use shellscript and sudo as running the install direct as user ctmagent gives HOME errors plus we get errors in the log file + # also does patches as can't get the patch script running after it for some reason + # patch names need to be in hiera see controlm_agent.pp + exec { 'controlm_agent_install': + command => '/apps/bmc/ctm/controlm_agent_install.sh > /apps/bmc/ctm/controlm_agent_install.log', + creates => '/apps/bmc/ctm/controlm_agent_install.hasrun', + require => [User['ctmagent'],Package['ctmagent_core_clean'],File['/apps/bmc/ctm/ctm_silentinstall_optus.xml','/apps/bmc/ctm/controlm_agent_install.sh'],Exec['chown_/apps/bmc'],], + timeout => 1800, + } + + case $::os['release']['major']{ + '6': { + service { 'ctm.sh': + ensure => running, + enable => true, + hasstatus => false, + status => '/bin/ps -ef | /bin/grep /apps/bmc/ctm/exe/p_ctm | /bin/grep -v grep', + require => [File['/etc/rc.d/init.d/ctm.sh'],Exec['controlm_agent_install'],] + } + } + '7': { + + service { 'ctm.sh': + enable => false, + } + + service { 'ctm': + ensure => running, + enable => true, + hasstatus => false, + status => '/bin/ps -ef | /bin/grep /apps/bmc/ctm/exe/p_ctm | /bin/grep -v grep', + require => [File['/etc/rc.d/init.d/ctm'],Exec['controlm_agent_install']] + } + + } + default: {fail "Unsupported Major version ${::os['release']['major']} detected"} + } +} + diff --git a/site-modules/controlm/manifests/controlm_agent/packages.pp b/site-modules/controlm/manifests/controlm_agent/packages.pp new file mode 100644 index 0000000..c907b8c --- /dev/null +++ b/site-modules/controlm/manifests/controlm_agent/packages.pp @@ -0,0 +1,16 @@ +class controlm::controlm_agent::packages inherits controlm::controlm_agent { + + package { 'ctmagent_core_clean' : + ensure => "$software_version", + require => User['ctmagent'], + } + + # the RPM does permissions, this is a backup + exec {'software permissions' : + command => '/bin/chown -R ctmagent:controlm /apps/bmc/software/version_9', + onlyif => '/usr/bin/test $(/bin/find /apps/bmc/software/version_9/CheckReq -uid 0 | w +c -l) -gt 0', + require => Package['ctmagent_core_clean'], + } + +} diff --git a/site-modules/controlm/manifests/controlm_agent/users.pp b/site-modules/controlm/manifests/controlm_agent/users.pp new file mode 100644 index 0000000..058f7e7 --- /dev/null +++ b/site-modules/controlm/manifests/controlm_agent/users.pp @@ -0,0 +1,38 @@ +class controlm::controlm_agent::users { + + unless defined(Group['controlm']) { + group { 'controlm': + ensure => present, + } + } + + user { 'ctmagent': + gid => [ 'controlm'], + home => '/apps/bmc/ctm', + comment => 'ControlM Agent', + shell => '/bin/bash', + password => '*', + managehome => true, + require => [Group['controlm'],File['/apps/bmc'],], + } + # set ownerships for /apps/bmc/ctm as needs sticky on group and install needs ctmagent to own /apps/bmc + exec { 'set permissions on /apps/bmc/ctm': + command => '/bin/chmod 2775 /apps/bmc/ctm', + onlyif => '/usr/bin/test $(/bin/find /apps/bmc/ctm -perm 2775 | wc -l) -eq 0', + require => User['ctmagent'], + } + + exec { 'chown_/apps/bmc': + command => '/bin/chown ctmagent.controlm /apps/bmc', + unless => '/usr/bin/test -e /apps/bmc/ctm/controlm_agent_install.hasrun', + require => User['ctmagent'], + } + + sudo::rule { 'controlm': + type => 'group', + runas_users => 'root', + commands => [ + '/apps/bmc/ctm/scripts_optus/ctm.sh', + ], + } +} diff --git a/site-modules/controlm/manifests/controlm_agent/z1 b/site-modules/controlm/manifests/controlm_agent/z1 new file mode 100644 index 0000000..0e64886 --- /dev/null +++ b/site-modules/controlm/manifests/controlm_agent/z1 @@ -0,0 +1,10 @@ + + file { '/apps/bmc/ctm/ctm_silentinstall_optus.xml': + ensure => file, + owner => 'root', + group => 'root', + mode => '0755', + content => template('controlm/agent_install.erb'), + require => User['ctmagent'], + } + diff --git a/site-modules/controlm/templates/agent_install.erb b/site-modules/controlm/templates/agent_install.erb new file mode 100644 index 0000000..b263ccd --- /dev/null +++ b/site-modules/controlm/templates/agent_install.erb @@ -0,0 +1,13 @@ + + Control-M/Agent 9.0.00 + + + + + + + + + + + diff --git a/site-modules/controlm/templates/controlm_agent_install.erb b/site-modules/controlm/templates/controlm_agent_install.erb new file mode 100644 index 0000000..52bf793 --- /dev/null +++ b/site-modules/controlm/templates/controlm_agent_install.erb @@ -0,0 +1,71 @@ +#!/bin/bash +# +#Does install and patches if any + +cd /apps/bmc/ +sudo -u ctmagent /apps/bmc/software/version_9/setup.sh -silent /apps/bmc/ctm/ctm_silentinstall_optus.xml +RESULT=$? +echo "exit status $RESULT" +if [ $RESULT -ne 0 ] ; then exit $RESULT; fi +/bin/date > /apps/bmc/ctm/controlm_agent_install.hasrun +echo "exit status $RESULT" >> /apps/bmc/ctm/controlm_agent_install.hasrun +echo "do not remove this file unless you want to rerun the install" >> /apps/bmc/ctm/controlm_agent_install.hasrun +chmod 444 /apps/bmc/ctm/controlm_agent_install.hasrun + + +<% if @patch_files -%> +/bin/date > /apps/bmc/ctm/controlm_agent_patch_install.hasrun +# remove any old patches +rm -rf /apps/bmc/software/version_9/fixes/*INSTALL.BIN + +. /etc/profile.d/controlm.sh + +<% @patch_files.each do | file | -%> + +echo "====================" +PATCH_RESULT=1 +cd /apps/bmc/software/version_9/fixes +wget http://<%= scope.lookupvar('::razor_metadata_repo_server') -%>/files/bcc_source/controlm/<%= file %> +chmod 755 /apps/bmc/software/version_9/fixes/<%= file %> +sudo -u ctmagent /bin/bash - < +EOF +PATCH_RESULT=$? + if [ $PATCH_RESULT -ne 0 ] + then + echo "patch <%= file -%> bad $PATCH_RESULT" >> controlm_agent_patch_install.hasrun + mv /apps/bmc/ctm/controlm_agent_patch_install.hasrun /apps/bmc/ctm/controlm_agent_patch_install.bad + exit $RESULT + fi + +echo "patch exit status <%= file -%> $PATCH_RESULT" +# sleep to see if patches properly install +echo "sleeping for 10 " +sleep 10 +<% end -%> +<% end -%> + +# set correct hostnames +SHORT=`/bin/hostname -s` +LONG=`/bin/hostname -f` + +echo "Changing short hostnames in CONFIG.dat" +cp -f /apps/bmc/ctm/data/CONFIG.dat /apps/bmc/ctm/data/CONFIG.dat.bak +/bin/sed -i "s/$SHORT$/$LONG/" /apps/bmc/ctm/data/CONFIG.dat +grep $SHORT /apps/bmc/ctm/data/CONFIG.dat + + +#change mode +/usr/bin/yes y | /apps/bmc/ctm/scripts/set_agent_mode -u ctmagent -o 1 + +# stop agent +sudo -u ctmagent /bin/bash - < for backward compatibility +ARG1=`echo $1 | tr '[A-Z]' '[a-z]'` +if [ "$ARG1" = "start" ] || [ "$ARG1" = "stop" ] ; then + if [ "$ARG1" = "start" ] ; then + STATE_ACTION="start" + elif [ "$ARG1" = "stop" ] ; then + STATE_ACTION="stop" + fi +else + STATE_ACTION="start" +fi + + + if [ "$agent_status" = "STOPPED" ] ; then # AGENT_STATUS is set to 'STOPPED', exit without starting the Agent + echo "Control-M/Agent (account $account_name) status is set to 'STOPPED'. Control-M/Agent will not start." + exit 0 + fi + + # get the value for config parameter AGENT_OWNER to determine which owner should start the agent + # in case the parameter is missing or empty, start as root. + # This script is executed as root user by the OS during machine startup. + # If the agent should run as agent owner, use 'su' to run start-ag + agent_owner=`grep AGENT_OWNER $config_file | awk '{print $2}'` + +if [ "$STATE_ACTION" = "start" ] ; then + + if [ "$agent_owner" != "root" ] ; then + /bin/su - $agent_owner -c "$install_path/ctm/scripts/start-ag -u $account_name -p ALL" + else + $install_path/ctm/scripts/start-ag -u $account_name -p ALL + fi + +else + + # backup ctm_agent_status.dat to keep origional status + TMP_FILE_NAME="ctm_agent_status_dat-`date +'%Y-%m-%d_%H-%M-%S'`.tar" + cd $install_path/ctm/data ; tar -cf $TMP_FILE_NAME ctm_agent_status.dat + + if [ "$agent_owner" != "root" ] ; then + /bin/su - $agent_owner -c "$install_path/ctm/scripts/shut-ag -u $account_name -p ALL" + else + $install_path/ctm/scripts/shut-ag -u $account_name -p ALL + fi + + # restore ctm_agent_status.dat to origional + cd $install_path/ctm/data ; tar -xf $TMP_FILE_NAME ; rm -f $TMP_FILE_NAME + +fi +exit 0 + + diff --git a/site-modules/controlm/templates/ztest b/site-modules/controlm/templates/ztest new file mode 100644 index 0000000..e69de29 diff --git a/site-modules/role/manifests/callaugeas.pp b/site-modules/role/manifests/callaugeas.pp new file mode 100644 index 0000000..3429116 --- /dev/null +++ b/site-modules/role/manifests/callaugeas.pp @@ -0,0 +1,5 @@ +class role::callaugeas { + + include controlm::controlm_agent + +}