#!/usr/bin/env ruby

require "json"

ip = JSON.parse(`terraform output -json ip`)

File.open("ansible/hosts", "w+") do |file|
  file.puts("[servers]")
  ip["value"].each do |name, (public, private)|
    next unless /redmine/.match?(name)
    file.puts("#{name} ansible_host=#{public} public_ip=#{public} private_ip=#{private}")
  end
end

#!/usr/bin/env ruby

require "json"

ip = JSON.parse(`terraform output -json ip`)

File.open("ansible/hosts", "w+") do |file|
  file.puts("[servers]")
  ip["value"].each do |name, (public, private)|
    next unless /redmine/.match?(name)
    file.puts("#{name} ansible_host=#{public} public_ip=#{public} private_ip=#{private}")
  end
  file.puts
  file.puts("[fluentd]")
  ip["value"].each do |name, (public, private)|
    next unless /fluentd/.match?(name)
    file.puts("#{name} ansible_host=#{public} public_ip=#{public} private_ip=#{private}")
  end
end

Add fluentd to hosts file
Add fluentd to hosts file
