This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imagine our user from before: | |
class users { | |
user { 'elmo': | |
ensure => present, | |
shell => '/bin/zsh', | |
home => '/home/elmo', | |
} | |
file { '/home/elmo': | |
ensure => directory, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
============== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! AddLine() | |
call search("bbb") | |
call search("bbb") | |
let l:foundline = search("ccc") | |
call append(l:foundline, "ddd") | |
wq! | |
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Tests to go with https://stackoverflow.com/a/55451627/3787051 | |
setUp() { | |
cat > /tmp/before <<EOF | |
aaa | |
bbb | |
ccc | |
bbb | |
ccc | |
eee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat x | |
. include.sh | |
foo=bar | |
echo foo is $foo from in x | |
validate_vars foo | |
. y |
OlderNewer