final_output.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. file_hosts="hosts.yml"
  3. file_vars="variables.yml"
  4. hosts=$(grep -w "ansible_host:" $file_hosts | cut -d " " -f8)
  5. hostnames=$(grep -w "machine_hostname:" $file_hosts | cut -d " " -f8 | sed 's/"//' | sed 's/"//')
  6. domain=$(grep -w "domain:" $file_vars | cut -d " " -f2 | sed 's/"//' | sed 's/"//')
  7. zone=$(grep -w "zone:" $file_vars | cut -d " " -f2 | sed 's/"//' | sed 's/"//')
  8. publish=$(grep -w "publish:" $file_vars | cut -d " " -f2 | sed 's/"//' | sed 's/"//')
  9. hosts_lenght=$(echo -e "$hosts" | wc -l)
  10. hostnames_lenght=$(echo -e "$hostnames" | wc -l)
  11. x=$hosts_lenght
  12. echo "---"
  13. echo "The installation should be succesfull, you can now add these entries to your dns:"
  14. echo "---"
  15. while [ $x -gt 0 ];
  16. do
  17. host=""
  18. hostname=""
  19. host=$(echo -e "$hosts" | sed -n "$x"p)
  20. hostname=$(echo -e "$hostnames" | sed -n "$x"p)
  21. echo "$hostname 300 IN A $host"
  22. echo "$zone 300 IN NS $hostname.$domain."
  23. x=$(($x-1))
  24. done
  25. echo "---"
  26. echo "to publish something like www.$domain via your new geo-balancer, add this to your dns config:"
  27. echo "www 900 IN CNAME $publish.$zone.$domain."
  28. echo "---"