Exported resources not working with puppet - ruby

I've written a module to set up the Prometheus node_exporter (in here called ni_trending). Now I need to add all FQDNs of the nodes to a simple file: So declaring an exported resource makes much sense here. PuppetDB is configured and working.
Here's the declaration, within my config.pp:
##node_exporter { "${listen_address}":
hostname => $ni_trending::hostname,
listen_port => $ni_trending::listen_port,
}
When the module is applied on the node I get following error:
Error: Could not retrieve catalog from remote server: Error 500 on
SERVER: Server Error: Evaluation Error: Error while evaluating a
Resource Statement, Invalid export in Class[Ni_trending]: {} is not a
resource on node ydixken-dev01.berlin.ni
Within the ni_trending module I'm retrieving all collected resources via:
Node_exporter <<| |>>
What is missing here?

Related

Unable to bootstrap nomad cluster with multi-region setup "Error bootstrapping: Unexpected response code: 500 (No path to region)"

I am trying to setup Nomad ACL among a multi region and multi datacenter cluster,
In server stanza I added the below on all server nodes
server {
enabled = true
bootstrap_expect = 2
encrypt = "XXX-same-on-all-servers-XXX"
authoritative_region = "HOME-DC"
server_join {
retry_join = ["server1", "server2", "server3"]
}
}
acl {
enabled = true
}
After I restart all the servers on tailing the logs this is what I get
2021-02-01T11:38:04.156Z [WARN] nomad.rpc: no path found to region: region=HOME-DC
2021-02-01T11:38:04.157Z [ERROR] nomad: failed to fetch namespaces from authoritative region: error="No path to region"
And this is I get if I run
nomad acl bootstrap -address=$NOMAD_ADDR
Error bootstrapping: Unexpected response code: 500 (No path to region)
On the docs I see it asks you to set the replication_token value of the acl stanza, but I am not clear on how to do it, Does it has to be generated somehow like the encrypt token? If yes then how? Reference
authoritative region: authoritative_region is not required and should be removed. After removing it, run nomad acl bootstrap will success.
non-authoritative regions:
authoritative_region is always required.
replication_token is required too, replication_token could be your authoritative's bootstrap token, or create another token from for less capabilities.

How to set the "cluster" property in prisma.yml

Thanks for reading my question in advance. I am just start to use graphql and prisma following this tutorial.
I have the following Error when Deploying the Prisma database service:
Error: No cluster set. Please set the "cluster" property in your prisma.yml
at /Users/judy/howtographql/server/node_modules/graphql-config-extension-prisma/src/index.ts:89:11
at step (/Users/judy/howtographql/server/node_modules/graphql-config-extension-prisma/dist/index.js:40:23)
at Object.next (/Users/judy/howtographql/server/node_modules/graphql-config-extension-prisma/dist/index.js:21:53)
at fulfilled (/Users/judy/howtographql/server/node_modules/graphql-config-extension-prisma/dist/index.js:12:58)
at <anonymous>
error Command failed with exit code 1.
ERROR: "playground" exited with 1.
error Command failed with exit code 1.
I looked over the tutorial to find that there is nothing about how to set the cluster. I wonder how to fix this problem.
The default prisma.yaml is:
# the name for the service (will be part of the service's HTTP endpoint)
service: hackernews-graphql-js
# the cluster and stage the service is deployed to
stage: dev
# to disable authentication:
# disableAuth: true
secret: mysecret123
# the file path pointing to your data model
datamodel: datamodel.graphql
It could be just that you may have entered an incorrect endpoint address. Please refer https://github.com/prisma/graphql-config-extension-graphcool/issues/8

libnetwork: Error: unknown command "/var/run/docker/netns/582bd184e561" for "some_app"

I am trying to setup a network in the container (using Docker's libnetwork and libcontainer), but I keep running into this issue. As far as I can tell it's looking into some_app to get some sandbox information?
INFO[3808] No non-localhost DNS nameservers are left in resolv.conf. Using default external servers : [nameserver 8.8.8.8 nameserver 8.8.4.4]
INFO[3808] IPv6 enabled; Adding default IPv6 external servers : [nameserver 2001:4860:4860::8888 nameserver 2001:4860:4860::8844]
Error: unknown command "/var/run/docker/netns/582bd184e561" for "some_app"
Run 'some_app --help' for usage.
ERRO[3808] Resolver Setup/Start failed for container 6b81802576bd4f16aa117061f81b5c3e, "setup not done yet"
ERRO[3808] failed to add interface vethef0a693 to sandbox: failed in prefunc: failed to set namespace on link "vethef0a693": invalid argument
ERRO[3808] failed to add interface vethef0a693 to sandbox: failed in prefunc: failed to set namespace on link "vethef0a693": invalid argument
I was wondering if anyone could help me make sense of this and perhaps prevent it. Are these two separate errors?
Thank you
Here is the library I am trying to use
It took me a while to figure this out, but here goes:
Just like in Docker, libnetwork creates a veth interface pair. It then moves one end of the veth pair into the container namespace. During this process libnetwork tries to execute commands registered at runtime on the current instance of the binary (some_app in this case).
These commands do not exist on the external interface of some_app however. They are injected later using a library called reexec. For this to work, reexec needs to be initialized like this:
if reexec.Init() {
return
}
Also note that according to this thread libnetwork is currently not supported for applications outside of Docker.
NB: I discovered this by reading the source code, so I might be wrong but my issue went away after this.

graphite puppet error while installation

Getting the below error while installing graphite server using puppet
The pupet module installed for graphite
puppet module install dwerder-graphite
This is the content of graphite.pp
cat graphite.pp
The output
class {'graphite':
}
This the Command
puppet apply graphite.pp
The error what i received:
warning: Scope(Class[Graphite::Params]): Could not look up qualified variable 'graphite::gr_web_group'; class graphite has not been evaluated at /etc/puppet/modules/graphite/manifests/params.pp:97
warning: Scope(Class[Graphite::Params]): Could not look up qualified variable 'graphite::gr_web_group'; class graphite has not been evaluated at /etc/puppet/modules/graphite/manifests/params.pp:97
warning: Scope(Class[Graphite::Params]): Could not look up qualified variable 'graphite::gr_web_user'; class graphite has not been evaluated at /etc/puppet/modules/graphite/manifests/params.pp:103
warning: Scope(Class[Graphite::Params]): Could not look up qualified variable 'graphite::gr_web_user'; class graphite has not been evaluated at /etc/puppet/modules/graphite/manifests/params.pp:103
Failed to parse template graphite/opt/graphite/conf/carbon.conf.erb:
Filepath: /usr/lib/ruby/site_ruby/1.8/puppet/parser/scope.rb
Line: 459
Detail: undefined method `[]' for #<Puppet::Parser::Scope:0x7f82caef1e98>
at /etc/puppet/modules/graphite/manifests/config.pp:171 on node test
I'm running on RHEL
cat /etc/redhat-release
Red Hat Enterprise Linux Workstation release 6.4 (Santiago)
Where do you put file graphite.pp? Here is way to test the modules recommend by Puppetlabs.
If you puppet modules is /etc/puppet/modules, then create tests folder under it, and create graphite.pp, then add content in it:
include graphite
When you manually apply the change, run this command:
cd /etc/puppet/modules/tests
puppet apply --modulepath=/etc/puppet/modules graphite.pp

Foreman with puppet node.rb error 404 Not Found

I have installed foreman-1.2 with puppet, after installation i have registered my puppet to smart-proxy on foreman.
when i run following command
[root#puppet ~]# puppet agent -t
Warning: Unable to fetch my node definition, but the agent run will continue:
Warning: Error 400 on SERVER: Failed to find puppet.example.com via exec: Execution of '/etc/puppet/node.rb puppet.example.com' returned 1: --- false
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed when searching for node puppet.example.com: Failed to find puppet.example.com via exec: Execution of '/etc/puppet/node.rb puppet.example.com' returned 1: --- false
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
I tried following
[root#puppet ~]# /etc/puppet/node.rb puppet.example.com
--- false
Error retrieving node puppet.example.com: Net::HTTPNotFound
foreman.log debug
Started GET "/node/puppet.example.com?format=yml" for 10.101.20.15 at 2014-03-25 21:01:47 -0400
Processing by HostsController#externalNodes as YML
Parameters: {"name"=>"puppet.example.com"}
Setting Load (1.3ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'restrict_registered_puppetmasters' ORDER BY name LIMIT 1
Setting Load (0.3ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'require_ssl_puppetmasters' ORDER BY name LIMIT 1
SmartProxy Load (0.5ms) SELECT `smart_proxies`.* FROM `smart_proxies` INNER JOIN `features_smart_proxies` ON `features_smart_proxies`.`smart_proxy_id` = `smart_proxies`.`id` INNER JOIN `features` ON `features`.`id` = `features_smart_proxies`.`feature_id` WHERE `features`.`name` = 'Puppet' ORDER BY smart_proxies.name
Setting Load (0.3ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'trusted_puppetmaster_hosts' ORDER BY name LIMIT 1
Verifying request from ["puppet.example.com"] against ["puppet.example.com"]
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`login` = 'admin' LIMIT 1
Setting current user thread-local variable to admin
Host::Managed Load (0.7ms) SELECT `hosts`.* FROM `hosts` WHERE `hosts`.`type` IN ('Host::Managed') AND `hosts`.`certname` = 'puppet.example.com' LIMIT 1
Host::Managed Load (0.6ms) SELECT `hosts`.* FROM `hosts` WHERE `hosts`.`type` IN ('Host::Managed') AND `hosts`.`name` = 'puppet.example.com' LIMIT 1
Completed 404 Not Found in 25ms (ActiveRecord: 4.1ms)
Am i missing something? do i need to create host first on foreman GUI? I don't understand concept of node.rb
First you should check the contents of node.rb. There are a number of variables that need to be set for it to work. It looks like this hasn't been done because the "Net::HTTPNotFound" says it can't find your Foreman server.
Second, yes and no -- the host needs to be defined in Froreman first. If the host doesn't exist in Foreman yet Foreman "may" create it -- it really depends on how you've set up Foreman.
If memory serves properly, I believe a non-existent host will be created when the facts are uploaded by node.rb (if that is enabled). If you're just running it from the command line, then no facts are being uploaded and the host isn't being created.
For your testing, ensure the host is created in Foreman. Then test node.rb (after you check that the vars in it are set properly).
EDIT:
You're last question: node.rb's main function is to get the yaml formated config for a server and hand it to puppet. Secondary it also functions to upload facts from the server to Foreman -- which can be used in classifying the server in Foreman.
Basically you have to make sure that the master and the agent are familiar with each other (either via /etc/hosts or dns). This error is usually raised when the master can not resolve the agent's name (e.g puppet.example.com)

Resources