Advertisement
Guest User

lkco

a guest
Mar 15th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. # cat /var/rudder/share/1da1332a-4e35-4ce7-9e59-3912b7ddac61/rules/cfengine-community/hostsConfiguration/1.0/hostsConfiguration.cf
  2. #####################################################################################
  3. # Copyright 2011 Normation SAS
  4. #####################################################################################
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, Version 3.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. #####################################################################################
  19.  
  20. # (C) Normation 2011
  21. #
  22. # NOTE : I permitted the creation of the hosts file if absent, but on a purely
  23. # functionnal side, its absence means a severe breakage of your IP stack. Be
  24. # aware of this if a file creation is reported !
  25. #
  26.  
  27. bundle agent check_hosts_configuration {
  28.  
  29. vars:
  30.  
  31. "hosts_host[1]" string => "cslwmng01";
  32. "hosts_host[2]" string => "cslwsyl01";
  33. "hosts_host[3]" string => "cslwmda02";
  34. "hosts_host[4]" string => "cslwmda03";
  35. "hosts_host[5]" string => "cslwmda04";
  36. "hosts_host[6]" string => "cslumda05";
  37. "hosts_host[7]" string => "cslwmda06";
  38. "hosts_host[8]" string => "cslwmda07";
  39. "hosts_host[9]" string => "csluddp01";
  40. "hosts_host[10]" string => "chawpa01";
  41. "hosts_host[11]" string => "rudder";
  42.  
  43.  
  44. "hosts_ip[1]" string => "10.69.0.101";
  45. "hosts_ip[2]" string => "10.69.0.102";
  46. "hosts_ip[3]" string => "10.69.0.160";
  47. "hosts_ip[4]" string => "10.69.1.161";
  48. "hosts_ip[5]" string => "10.69.1.162";
  49. "hosts_ip[6]" string => "10.69.1.163";
  50. "hosts_ip[7]" string => "10.69.0.104";
  51. "hosts_ip[8]" string => "10.69.0.107";
  52. "hosts_ip[9]" string => "10.69.0.22";
  53. "hosts_ip[10]" string => "10.69.1.57";
  54. "hosts_ip[11]" string => "172.16.85.168";
  55.  
  56.  
  57. files:
  58.  
  59. linux::
  60.  
  61. "/etc/hosts"
  62.  
  63. create => "true",
  64. perms => m("644"),
  65. edit_defaults => empty_backup,
  66. edit_line => set_hosts_values("check_hosts_configuration.hosts_host", "check_hosts_configuration.hosts_ip"),
  67. classes => kept_if_else("hosts_edition_kept", "hosts_edition_done", "hosts_edition_failed");
  68.  
  69. windows::
  70.  
  71. "$(sys.winsysdir)\drivers\etc\hosts"
  72.  
  73. create => "true",
  74. # perms => m("644"),
  75. edit_defaults => empty_backup,
  76. edit_line => set_hosts_values("check_hosts_configuration.hosts_host", "check_hosts_configuration.hosts_ip"),
  77. classes => kept_if_else("hosts_edition_kept", "hosts_edition_done", "hosts_edition_failed");
  78.  
  79.  
  80. reports:
  81.  
  82. (linux|windows)::
  83. "@@hostsConfiguration@@log_debug@@9d5f61ce-9dab-4a74-b31d-8ea31d0230f3@@e49d357e-1462-4d8b-8adb-98841c2963d7@@6@@hostsConfiguration@@None@@$(g.execRun)##$(g.uuid)@#Hosts file content enforcement requested";
  84. hosts_edition_done::
  85. "@@hostsConfiguration@@result_repaired@@9d5f61ce-9dab-4a74-b31d-8ea31d0230f3@@e49d357e-1462-4d8b-8adb-98841c2963d7@@6@@hostsConfiguration@@None@@$(g.execRun)##$(g.uuid)@#Hosts file was updated";
  86.  
  87. hosts_edition_kept.!hosts_edition_done::
  88. "@@hostsConfiguration@@result_success@@9d5f61ce-9dab-4a74-b31d-8ea31d0230f3@@e49d357e-1462-4d8b-8adb-98841c2963d7@@6@@hostsConfiguration@@None@@$(g.execRun)##$(g.uuid)@#Hosts file already OK";
  89.  
  90. hosts_edition_failed::
  91. "@@hostsConfiguration@@result_error@@9d5f61ce-9dab-4a74-b31d-8ea31d0230f3@@e49d357e-1462-4d8b-8adb-98841c2963d7@@6@@hostsConfiguration@@None@@$(g.execRun)##$(g.uuid)@#Hosts file could not be edited";
  92.  
  93.  
  94. }
  95.  
  96. bundle edit_line set_hosts_values(hosts, ips) {
  97.  
  98. vars:
  99.  
  100. "hosts_index" slist => getindices("$(hosts)");
  101.  
  102. insert_lines:
  103.  
  104. "127.0.0.1 localhost";
  105. "127.0.1.1 $(sys.host)";
  106. "##";
  107. "# The following lines are desirable for IPv6 capable hosts";
  108. "::1 localhost ip6-localhost ip6-loopback";
  109. "fe00::0 ip6-localnet";
  110. "ff00::0 ip6-mcastprefix";
  111. "ff02::1 ip6-allnodes";
  112. "ff02::2 ip6-allrouters";
  113. "ff02::3 ip6-allhosts";
  114. "###";
  115. "## Here follows all the rudder defined hosts :";
  116. "$($(ips)[$(hosts_index)]) $($(hosts)[$(hosts_index)])";
  117.  
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement