Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # cat /var/rudder/share/1da1332a-4e35-4ce7-9e59-3912b7ddac61/rules/cfengine-community/hostsConfiguration/1.0/hostsConfiguration.cf
- #####################################################################################
- # Copyright 2011 Normation SAS
- #####################################################################################
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, Version 3.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- #####################################################################################
- # (C) Normation 2011
- #
- # NOTE : I permitted the creation of the hosts file if absent, but on a purely
- # functionnal side, its absence means a severe breakage of your IP stack. Be
- # aware of this if a file creation is reported !
- #
- bundle agent check_hosts_configuration {
- vars:
- "hosts_host[1]" string => "cslwmng01";
- "hosts_host[2]" string => "cslwsyl01";
- "hosts_host[3]" string => "cslwmda02";
- "hosts_host[4]" string => "cslwmda03";
- "hosts_host[5]" string => "cslwmda04";
- "hosts_host[6]" string => "cslumda05";
- "hosts_host[7]" string => "cslwmda06";
- "hosts_host[8]" string => "cslwmda07";
- "hosts_host[9]" string => "csluddp01";
- "hosts_host[10]" string => "chawpa01";
- "hosts_host[11]" string => "rudder";
- "hosts_ip[1]" string => "10.69.0.101";
- "hosts_ip[2]" string => "10.69.0.102";
- "hosts_ip[3]" string => "10.69.0.160";
- "hosts_ip[4]" string => "10.69.1.161";
- "hosts_ip[5]" string => "10.69.1.162";
- "hosts_ip[6]" string => "10.69.1.163";
- "hosts_ip[7]" string => "10.69.0.104";
- "hosts_ip[8]" string => "10.69.0.107";
- "hosts_ip[9]" string => "10.69.0.22";
- "hosts_ip[10]" string => "10.69.1.57";
- "hosts_ip[11]" string => "172.16.85.168";
- files:
- linux::
- "/etc/hosts"
- create => "true",
- perms => m("644"),
- edit_defaults => empty_backup,
- edit_line => set_hosts_values("check_hosts_configuration.hosts_host", "check_hosts_configuration.hosts_ip"),
- classes => kept_if_else("hosts_edition_kept", "hosts_edition_done", "hosts_edition_failed");
- windows::
- "$(sys.winsysdir)\drivers\etc\hosts"
- create => "true",
- # perms => m("644"),
- edit_defaults => empty_backup,
- edit_line => set_hosts_values("check_hosts_configuration.hosts_host", "check_hosts_configuration.hosts_ip"),
- classes => kept_if_else("hosts_edition_kept", "hosts_edition_done", "hosts_edition_failed");
- reports:
- (linux|windows)::
- "@@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";
- hosts_edition_done::
- "@@hostsConfiguration@@result_repaired@@9d5f61ce-9dab-4a74-b31d-8ea31d0230f3@@e49d357e-1462-4d8b-8adb-98841c2963d7@@6@@hostsConfiguration@@None@@$(g.execRun)##$(g.uuid)@#Hosts file was updated";
- hosts_edition_kept.!hosts_edition_done::
- "@@hostsConfiguration@@result_success@@9d5f61ce-9dab-4a74-b31d-8ea31d0230f3@@e49d357e-1462-4d8b-8adb-98841c2963d7@@6@@hostsConfiguration@@None@@$(g.execRun)##$(g.uuid)@#Hosts file already OK";
- hosts_edition_failed::
- "@@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";
- }
- bundle edit_line set_hosts_values(hosts, ips) {
- vars:
- "hosts_index" slist => getindices("$(hosts)");
- insert_lines:
- "127.0.0.1 localhost";
- "127.0.1.1 $(sys.host)";
- "##";
- "# The following lines are desirable for IPv6 capable hosts";
- "::1 localhost ip6-localhost ip6-loopback";
- "fe00::0 ip6-localnet";
- "ff00::0 ip6-mcastprefix";
- "ff02::1 ip6-allnodes";
- "ff02::2 ip6-allrouters";
- "ff02::3 ip6-allhosts";
- "###";
- "## Here follows all the rudder defined hosts :";
- "$($(ips)[$(hosts_index)]) $($(hosts)[$(hosts_index)])";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement