can't get the require work with file in puppet module - class

i try to get the following code to run:
class common
{
...
# common packages
package
{
["lsb-release", "figlet"]: ensure => installed,
}
# Print some information if someone logs in:
file { "/etc/motd":
#require => [ Package["figlet"], File["/usr/bin/figlet"] ],
require => Package["figlet"],
content => generate('/usr/bin/env', '/usr/bin/figlet','-w', '186', '-p', '-f', 'banner', "$hostname"),
}
....
}
should't this work?
i get the following error:
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to execute generator /usr/bin/env: Execution of '/usr/bin/env /usr/bin/figlet -w 186 -p -f banner hostname' returned 127: /usr/bin/env: /usr/bin/figlet: No such file or directory
at /etc/puppet/modules/common/manifests/init.pp:37 on node puppetmaster.local
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run
first i had no require (row 12) and no package (row 5-8) in the code, to fix the errors i thought to i can simply add the row 12 (require package figlet) but it does not work. so i added the package figlet, but the the error does not go away.
how to add this dependency? shouldn't puppet run through the code and don't skip the run totally?

generate() runs on the server, not the client. (It's a parser function so it has to run on the server)
The class as you've written it will ensure that clients get figlet installed on them, but then tries to run figlet on the puppetmaster. Just install figlet on your puppetmasters and you won't need the package resources.
Also use smslant font, not banner :)

Related

CREATE EXTENSION pljava failed on PostgreSql 9.6

I try to install pljava for postgesql 9.6 in Ubuntu 16.04, but it fails with error.
A gradlew script makes an installation, but it fails with the following error"
Failed to execute: CREATE EXTENSION pljava; because: ERROR: could not access file "pljava-so-1.5.1-BETA1": No such file or directory
A gradlew source:
Sql sql = establishConnection()
try {
sql.execute("SET pljava.libjvm_location TO '${javaNative}';")
sql.execute("SET pljava.vmoptions TO '-Xshare:on -XX:+DisableAttachMechanism';")
sql.execute("ALTER DATABASE postgres SET pljava.libjvm_location FROM CURRENT;")
sql.execute("ALTER DATABASE postgres SET pljava.vmoptions FROM CURRENT;")
sql.execute("CREATE EXTENSION pljava;")
} finally {
sql.close()
}
As i understand, it fails during a creation of extension pljava, commands above was executed without any errors.
According to #ChapmanFlack advice:
I have no any mentions about pljava-so-1.5.1-BETA1 file at pg_config --libdir directory. Also i didn't find that file at pg_config --sharedir
grep LOAD pljava--1.5.1-BETA1.sql output following:
touched off by the LOAD command, making possible a decent installation
LOAD command, but finds the CREATE EXTENSION command instead). So,
temporarily LOAD 'pljava-so-1.5.1-BETA1'; Ok, the LOAD succeeded, so
everything happened ... unless ... the same PostgreSQL turns LOAD into
a (successful) no-op in that case, meaning To fail fast in that case,
expect that the LOAD actions should have
I think PL/Java builds from a prebuilt, because of that line at gradlew:
commandLine 'java', '-jar', '../installer/build/dependencies/pljava-pg9.6.jar'
I would be appreciate for any advice

Modulefile - Module loading when module unload is called

So I am trying to have module files dynamically load/unload when you load one. I am trying to do this in a way so that I can unload conflicting modules (instead of just using the conflict variable as it just throws an error)
However, when I call module load on one file that tries to unload another... the second one is loaded instead of unloaded. Example is below:
test1 Modulefile:
#%Module1.0
##
## Testing
##
if { [module-info mode load] && [is-loaded test2] } {
puts stderr "Unloading test2 (From test1)"
module unload test2
}
test2 Modulefile:
#%Module1.0
##
## Test2
##
if { [module-info mode load] } {
puts stderr "Loading test2\n"
}
if { [module-info mode remove] } {
puts stderr "Unloading test2\n"
}
Output when I try to load test1 while test2 is loaded:
root#host:/usr/local/modules# module load test1
Unloading test2 (From test1)
Loading test2
module --version output:
VERSION=3.2.10
DATE=2012-12-21
AUTOLOADPATH=undef
BASEPREFIX="/usr"
BEGINENV=99
CACHE_AVAIL=undef
DEF_COLLATE_BY_NUMBER=undef
DOT_EXT=""
EVAL_ALIAS=1
HAS_BOURNE_FUNCS=1
HAS_BOURNE_ALIAS=1
HAS_TCLXLIBS=undef
HAS_X11LIBS=1
LMSPLIT_SIZE=1000
MODULEPATH="/usr/share/modules/modulefiles"
MODULES_INIT_DIR="/usr/Modules/3.2.10/init"
PREFIX="/usr/Modules/3.2.10"
TCL_VERSION="8.6"
TCL_PATCH_LEVEL="8.6.1"
TMP_DIR="/tmp"
USE_FREE=undef
VERSION_MAGIC=1
VERSIONPATH="/usr/share/modules/versions"
WANTS_VERSIONING=1
WITH_DEBUG_INFO=undef
Does anyone know why or how I can fix this? Is there another command that I can put in the Modulefile that unloads another module? Or is there an better alternative to using Modules?
Thanks in advanced for reading and helping!
The issue you describe is coming from a bug affecting Modules version <= 3.2.10. Newer Modules version (> 3.2.10) or up-to-date "environment-modules" package on RedHat-like Linux distribution have fixed this issue:
For instance on a recent Fedora system, excepted behavior is obtained:
$ module -V
Modules Release 4.1.3 (2018-06-18)
$ module load test2
Loading test2
$ module list
Currently Loaded Modulefiles:
1) test2
$ module load test1
Unloading test2 (From test1)
Unloading test2
$ module list
Currently Loaded Modulefiles:
1) test1

Mongo DB error while running puppet script

While running the command
puppet apply --verbose --debug --modulepath puppet/manifests/modules
puppet/manifests/devbox.pp
I get the following error
err:/Stage[main]/Mongo-datastore/Package[mongodb]/ensure: change from absent to present failed:Could not find package mongo-10genmongo-10gen-server
To fix this error I installed mongodb manually and i changed the mongodb entry in the following package as
name => ["mongodb-org-2.6.4.1""mongodb-org-2.6.4.1"]**
package {
"mongodb":
name => ["mongo-10gen", "mongo-10gen-server"],
ensure => installed,
require => File['/etc/yum.repos.d/10gen.repo'];
}
Can you please tell me why I need to manually install the package while I have already written the script to install mongo-10gen and mongo-10gen-server.

import statements fail

I'm a Puppet newbie. I'm trying to setup a chef-style deployment environment. I have a puppet-master server set up, and I'd like to be able to configure/deploy to two nodes that I set up simultaneously.
What I'm expecting with my puppet setup right now is for my two servers (called img01 and img02) to automatically create a file called /tmp/test_file.txt.
I'm not even sure how to really "load in" a manifest. I just assumed that anything in site.pp would automatically get loaded, but that doesn't seem to be the case. When I run "puppet apply /etc/puppet/manifests/site.pp", I get the following:
Error: Could not parse for environment production: No file(s) found for import of 'test' at /etc/puppet/manifests/site.pp:3 on node puppet.lgwp.com
Error: Could not parse for environment production: No file(s) found for import of 'test' at /etc/puppet/manifests/site.pp:3 on node puppet.lgwp.com
This is what my manifest setup looks like right now:
Cert list on the puppet-master server:
+ "img01.lgwp.com.com" (SHA256) (omitted)
+ "img02.lgwp.com" (SHA256) (omitted)
+ "puppet.lgwp.com" (SHA256) (omitted) (alt names: "DNS:puppet.lgwp.com")
/etc/puppet/manifest/site.pp:
import "test"
import "nodes"
Exec { path => "/usr/bin:/usr/sbin/:/bin:/sbin" }
/etc/puppet/manifest/nodes.pp:
import "test"
node "imageserver" {
include "tempfile"
}
node 'img01.lgwp.com' inherits imageserver {
}
node 'img02.lgwp.com' inherits imageserver {
}
/etc/puppet/modules/test/manifests/test.pp:
class test {
package { test: ensure => latest }
file { "test_file":
path => '/tmp/test_file.txt',
ensure => present,
mode => 0755,
content => 'hola world',
source => "puppet:///modules/test/test_file",
require => Package["test"],
}
}
Don't use import. Just don't.
Remove the existing import statements and change the manifest setting in your puppet.conf to include all files in /etc/puppet/manifests.
[main]
manifest=/etc/puppet/manifests/
include tempfile makes no sense either, unless you have a tempfile module. Try
include test
Other classes in the test module should be named test::something and can also just be included. Puppet locates the manifests in the according modules. There is literally no need to use import anymore.

How to configure and use Mailgun's SDK with composer-php?

I installed Composer and a SDK for Mailgun's service. These are the steps i followed:
# current directory
cd ~
# Install Composer
curl -sS https://getcomposer.org/installer | php
# Add Mailgun as a dependency
php composer.phar require mailgun/mailgun-php:~1.7
According to the instructions, all I did after that was (index.php):
<?php
require 'vendor/autoload.php';
use Mailgun\Mailgun;
# First, instantiate the SDK with your API credentials and define your domain.
$mg = new Mailgun("key-my-key-goes-here-987654321");
$domain = "somedomain.com";
Then, I tried to get the list of bounced emails:
$data = $mg->get("$domain/bounces", array('limit' => 15, 'skip' => 0));
var_dump($data);
...and I'm getting this error:
Warning: require(vendor/autoload.php): failed to open stream: No such
file or directory in /var/www/html/index.php on line 2 Fatal error:
require(): Failed opening required 'vendor/autoload.php'
(include_path='.:/usr/share/pear:/usr/share/php') in
/var/www/html/index.php on line 2
So I'm guessing it has something to do with composer's installation/configuration perhaps? Thanks for any help...
The way you programmed it, you must have the following files all in the same directory:
composer.json
index.php (your test script)
And you must have run the composer require command while being inside this directory. This will also create a directory named vendor here, and add plenty of files, amongst them vendor/autoload.php.
If however your test script isn't in this location, the require call will not find the file where you tell PHP to find it. This isn't any failure of Composer, but simply the fact that you have to include that file according to your situation, not by copy&paste code. If you change the path of your test script, you have to change the path of the vendor directory as well.