Skip to content

Instantly share code, notes, and snippets.

[root@master ~]# export FACTER_operatingsystem=blah
[root@master ~]# puppet apply -e 'notify { "${::osfamily}": }'
Notice: Linux
Notice: /Stage[main]//Notify[Linux]/message: defined 'message' as 'Linux'
Notice: Finished catalog run in 0.24 seconds
[root@master ~]# unset FACTER_operatingsystem
[root@master ~]# puppet apply -e 'notify { "${::osfamily}": }'
Notice: RedHat
Notice: /Stage[main]//Notify[RedHat]/message: defined 'message' as 'RedHat'
Notice: Finished catalog run in 0.23 seconds
Imagine our user from before:
class users {
user { 'elmo':
ensure => present,
shell => '/bin/zsh',
home => '/home/elmo',
}
file { '/home/elmo':
ensure => directory,
[root@logdata01 ~]# curl -XPUT "localhost:9200/_snapshot/backup/tcom_snapshot?wait_for_completion=true&pretty"
{
"snapshot" : {
"snapshot" : "tcom_snapshot",
"indices" : [ "kibana-int", "logstash-2014.09.20", "logstash-2014.09.19", "logstash-2014.09.25", "logstash-2014.09.29", "logstash-2014.09.24", "logstash-2014.09.26", "logstash-2014.09.23", "logstash-2014.09.27", "logstash-2014.09.28" ],
"state" : "SUCCESS",
"start_time" : "2014-09-29T08:37:53.763Z",
"start_time_in_millis" : 1411979873763,
"end_time" : "2014-09-29T08:43:07.494Z",
"end_time_in_millis" : 1411980187494,
alexs-mbp:playbooks-internal-d291702 alexharvey$ cat roles/nginx/templates//stream.conf.j2
#{{ ansible_managed }}
{% for v in nginx_streams[item] %}
{% if v != "" %}
{{ v.replace(";",";\n ").replace(" {"," {\n ").replace(" }"," \n }\n") }}
{% if v.find('{') == -1%};
{% endif %}
{% endif %}
{% endfor %}
# common.yaml:
---
service::common::httpd::packages: [ "Package['package-x']", "Package['package-y']" ]
# init.pp:
class test {
package { 'package-x': ensure => installed }
package { 'package-y': ensure => installed }
Just fixing the syntax issues in:
class profile::sec::sec_model {
hiera_hash('users').each |String $user, Hash $user_hash| {
$user_hash.each |String $attr, String $value| {
user { "$user":
"${attr}" => "${value}"
}
}
}
This gist is to show that this question here:
https://stackoverflow.com/a/38978201/3787051
Is not answered by this answer here:
https://stackoverflow.com/q/55220417/3787051
This is Bash unit test code to test various solutions that were suggested as answers to my question.
==============
function! AddLine()
call search("bbb")
call search("bbb")
let l:foundline = search("ccc")
call append(l:foundline, "ddd")
wq!
endfunction
## Tests to go with https://stackoverflow.com/a/55451627/3787051
setUp() {
cat > /tmp/before <<EOF
aaa
bbb
ccc
bbb
ccc
eee
$ cat x
. include.sh
foo=bar
echo foo is $foo from in x
validate_vars foo
. y