todd.seidenberg
01/18/2023, 3:43 PMtodd.seidenberg
01/18/2023, 3:43 PMtodd.seidenberg
01/18/2023, 3:44 PMvchepkov
01/18/2023, 3:46 PMDavid Sandilands
01/18/2023, 3:48 PMSlackbot
01/18/2023, 3:49 PMNeeloj
01/18/2023, 4:02 PMfile { 'copy_check_test':
ensure => 'directory',
source => 'puppet:///modules/check_test',
path => '/etc/check_test',
ignore => 'custom.conf',
}
file { 'create_custom_conf':
ensure => file,
path => '/etc/check_test/custom.conf',
replace => false,
source => 'puppet:///modules/check_test/custom.conf',
require => File['copy_check_test'],
}
So not puppet will copy the directory content to /etc/check_test and overwrite it every time except ( ignore ) the custom.conf file
By second file resource type I copy the custom.conf file to the /etc/check_test
Now the second run for puppet agent -t the all files will be overwritten in /etc/check_test except custom.confYury Bushmelev
01/18/2023, 4:16 PMpath for the file resource.. other resources have other “namevars” (e.g. it is name for package resource)Yury Bushmelev
01/18/2023, 4:20 PMNeeloj
01/18/2023, 4:20 PMrismoney
01/18/2023, 4:31 PMrismoney
01/18/2023, 4:34 PM! ($var in [ 'one', 'two' ]) # guess i could do thisnatemccurdy
01/18/2023, 5:20 PMunless which is the equivalent of "if not".
For example:
$array = ['cat', 'dog', 'mouse']
if 'dog' in $array {
notice('dog is in the array')
}
unless 'rabbit' in $array {
notice('rabbit is not in the array')
}
$ puppet apply example.pp
Notice: Scope(Class[main]): dog is in the array
Notice: Scope(Class[main]): rabbit is not in the arraynatemccurdy
01/18/2023, 5:21 PMunless which is the equivalent of "if not".
For example:
$array = ['cat', 'dog', 'mouse']
if 'dog' in $array {
notice('dog is in the array')
}
unless 'rabbit' in $array {
notice('rabbit is not in the array')
}
$ puppet apply example.pp
Notice: Scope(Class[main]): dog is in the array
Notice: Scope(Class[main]): rabbit is not in the arraynatemccurdy
01/18/2023, 5:23 PMunless, then yeah, what you mentioned will also work as long as you make sure you're negating the correct part of the expression (which you did, and which in this case is the result of <foo> in $array):
For example:
if !('rabbit' in $array) {
notice('rabbit is not in the array')
}natemccurdy
01/18/2023, 5:24 PMunless, then yeah, what you mentioned will also work as long as you make sure you're negating the correct part of the expression (which you did): For example:
if !('rabbit' in $array) {
notice('rabbit is not in the array')
}natemccurdy
01/18/2023, 5:26 PMunless, then yeah, what you mentioned will also work as long as you make sure you're negating the correct part of the expression (which you did, and which in this case is the result of <foo> in $array):
For example:
if !('rabbit' in $array) {
notice('rabbit is not in the array')
}todd.seidenberg
01/18/2023, 6:58 PMPat Riehecky
01/18/2023, 6:59 PMmy_subsystems:
- ssh
- nginx
- nfsclient
How do I write a query that will find the fqdn of all hosts with my_subsystems=nginx
I've tried ["from", "facts", ["and", ["=", "name", "my_subsystems"], ["=", "value", "nginx"]]]
but that returns no results, but ["from", "facts", ["and", ["=", "name", "my_subsystems"]] shows the fact is in the DB and listed as an arraytodd.seidenberg
01/18/2023, 7:03 PMSlackbot
01/18/2023, 7:06 PMnatemccurdy
01/18/2023, 7:07 PMpuppet query 'inventory[certname] { "nginx" in facts.my_subsystems }"Pat Riehecky
01/18/2023, 7:07 PMnatemccurdy
01/18/2023, 7:07 PMpuppet query 'inventory[certname] { "nginx" in facts.my_subsystems }'Slackbot
01/18/2023, 7:08 PMbrokencode
01/18/2023, 7:09 PMnatemccurdy
01/18/2023, 7:10 PMbrokencode
01/18/2023, 7:10 PMSlackbot
01/18/2023, 7:18 PMgary
01/18/2023, 7:19 PMFacter.value . Any ideas whats going on / what am I doing wrong?
Note this is only when I set the external fact (/etc/facter/facts.d/fact.json). The custom fact work fine when running without the module.
Pasting snippets in this thread so I don't spam everyone.