I can't understand how to restart service from another class.
My structure is:
# cat init.pp
class nginxrtmp {
include nginxrtmp::nginxinstall
include nginxrtmp::nginxconfig
}
in nginxrtmp::nginxinstall i have service nginx to restart
# cat nginxinstall.pp
service {'nginx':
name => 'nginx.service',
ensure => 'running',
enable => 'true',
}
And in nginxrtmp::nginxconfig i have *.erb template with config
# cat nginxconfig.pp
file { '/etc/nginx/nginx.conf':
* => $resAttributes,
content => template('nginxrtmp/redhat.nginx.conf.erb'),
notify => nginxinstall::Service['nginx'],
}
And my question is, how to restart service nginx described in another class and file *.pp if my template file change
I just found answer myself. Need to write
include nginxrtmp::nginxinstall
in class with config
You could create a service.pp file that contains the service and then change it to:
# init.pp
class nginxrtmp {
contain nginxrtmp::service
contain nginxrtmp::config
Class['::nginxrtmp::config']
~> Class['::nginxrtmp::service']
}
# service.pp
service { 'nginx':
name => 'nginx.service',
ensure => 'running',
enable => 'true',
}
# config.pp
file { '/etc/nginx/nginx.conf':
* => $resAttributes,
content => template('nginxrtmp/redhat.nginx.conf.erb'),
}
Take a look at: https://docs.puppet.com/puppet/4.10/bgtm.html and this section in regarding to ordering https://docs.puppet.com/puppet/4.10/bgtm.html#c-ordering
Related
I want to send the output of logstash to mongodb for which I am using mongodb output plugins of logstash in linux. I am using logstash-1.5.0.beta1 and mongodb-3.0.3 versions. I am getting the following error :
LoadError: no such file to load -- mongo
require at org/jruby/RubyKernel.java:1065
require at /root/logstash-1.5.0.beta1/vendor/jruby/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55
require at /root/logstash-1.5.0.beta1/vendor/jruby/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:53
require at /root/logstash-1.5.0.beta1/vendor/bundle/jruby/1.9/gems/polyglot-0.3.5/lib/polyglot.rb:65
register at /root/logstash-1.5.0.beta1/lib/logstash/outputs/mongodb.rb:37
each at org/jruby/RubyArray.java:1613
start_outputs at /root/logstash-1.5.0.beta1/lib/logstash/pipeline.rb:158
run at /root/logstash-1.5.0.beta1/lib/logstash/pipeline.rb:79
execute at /root/logstash-1.5.0.beta1/lib/logstash/agent.rb:141
run at /root/logstash-1.5.0.beta1/lib/logstash/runner.rb:166
call at org/jruby/RubyProc.java:271
run at /root/logstash-1.5.0.beta1/lib/logstash/runner.rb:171
call at org/jruby/RubyProc.java:271
initialize at /root/logstash-1.5.0.beta1/vendor/bundle/jruby/1.9/gems/stud-0.0.18/lib/stud/task.rb:12
My logstash conf file is as follows:
input {
file{
path => "/something.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
output { stdout {codec => rubydebug}
mongodb{
collection => "users"
database => "test"
uri => "mongodb://localhost:27017/"
}
}
I run this using the command:
/root/logstash-1.5.0.beta1/bin/logstash -f /etc/logstash/logstash-mongodb.conf
Can anyone guide me to the solution?
Since you are giving file name as - path => "/something.csv" -- logstash is not able to identify. Add absolute path to file input path as below, so that logstash can identify the location and process it.
input {
file {
path => "C://myfile/something.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
Can someone please explain how to embed metadata into a custom metadata field in an MP4 file with exiftool? I've searched all the docs and it seems to be related to the config file that needs to be created. Here is what I'm working with. (I know this isnt even close, as its not doing XMP fields, but I havent found a single working example with XMP fields yet.
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Exif::Main' => {
0xd001 => {
Name => 'Show',
Writable => 'string',
WriteGroup => 'IFD0',
},
);
1; #end
The command I'm trying to run is:
exiftool -config exifToolConfig -show="Lightning" /reachengine/media/mezzanines/2015/02/13/13/CanyonFlight.mp4
Running this in a linux environment.
What is the properly way to set XMP metadata on custom metadata fields via ExifTool in linux on MP4 files?
The sample exiftool config file contains a number of working examples of custom XMP tags.
Basically, it is done like this:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::XMP::Main' => {
xxx => {
SubDirectory => {
TagTable => 'Image::ExifTool::UserDefined::xxx',
},
},
},
);
%Image::ExifTool::UserDefined::xxx = (
GROUPS => { 0 => 'XMP', 1 => 'XMP-xxx', 2 => 'Other' },
NAMESPACE => { 'xxx' => 'http://ns.myname.com/xxx/1.0/' },
WRITABLE => 'string',
MyNewXMPTag => { },
);
Then the command is
exiftool -config myconfig -mynewxmptag="some value" myfile.mp4
Puppet can be so frustrating sometimes.
I have multiple nodes that use a service "poodle", and it has been configured this way.
# SITE.PP
node 'tweedle.example.com' {
include basicstuff
include poodle
}
node 'beetle.example.com' {
include basicstuff
include poodle
}
## POODLE MODULE, manifests/init.pp
class poodle {
class {'poodle::install': }
class {'poodle::config': }
class {'poodle::service': }
Class ['poodle::install'] -> Class ['poodle::config'] ~> Class ['poodle::service']
}
...
class poodler::service {
service {'poodle':
ensure => 'running',
enable => true,
restart => "/etc/init.d/poodle stop && sleep 5 && /etc/init.d/poodle start",
subscribe => File['/opt/poodle/poodle.py'],
}
}
Now, let's say that I no longer need to run poodle on the "beetle" machine. How do I go about stopping the service on only that machine?
I've tried passing ensure => stopped, but I get a syntax error:
node 'beetle.example.com' {
include basicstuff
class poodle::service {
ensure => 'stopped'
}
}
Or maybe?
node 'beetle.example.com' {
include basicstuff
include poodle::service {
ensure => 'stopped'
}
}
Add a parameter to your service class that can be used for the ensure parameter on the service, like so
class poodler::service ($ensure = 'running') {
service {'poodle':
ensure => $ensure,
enable => true,
restart => "/etc/init.d/poodle stop && sleep 5 && /etc/init.d/poodle start",
subscribe => File['/opt/poodle/poodle.py'],
}
}
Then instead of including the class like your second attempt does, create the class as a resource and set the value of $ensure.
node 'beetle.example.com' {
include basicstuff
class {'poodle::service':
ensure => 'stopped',
}
}
That should kill the service.
Since the default for the $ensure paramater is set to running, you don't need to specify that when you actually want it running.
Can parameterize other parts of your classes if you want that could cause the app to be completely removed if you wanted to.
Good reading on this subject is at: Learning Puppet — Class Parameters
I have a class in the path 'app/classes' called 'Helper.php'. And also I have a config file 'custom.php' in 'app/config'.
The problem is, when I call the config file, this return FALSE.
class Helper {
public static function actions_header ($ractive) {
return Config::load('custom');
}
}
The custom config file
return array(
'sidebar_entities' => array (
array(
'name' => 'Dashboard',
'icon' => 'icon-dashboard',
'url' => 'dashboard'
),
array(
'name' => 'Álbumes',
'icon' => 'icon-music',
'url' => 'albums'
)
)
);
You probably need something like this:
// load the config
Config::load('custom', true); // true - so you load the config to group 'custom'
// return array of items
return Config::get('custom');
I have not tested this, but something like this should work.
Tried to repeat the same code and everything works fine for me. FuelPHP 1.7.
Up until 2012-08-28, load() only returned the loaded data on the initial call. If you called load() and the file is already loaded, it returned false. Since then, it will not load the file again, but return what is already loaded.
So the question is: how old is the version of Fuel you are using? Given the date of the change, that would be < 1.3, which is very old...
I have run into this issue as well. I run the following code. (I am running Fuel 1.6)
Config::load('config_file_name') //returns config array
Config::load('config_file_name') //returns false
Then I run the following to load a sub array of the config file.
Config::get('config_file_name.attr') //returns nothing
Turns out I just didn't understand the fuel documentation. Thanks #huglester, your answer made it all make sense for some reason.
The documentation says:
// This merges the "custom" config file in with the root config.
Config::load('custom');
// This loads the "custom" config file in a group named "custom".
Config::load('custom', true);
So, when you run Config::load('config_file_name'), you can access the config sub arrays by using Config::get('attr'). This is because the 'config_file_name' is merged with the root config.
If you want to use Config::get('config_file_name.attr'), then you need to load the config file using Config::load('config_file_name', true)
I'm very new to Puppet, and can't seem to find the answer to this question. I have a defined Puppet resource that takes a few arguments:
class xy::xy {
include apache:regular_apache
define setup($pkg_name, $xy_version, $pas_ver) {
file { '/etc/xy':
ensure => present,
notify => Service['apache'],
}
}
I'm trying to require this custom resource for another resource in another file.
class soft::buy {
include xy::xy
$xt_requires = [Xy::Xy::Setup["{'xt_buy': pkg_name => 'xt_buy_v01',
xy_version => '1.0.1',
pas_version => '2.1.4'}"]]
package { 'buy.xt':
ensure => $::buy_xt_version,
provider => 'xt',
require => $xt_requires,
}
}
The error that I get is this: Syntax error at 'require'; expected '}'
From reading the Puppet docs, it seems like I'm missing a comma or colon somewhere, but I've tried a variety of things. I was wondering how to properly require a custom defined resource with parameters for another resource? Thanks!
The syntax error can be fixed by the following code snippet.
package { 'buy.xt':
ensure => $::buy_xt_version,
provider => 'xt',
require => $xt_requires
}
[EDIT: The original code defines $xt_requires, not $requires]
You are defining the parameter require (which defines which resource needs to be handled first).
This is different from the language statement require (which is including a class and adding a dependency on the required class).
However, in the require-paramter, you cannot specify the parameters for the requirement, just it's presence. Fully correct would be:
xy::xy::setup {'xt_buy':
pkg_name => 'xt_buy_v01',
xy_version => '1.0.1',
pas_version => '2.1.4'
}
package { 'buy.xt':
ensure => $::buy_xt_version,
provider => 'xt',
require => Xy::Xy::Setup['xt_buy']
}