itamae/cookbooks/vault/attributes.rb

27 lines
871 B
Ruby
Raw Normal View History

2021-06-21 12:27:04 +00:00
# -------------------------------------------
# Specifying the default settings:
# -------------------------------------------
2022-03-13 05:06:36 +00:00
case run_command('grep VERSION_ID /etc/os-release | awk -F\" \'{print $2}\'').stdout.chomp
2024-04-27 05:58:04 +00:00
when "20.04", "22.04"
2022-03-13 05:06:36 +00:00
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
2022-03-13 05:08:14 +00:00
hostname = run_command('uname -n').stdout.chomp
2021-06-21 12:27:04 +00:00
node.reverse_merge!({
'vault' => {
'manager' => false,
2022-03-13 05:06:36 +00:00
'ipaddr' => ipaddr,
2022-03-13 05:08:14 +00:00
'hostname' => hostname,
'ips' => ['192.168.10.141', '192.168.10.142', '192.168.10.143'],
2021-06-21 12:27:04 +00:00
}
})