Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Configuring some virtual IPs.

In order it should:

Should configure arp_ignore and arp_announce on all interfaces.
Should define 3 new network scripts /etc/sysconfig/network-scripts/ifcfg-lo:[0-2].
Should bring up 3 new virtual interfaces.

vip.pp
------
class vip_sysctl {
        exec { "reload-sysctl":
                command => "/sbin/sysctl -p /etc/sysctl.conf",
                refreshonly => true
        }

        Sysctl { notify => Exec["reload-sysctl"] }

        sysctl { "net.ipv4.conf.all.arp_ignore": value => 1 }
        sysctl { "net.ipv4.conf.eth0.arp_ignore": value => 1 }
        sysctl { "net.ipv4.conf.eth1.arp_ignore": value => 1 }
        sysctl { "net.ipv4.conf.all.arp_announce": value => 2 }
        sysctl { "net.ipv4.conf.eth0.arp_announce": value => 2 }
        sysctl { "net.ipv4.conf.eth1.arp_announce": value => 2 }
}

class vip {
        require vip_sysctl

        exec { "reload-sysctl":
                command => "/sbin/sysctl -p /etc/sysctl.conf",
                refreshonly => true
        }

        Sysctl { notify => Exec["reload-sysctl"] }

        sysctl { "net.ipv4.conf.all.arp_ignore": value => 1 }
        sysctl { "net.ipv4.conf.eth0.arp_ignore": value => 1 }
        sysctl { "net.ipv4.conf.eth1.arp_ignore": value => 1 }
        sysctl { "net.ipv4.conf.all.arp_announce": value => 2 }
        sysctl { "net.ipv4.conf.eth0.arp_announce": value => 2 }
        sysctl { "net.ipv4.conf.eth1.arp_announce": value => 2 }

        define loopback($ip => $title, $ifnum) {
                file {"/etc/sysconfig/network-scripts/ifcfg-lo:$ifnum":
                        ensure => file,
                        mode => 644,
                        content => template("ifcfg-vip.erb"),
                        notify => Exec["bring-up-lo"]
                }

                exec {"bring-up-lo":
                        command => "/sbin/ifconfig lo:$ifnum $ip netmask 255.255.255.255 up",
                        refreshonly => true
                }
        }

        loopback { "192.168.246.50": ifnum => 0 }
        loopback { "192.168.246.51": ifnum => 1 }
        loopback { "192.168.246.52": ifnum => 2 }
}


ifcfg-vip.erb
-------------
DEVICE=lo:<%= ifnum %>
BOOTPROTO=static
IPADDR=<%= ip %>
NETMASK=255.255.255.255
ONBOOT=yes