The following ddl
action 'ant', :description => "Runs ant in the application directory" do
input :application,
:prompt => "Application(s)",
:description => "Application's instance name(s)",
:type => :string,
:validation => '^[a-z0-9_,\-]+$',
:maxlength => 500,
:optional => false
can be used inside an agent to get the command line parameter application
# entry point for the ant target
action 'ant' do
# find eligible applications
applications = request[:application].split(',').select{|a| valid_application?(a) }
The command command can be started with mco <agentname> -a applicationname1,applicationname2and so on. Issuing mco <agentname> --help gives me :
$ mco ehyp --help
Manage an <internal> application
Application Options
-a, --application APPLICATION Application to manage
I do not find the "link" between -a or --application and request[:application]. Where is it defined how to inteprete these command line switches ?
It is defined in MCollective::Application there you define :
option :application,
:description => 'Application to manage',
:arguments => ['-a', '--application APPLICATION'],
:required => true
option :destination,
:description => 'Ant target ("destination") to call',
:arguments => ['-d', '--destination TARGET'],
:required => true
Related
Currently trying to populate the employee index with the below settings:
CONF
input {
jdbc {
jdbc_driver_library => "~/sqljdbc_6.2/enu/mssql-jdbc-6.2.1.jre8.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://SERVER;user=USER;password=PASSWORD"
jdbc_user => "DB_USER"
jdbc_password => "DB_PASSWORD"
jdbc_validate_connection => true
jdbc_validation_timeout => -1
statement => "SELECT * FROM [dbo].Employee ORDER BY ID"
type => "employee"
}
}
filter {
}
output {
}
NOTE: filter and output sections of the conf file is purposely blank
LINUX COMMAND
sudo /usr/share/logstash/bin/logstash -f /home/ubuntu/Employee-pipeline.conf --path.settings /etc/logstash/ --path.data /var/lib/logstash_new
RESULT
Looks like logstash does not know or don't have access to ~/sqljdbc...*.jar
I also confirmed that the mssql-jdbc-6.2.1.jre8.jar exists
However, when I changed the path to /home/ubuntu/sqljdbc_6.2/enu/mssql-jdbc-6.2.1.jre8.jar, it runs successfully.
So ~/ is the same as /home/ubuntu
This started to occur after upgrading our Elastic Stack from v5.5 to v5.6. Also, note that this does not occur if we run the same conf file with the logstash service.
I have two cookbooks: elasticsearch and curator.
Elasticsearch cookbook installs and configure an elasticsearch. The following resource (from elasticsearch cookbook), has to be modified from curator cookbook:
elasticsearch_configure 'elasticsearch' do
configuration ({
'http.port' => port,
'cluster.name' => cluster_name,
'node.name' => node_name,
'bootstrap.memory_lock' => false,
'discovery.zen.minimum_master_nodes' => 1,
'xpack.monitoring.enabled' => true,
'xpack.graph.enabled' => false,
'xpack.watcher.enabled' => true
})
end
I need to modify it on curator cookbook and add a single line:
'path.repo' => (["/backups/s3_currently_dev", "/backups/s3_currently", "/backups/s3_daily", "/backups/s3_weekly", "/backups/s3_monthly"])
How I can do that?
I initially was going to point you to the chef-rewind gem, but that actually points to the edit_resource provider that is now built into Chef. A basic example of this:
# cookbook_a/recipes/default.rb
file 'example.txt' do
content 'this is the initial content'
end
.
# cookbook_b/recipes/default.rb
edit_resource! :file, 'example.txt' do
content 'modified content!'
end
If both of these are in the Chef run_list, the actual content within example.txt is that of the edited resource, modified content!.
Without fully testing your case, I'm assuming the provider can be utilized the same way, like so:
edit_resource! :elasticsearch_configure, 'elasticsearch' do
configuration ({
'http.port' => port,
'cluster.name' => cluster_name,
'node.name' => node_name,
'bootstrap.memory_lock' => false,
'discovery.zen.minimum_master_nodes' => 1,
'xpack.monitoring.enabled' => true,
'xpack.graph.enabled' => false,
'xpack.watcher.enabled' => true,
'path.repo' => ["/backups/s3_currently_dev", "/backups/s3_currently", "/backups/s3_daily", "/backups/s3_weekly", "/backups/s3_monthly"]
})
end
I am completely new to Puppet and this is my first time writing code in puppet. I want to get a tar.gz file and then untar it to create the folder.
Here is my code:
file{ "${::filename}.tar.gz":
ensure => 'file',
mode => '0644',
notify => Exec['untar-file'],
}
exec{ 'download-file' :
command => "wget URL_FOR_TAR_GZ",
cwd => "PATH_WHERE_TO_STORE",
user => "my_name",
group => "our company name",
}
exec { 'untar-file':
command => "/bin/tar -xzvf tar_file_name",
cwd => "file_path",
creates => "foldername_to_be_createdc",
user => "my_name",
group => "our company name",
require => Exec['download-file']
}
As soon as I run this I get an error:
wget returned 8 instead of one of [0]" and "/Exec[download-file]/returns: change from notrun to 0 failed"
Where am I going wrong?
I am new to puppet. I want to run a shell script call crfs.sh located under /myscripts on a RHEL linux puppet master server.
How do I execute this script on a client or target server?
What you want can be solved using the file and the exec modules of puppet.
class mymodule::myclass {
file { 'my_bash_script':
ensure => 'file',
source => 'puppet:///modules/mymodule/my_bash_script.sh',
path => '/usr/local/bin/my_bash_script.sh',
owner => 'root'
group => 'root'
mode => '0744', # Use 0700 if it is sensitive
notify => Exec['run_my_script'],
}
exec { 'run_my_script':
command => '/usr/local/bin/my_bash_script.sh',
refreshonly => true,
}
}
I have the following code for a small class for Tomcat, The class runs fine but the service at the end of the script doesn't start. any guidance would be great. i dont know why the service wont start.
content of the Tomcat6 class
# Class: tomcat6
#
# This module manages tomcat6
#
# Parameters: none
#
# Actions:
#
# Requires: see Modulefile
#
# Sample Usage:
#
class tomcat6 ( $parentdir = '/usr/share',
$tomcat_version = '6.0.37',
$tomcat_major_version = '6',
$digest_string = '171d255cd60894b29a41684ce0ff93a8',
$tomcat_exe = 'tomcat6/tomcat.erb',
$java_home = '/usr/java/latest',
$jvm_route = 'jvm1',
$shutdown_password = 'SHUTDOWN',
$admin_port = 8005,
$http_port = 8080,
$tomcat_user = 'root',
$tomcat_group = 'root',
$admin_user = 'tomcat',
$admin_password = 'tomcat'
) {
$basedir = "${parentdir}/apache-tomcat-6.0.37"
file {'/installs':
ensure => 'directory',
source => 'puppet:///modules/tomcat6/',
recurse => 'remote',
owner => 'root',
group => 'root',
mode => '0755',
}
exec { 'tomcat_untar':
command => 'tar -zxvf /installs/apache-tomcat-6.0.37.tar.gz -C /usr/share/',
cwd => '/usr/share/',
creates => "/usr/share/apache-tomcat-6.0.37",
path => ["/bin"],
require => [File["/installs"]]
}
file { "/etc/init.d/tomcat":
ensure => present,
owner => root,
group => root,
mode => 0755,
content => template($tomcat_exe),
require => Exec["tomcat_untar"]
}
service { "tomcat":
ensure => "running",
enable => "true",
require => File["/etc/init.d/tomcat"]
}
}
contents of tomcat.erb
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.6.0_26
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-6.0.37
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
Puppet does an /etc/init.d/tomcat status to see if the service is running. If it gets no proper return status if the service is stopped, it will not try to start it.
http://docs.puppetlabs.com/references/latest/type.html#service
Check out hasstatus.
An alternative is to make Puppet grep through the process table with 'pattern' and 'hasstatus' set to false.