Puppet - Error: Could not retrieve catalog; skipping run - automation

when I try to connect the puppet agent with puppet agent --test, I have this error :
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 400 on SERVER :Could not find class <my_module> for <my_agent> on node <my_agent>
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
I have import nodes on sites.pp and include <my_module> on nodes.pp
--edit--
Content of sites.pp :
import "nodes"
filebucket { main: server => "<my_master>" }
File { backup => main }
Exec { path => "/usr/bin:/usr/sbon:/bin:/sbin" }
Content of nodes.pp :
node "<my_agent>" {
include <my_module>
}
--edit--
What is the real problem ?
Thanks

I have created another VM, and that's working now ! =)
Maybe I have taken a mistake in the network configuration.

Related

"Lighthouse failed while trying to load a type: <XXX> Make sure the type is present in your schema definition."

I'm performing dusk test with lighthouse inside it like:
class ExampleTest extends DuskTestCase
{
use DatabaseMigrations;
public function testExample()
{
//this is a mutation for adding more stuff
$this->graphQL('mutation ...')
$this->browse(function (Browser $browser) use ($url) {
$browser->visit($url)
//asserts...
});
}
}
And on my mutations, the error message is:
"""Lighthouse failed while trying to load a type: typeFromMySchemaExample \n
\n
Make sure the type is present in your schema definition.\n
"""
I've already seen that schema is valid by:
php artisan lighthouse:validate-schema
And check the schema by it self to see if that type is present with:
php artisan lighthouse:print-schema
And cleared all configs/cache from laravel and lighthouse as in solution#1 with no success.
In my composer, I have:
laravel/dusk in v6.12.0
nuwave/lighthouse in v5.2.0
phpunit/phpunit in v9.5.2
ps:I commented that type in the graphql and the error keeps going by my import order in the schema.graphql.

deepstream error listen EADDRINUSE 127.0.0.1:6020

i try to run my first deepstream.io server from this link but i get this error :
error:
CONNECTION_ERROR | Error: listen EADDRINUSE 127.0.0.1:3003
PLUGIN_ERROR | connectionEndpoint wasn't initialised in time
f:\try\deep\node_modules\deepstream.io\src\utils\dependency-
initialiser.js:96
throw error
^
Error: connectionEndpoint wasn't initialised in time
at DependencyInitialiser._onTimeout
(f:\try\deep\node_modules\deepstream.io\src\utils\dependency-
initialiser.js:94:17)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
and this is my code:
const DeepStreamServer = require("deepstream.io")
const C = DeepStreamServer.constants;
const server = new DeepStreamServer({
host:'localhost',
port:3003
})
server.start();
In deepstream 3.0 we released our HTTP endpoint, by default this runs alongside our websocket endpoint.
Because of this, passing the port option at the root level of the config no longer works (it overrides both the HTTP and websocket port options, as you can see in the screen capture provided, both endpoints are trying to start on the same port).
You can override each of these ports as follows:
const deepstream = require('deepstream.io')
const server = new deepstream({
connectionEndpoints: {
http: {
options: {
port: ...
}
},
websocket: {
options: {
port: ...
}
}
}
})
server.start()
Or you can define your config in a file and point to that while initialising deepstream[1].
[1] deepstream server configuration
One solution that i find is passing empty config object so inseted of :
const server = new DeepStreamServer({
host:'localhost',
port:3003
})
i'm just using this :
const server = new DeepStreamServer({})
and now everything work's well.
All the bellow is for Version 4.2.2 (last version by now)
I was having the same Port in use or config file not found errors. And i was using typescript and i didn't pay attention too to the output dir and build (which can be a problem when one use typescript and build). I was able to run the server in the end. And i had a lot of analysis.
I checked up the code source and i have seen how the config is loaded
const SUPPORTED_EXTENSIONS = ['.yml', '.yaml', '.json', '.js']
const DEFAULT_CONFIG_DIRS = [
path.join('.', 'conf', 'config'), path.join('..', 'conf', 'config'),
'/etc/deepstream/config', '/usr/local/etc/deepstream/config',
'/usr/local/etc/deepstream/conf/config',
]
DEFAULT_CONFIG_DIRS.push(path.join(process.argv[1], '..', 'conf', 'config'))
DEFAULT_CONFIG_DIRS.push(path.join(process.argv[1], '..', '..', 'conf', 'config'))
Also i tested different things and all. Here what i came up with:
First of all if we don't precise any parameter in the constructor. A config from the default directories will get to load. If there isn't then the server fail to run.
And one of the places where we can put a config is ./conf in the same folder as the server node script.
Secondly we can precise a config as a string path (parameter in the constructor). config.yml or one of the supported extensions. That will allow the server to load the server config + the permission.yml and users.yml configs. Which too are supposed to be in the same folder. If not in the same folder there load will fail, and therefor the permission plugin will not load. And so does the users config. And no fall back to default will happen.
Thirdly the supported extensions for the config files are: yml, yaml, json, js.
In nodejs context. If nothing precised. There is no fallback to some default config. The config need to be provided in one of the default folders, or by precising a path to it. Or by passing a config object. And all the optional options will default to some values if not provided ( a bit bellow there is an example that can show that ). Know however that precising an end point is very important and required.
To precise the path, we need to precise the path to the config.yml file (the server config) [example: path.join(__dirname, './conf/config.yml')]. Then from the same dir permission.yml and users.yml will be retrieved (the extension can be any of the supported one). We can not precise a path to a directory, it will fail.
We can precise the path to permission config or user config separatly within config.yaml as shown bellow:
# Permissioning example with default values for config-based permissioning
permission:
type: config
options:
path: ./permissions.yml
maxRuleIterations: 3
cacheEvacuationInterval: 60000
Finally we can pass an object to configure the server, or by passing null as a parameter and use .set methods (i didn't test the second method). For configuring the server we need to follow the same structure as the yml file. With sometimes a bit different naming. The typescript declaration files or types show us the way. With an editor like vscode. Even if we are not using typescript we can keep get the auto completion and type definitions.
And the simplest for equivalent to the previous version is :
const webSocketServer = new Deepstream({
connectionEndpoints: [
{
type: 'ws-websocket',
options: {
port: 6020,
host: '127.0.0.1',
urlPath: '/deepstream'
}
}
]
});
webSocketServer.start();
the above is the new syntax and way.
const server = new DeepStreamServer({
host:'localhost',
port:3003
})
^^^^^^^ is completely deprecated and not supported in version 4 (the doc is not updated).

basic puppet construct not working, why?

I have created a puppet construct: the file-scructure can be taken out of the screenshot below.
But when I execute the sites.pp file with the following command...
sudo puppet apply manifests/sites.pp --modulepath=~/puppet/modules/
...I get an errormessage as it is shown in the screenshot below.
manifests/sites.pp:
import 'nodes.pp'
manifests/nodes.pp:
node 'rbalwprinst01' {
include teamviewer
}
modules/teamviewer/manifests/init.pp:
class teamviewer {
file { '/tmp/test':
content => "test",
}
}
What is the cause of this error?
Thanks in advance.
EDIT: The solution to the problem was to remove "sudo", so that the command gets executed by the normal user.

puppetlabs/apache: Invalid relationship: File[/etc/httpd/conf/httpd.conf]

I just pulled the puppetlabs-apache git repository since a few months and when I run puppet I get the message:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid relationship: File[/etc/httpd/conf/httpd.conf] { require => File[/etc/httpd/conf/ports.conf] }, because File[/etc/httpd/conf/ports.conf] doesn't seem to be in the catalog
Error: Could not retrieve catalog; skipping run
This is my site manifests file:
class { 'apache':
mpm_module => 'prefork',
}
include apache::mod::php
class { 'postgresql::server': }
class { 'zabbix':
zabbix_url => 'zabbix.dj-wasabi.nl',
manage_resources => true,
}
This always worked before, but fails every time know. It doesn't matter which puppet version (3 or 4) or Linux OS (Centos, Ubuntu or Debian).
Am I missing something?
Kind regards,
Werner
Looks like Puppetlabs is tracking this issue here:
https://tickets.puppetlabs.com/browse/MODULES-2850

Gulp task to SSH and then mysqldump

So I've got this scenario where I have separate Web server and MySQL server, and I can only connect to the MySQL server from the web server.
So basically everytime I have to go like:
step 1: 'ssh -i ~/somecert.pem ubuntu#1.2.3.4'
step 2: 'mysqldump -u root -p'password' -h 6.7.8.9 database_name > output.sql'
I'm new to gulp and my aim was to create a task that could automate all this, so running one gulp task would automatically deliver me the SQL file.
This would make the developer life a lot easier since it would just take a command to download the latest db dump.
This is where I got so far (gulpfile.js):
////////////////////////////////////////////////////////////////////
// Run: 'gulp download-db' to get latest SQL dump from production //
// File will be put under the 'dumps' folder //
////////////////////////////////////////////////////////////////////
// Load stuff
'use strict'
var gulp = require('gulp')
var GulpSSH = require('gulp-ssh')
var fs = require('fs');
// Function to get home path
function getUserHome() {
return process.env.HOME || process.env.USERPROFILE;
}
var homepath = getUserHome();
///////////////////////////////////////
// SETTINGS (change if needed) //
///////////////////////////////////////
var config = {
// SSH connection
host: '1.2.3.4',
port: 22,
username: 'ubuntu',
//password: '1337p4ssw0rd', // Uncomment if needed
privateKey: fs.readFileSync( homepath + '/certs/somecert.pem'), // Uncomment if needed
// MySQL connection
db_host: 'localhost',
db_name: 'clients_db',
db_username: 'root',
db_password: 'dbp4ssw0rd',
}
////////////////////////////////////////////////
// Core script, don't need to touch from here //
////////////////////////////////////////////////
// Set up SSH connector
var gulpSSH = new GulpSSH({
ignoreErrors: true,
sshConfig: config
})
// Run the mysqldump
gulp.task('download-db', function(){
return gulpSSH
// runs the mysql dump
.exec(['mysqldump -u '+config.db_username+' -p\''+config.db_password+'\' -h '+config.db_host+' '+config.db_name+''], {filePath: 'dump.sql'})
// pipes output into local folder
.pipe(gulp.dest('dumps'))
})
// Run search/replace "optional"
SSH into the web server runs fine, but I have an issue when trying to get the mysqldump, I'm getting this message:
events.js:85
throw er; // Unhandled 'error' event
^
Error: Warning:
If I try the same mysqldump command manually from the server SSH, I get:
Warning: mysqldump: unknown variable 'loose-local-infile=1'
Followed by the correct mylsql dump info.
So I think this warning message is messing up my script, I would like to ignore warnings in cases like this, but don't know how to do it or if it's possible.
Also I read that using the password directly in the command line is not really good practice.
Ideally, I would like to have all the config vars loaded from another file, but this is my first gulp task and not really familiar with how I would do that.
Can someone with experience in Gulp orient me towards a good way of getting this thing done? Or do you think I shouldn't be using Gulp for this at all?
Thanks!
As I suspected, that warning message was preventing the gulp task from finalizing, I got rid of it by commenting the: loose-local-infile=1 From /etc/mysql/my.cnf