Get IPAddress of the server.
This commit is contained in:
parent
66a32f6d54
commit
bbe302764e
|
@ -1,8 +1,21 @@
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Specifying the default settings:
|
# Specifying the default settings:
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
|
case run_command('grep VERSION_ID /etc/os-release | awk -F\" \'{print $2}\'').stdout.chomp
|
||||||
|
when "20.04", "22.04"
|
||||||
|
cmd = 'LANG=C ip a | grep "inet " | grep -v -E "(127|172)" | cut -d" " -f6 | perl -pe "s/\/.+//g"'
|
||||||
|
|
||||||
|
when "18.04"
|
||||||
|
cmd = 'LANG=C /sbin/ifconfig | grep "inet " | grep -v -E "(127|172)" | cut -d" " -f10'
|
||||||
|
|
||||||
|
else
|
||||||
|
cmd = 'LANG=C /sbin/ifconfig | grep "inet addr" | grep -v -E "(127|172)" | awk "{print $2;}" | cut -d: -f2 | cut -f 1 -d " " | tail -1'
|
||||||
|
end
|
||||||
|
ipaddr = run_command(cmd).stdout.chomp
|
||||||
|
|
||||||
node.reverse_merge!({
|
node.reverse_merge!({
|
||||||
'loki' => {
|
'loki' => {
|
||||||
|
'ipaddr' => ipaddr,
|
||||||
'url' => 'https://github.com/grafana/loki/releases/download/',
|
'url' => 'https://github.com/grafana/loki/releases/download/',
|
||||||
'zip' => 'loki-linux-amd64.zip',
|
'zip' => 'loki-linux-amd64.zip',
|
||||||
'storage' => '/opt/loki/',
|
'storage' => '/opt/loki/',
|
||||||
|
|
|
@ -13,7 +13,7 @@ template '/etc/loki/loki-config.yml' do
|
||||||
group 'root'
|
group 'root'
|
||||||
mode '644'
|
mode '644'
|
||||||
|
|
||||||
variables(ipaddr: node['consul']['ipaddr'])
|
variables(ipaddr: node['loki']['ipaddr'])
|
||||||
|
|
||||||
notifies :restart, 'service[loki]'
|
notifies :restart, 'service[loki]'
|
||||||
end
|
end
|
||||||
|
@ -36,7 +36,7 @@ template '/etc/consul.d/service-loki.json' do
|
||||||
group 'consul'
|
group 'consul'
|
||||||
mode '644'
|
mode '644'
|
||||||
|
|
||||||
variables(ipaddr: node['consul']['ipaddr'])
|
variables(ipaddr: node['loki']['ipaddr'])
|
||||||
|
|
||||||
notifies :reload, 'service[consul]'
|
notifies :reload, 'service[consul]'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue