puppet 0.24.4 → 0.24.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +170 -0
- data/Rakefile +6 -4
- data/bin/filebucket +3 -2
- data/bin/puppet +7 -4
- data/bin/puppetca +32 -14
- data/bin/puppetd +12 -34
- data/bin/puppetmasterd +3 -2
- data/bin/puppetrun +5 -43
- data/bin/ralsh +2 -2
- data/conf/debian/README.source +2 -0
- data/conf/debian/TODO.Debian +1 -0
- data/conf/debian/changelog +257 -0
- data/conf/debian/compat +1 -0
- data/conf/debian/control +45 -0
- data/conf/debian/copyright +17 -0
- data/conf/debian/docs +1 -0
- data/conf/debian/fileserver.conf +12 -0
- data/conf/debian/puppet.NEWS +63 -0
- data/conf/debian/puppet.conf +8 -0
- data/conf/debian/puppet.dirs +7 -0
- data/conf/debian/puppet.files +6 -0
- data/conf/debian/puppet.init +64 -0
- data/conf/debian/puppet.logrotate +11 -0
- data/conf/debian/puppet.postinst +9 -0
- data/conf/debian/puppet.postrm +21 -0
- data/conf/debian/puppet.preinst +25 -0
- data/conf/debian/puppetmaster.files +4 -0
- data/conf/debian/puppetmaster.init +58 -0
- data/conf/debian/rules +115 -0
- data/conf/debian/watch +2 -0
- data/conf/gentoo/init.d/puppet +1 -1
- data/conf/gentoo/init.d/puppetmaster +32 -31
- data/conf/redhat/client.init +10 -2
- data/conf/redhat/puppet.spec +4 -1
- data/conf/redhat/server.init +9 -1
- data/examples/{code/allatonce → allatonce} +0 -0
- data/examples/{code/assignments → assignments} +0 -0
- data/examples/{code/components → components} +0 -0
- data/examples/{root/etc → etc}/init.d/sleeper +0 -0
- data/examples/{root/etc → etc}/otherfile +0 -0
- data/examples/{root/etc → etc}/puppet/fileserver.conf +0 -0
- data/examples/{root/etc → etc}/puppet/namespaceauth.conf +0 -0
- data/examples/{root/etc → etc}/puppet/puppet.conf +0 -0
- data/examples/{root/etc → etc}/puppet/tagmail.conf +0 -0
- data/examples/{code/execs → execs} +0 -0
- data/examples/{code/file.bl → file.bl} +0 -0
- data/examples/{code/filedefaults → filedefaults} +0 -0
- data/examples/{code/fileparsing → fileparsing} +0 -0
- data/examples/{code/filerecursion → filerecursion} +0 -0
- data/examples/{code/functions → functions} +0 -0
- data/examples/{code/groups → groups} +0 -0
- data/examples/{code/head → head} +0 -0
- data/examples/{code/importing → importing} +0 -0
- data/examples/{code/mac_automount.pp → mac_automount.pp} +0 -0
- data/examples/{code/mac_dscl.pp → mac_dscl.pp} +0 -0
- data/examples/{code/mac_dscl_revert.pp → mac_dscl_revert.pp} +0 -0
- data/examples/{code/mac_netinfo.pp → mac_netinfo.pp} +0 -0
- data/examples/{code/mac_pkgdmg.pp → mac_pkgdmg.pp} +0 -0
- data/examples/{code/modules → modules}/sample-module.pp +0 -0
- data/examples/{code/modules → modules}/sample-module/README.txt +0 -0
- data/examples/{code/modules → modules}/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +0 -0
- data/examples/{code/modules → modules}/sample-module/manifests/init.pp +0 -0
- data/examples/{code/modules → modules}/sample-module/templates/sample.erb +0 -0
- data/examples/{code/nodes → nodes} +0 -0
- data/examples/{code/one → one} +0 -0
- data/examples/{code/relationships → relationships} +0 -0
- data/examples/{code/selectors → selectors} +0 -0
- data/examples/{code/simpletests → simpletests} +0 -0
- data/examples/{code/svncommit → svncommit} +0 -0
- data/ext/autotest/Rakefile +8 -0
- data/ext/autotest/config +43 -0
- data/ext/autotest/readme.rst +16 -0
- data/{examples/root → ext}/bin/sleeper +1 -1
- data/ext/emacs/puppet-mode.el +246 -184
- data/ext/ldap/puppet.schema +7 -2
- data/ext/module_puppet +4 -3
- data/ext/nagios/check_puppet.rb +117 -0
- data/ext/puppetlast +40 -0
- data/install.rb +12 -3
- data/lib/puppet.rb +1 -44
- data/lib/puppet/defaults.rb +23 -10
- data/lib/puppet/dsl.rb +2 -2
- data/lib/puppet/executables/client/certhandler.rb +77 -0
- data/lib/puppet/external/nagios.rb +1 -1
- data/lib/puppet/external/nagios/base.rb +60 -46
- data/lib/puppet/file_serving/indirection_hooks.rb +4 -2
- data/lib/puppet/file_serving/metadata.rb +0 -9
- data/lib/puppet/file_serving/terminus_helper.rb +4 -4
- data/lib/puppet/indirector.rb +26 -28
- data/lib/puppet/indirector/catalog/compiler.rb +6 -28
- data/lib/puppet/indirector/checksum/file.rb +2 -2
- data/lib/puppet/indirector/direct_file_server.rb +7 -7
- data/lib/puppet/indirector/envelope.rb +13 -0
- data/lib/puppet/indirector/exec.rb +2 -2
- data/lib/puppet/indirector/facts/facter.rb +2 -2
- data/lib/puppet/indirector/file.rb +17 -14
- data/lib/puppet/indirector/file_metadata/file.rb +2 -2
- data/lib/puppet/indirector/file_server.rb +14 -14
- data/lib/puppet/indirector/indirection.rb +113 -48
- data/lib/puppet/indirector/ldap.rb +13 -25
- data/lib/puppet/indirector/memory.rb +7 -7
- data/lib/puppet/indirector/module_files.rb +14 -14
- data/lib/puppet/indirector/node/exec.rb +3 -10
- data/lib/puppet/indirector/node/ldap.rb +138 -41
- data/lib/puppet/indirector/node/plain.rb +1 -8
- data/lib/puppet/indirector/node/rest.rb +1 -1
- data/lib/puppet/indirector/plain.rb +2 -2
- data/lib/puppet/indirector/report/processor.rb +2 -2
- data/lib/puppet/indirector/request.rb +42 -0
- data/lib/puppet/indirector/rest.rb +51 -3
- data/lib/puppet/indirector/terminus.rb +0 -27
- data/lib/puppet/indirector/yaml.rb +12 -17
- data/lib/puppet/metatype/attributes.rb +3 -7
- data/lib/puppet/metatype/evaluation.rb +2 -2
- data/lib/puppet/module.rb +6 -2
- data/lib/puppet/network/client/master.rb +29 -81
- data/lib/puppet/network/handler/master.rb +12 -43
- data/lib/puppet/network/http.rb +8 -6
- data/lib/puppet/network/http/handler.rb +42 -32
- data/lib/puppet/network/http/mongrel.rb +8 -9
- data/lib/puppet/network/http/mongrel/rest.rb +42 -15
- data/lib/puppet/network/http/webrick.rb +27 -16
- data/lib/puppet/network/http/webrick/rest.rb +38 -14
- data/lib/puppet/network/http_pool.rb +3 -2
- data/lib/puppet/network/server.rb +24 -22
- data/lib/puppet/network/xmlrpc/client.rb +6 -1
- data/lib/puppet/node.rb +38 -79
- data/lib/puppet/node/catalog.rb +9 -0
- data/lib/puppet/node/facts.rb +9 -1
- data/lib/puppet/parser/ast/function.rb +1 -1
- data/lib/puppet/parser/collector.rb +6 -0
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/parser/functions.rb +25 -1
- data/lib/puppet/parser/interpreter.rb +2 -17
- data/lib/puppet/parser/parser.rb +4 -4
- data/lib/puppet/parser/parser_support.rb +6 -2
- data/lib/puppet/parser/resource.rb +6 -0
- data/lib/puppet/parser/templatewrapper.rb +9 -0
- data/lib/puppet/pgraph.rb +1 -1
- data/lib/puppet/property.rb +0 -1
- data/lib/puppet/provider.rb +9 -95
- data/lib/puppet/provider/confine.rb +77 -0
- data/lib/puppet/provider/confine/exists.rb +22 -0
- data/lib/puppet/provider/confine/false.rb +19 -0
- data/lib/puppet/provider/confine/feature.rb +17 -0
- data/lib/puppet/provider/confine/true.rb +20 -0
- data/lib/puppet/provider/confine/variable.rb +42 -0
- data/lib/puppet/provider/confine_collection.rb +47 -0
- data/lib/puppet/provider/confiner.rb +20 -0
- data/lib/puppet/provider/cron/crontab.rb +6 -2
- data/lib/puppet/provider/group/groupadd.rb +1 -1
- data/lib/puppet/provider/group/ldap.rb +48 -0
- data/lib/puppet/provider/ldap.rb +137 -0
- data/lib/puppet/provider/nameservice.rb +1 -2
- data/lib/puppet/provider/nameservice/objectadd.rb +2 -5
- data/lib/puppet/provider/package/dpkg.rb +16 -1
- data/lib/puppet/provider/package/freebsd.rb +15 -4
- data/lib/puppet/provider/package/gem.rb +33 -12
- data/lib/puppet/provider/package/pkgdmg.rb +1 -60
- data/lib/puppet/provider/package/ports.rb +6 -1
- data/lib/puppet/provider/package/rpm.rb +14 -13
- data/lib/puppet/provider/package/urpmi.rb +3 -3
- data/lib/puppet/provider/service/base.rb +4 -4
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +5 -3
- data/lib/puppet/provider/service/redhat.rb +35 -7
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +69 -0
- data/lib/puppet/provider/user/ldap.rb +133 -0
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +14 -14
- data/lib/puppet/rails/database/schema.rb +9 -0
- data/lib/puppet/rails/resource.rb +1 -0
- data/lib/puppet/reference/providers.rb +8 -2
- data/lib/puppet/reference/report.rb +23 -0
- data/lib/puppet/reports/rrdgraph.rb +4 -2
- data/lib/puppet/sslcertificates/ca.rb +9 -4
- data/lib/puppet/sslcertificates/support.rb +26 -2
- data/lib/puppet/transaction.rb +11 -16
- data/lib/puppet/transaction/change.rb +94 -0
- data/lib/puppet/transaction/event.rb +21 -0
- data/lib/puppet/transaction/report.rb +4 -0
- data/lib/puppet/type.rb +0 -2
- data/lib/puppet/type/file/ensure.rb +0 -5
- data/lib/puppet/type/file/group.rb +13 -7
- data/lib/puppet/type/file/source.rb +8 -15
- data/lib/puppet/type/file/target.rb +2 -0
- data/lib/puppet/type/group.rb +1 -1
- data/lib/puppet/type/mount.rb +4 -2
- data/lib/puppet/type/nagios_hostescalation.rb +3 -0
- data/lib/puppet/type/nagios_servicegroup.rb +3 -0
- data/lib/puppet/type/ssh_authorized_key.rb +56 -0
- data/lib/puppet/type/user.rb +3 -0
- data/lib/puppet/type/yumrepo.rb +0 -1
- data/lib/puppet/util.rb +1 -1
- data/lib/puppet/util/ldap.rb +5 -0
- data/lib/puppet/util/ldap/connection.rb +69 -0
- data/lib/puppet/util/ldap/generator.rb +45 -0
- data/lib/puppet/util/ldap/manager.rb +281 -0
- data/lib/puppet/util/posix.rb +2 -2
- data/lib/puppet/util/resource_template.rb +61 -0
- data/lib/puppet/util/settings.rb +63 -3
- data/lib/puppet/util/storage.rb +4 -0
- data/lib/puppet/util/warnings.rb +7 -0
- data/man/man8/filebucket.8 +116 -0
- data/man/man8/pi.8 +34 -0
- data/man/man8/puppet.8 +78 -0
- data/man/man8/puppet.conf.8 +1747 -0
- data/man/man8/puppetca.8 +118 -0
- data/man/man8/puppetd.8 +184 -0
- data/man/man8/puppetdoc.8 +62 -0
- data/man/man8/puppetmasterd.8 +87 -0
- data/man/man8/puppetrun.8 +151 -0
- data/man/man8/ralsh.8 +135 -0
- data/test/README +24 -0
- data/test/certmgr/support.rb +28 -1
- data/test/data/failers/badclassnoparam +10 -0
- data/test/data/failers/badclassparam +10 -0
- data/test/data/failers/badcompnoparam +9 -0
- data/test/data/failers/badcompparam +9 -0
- data/test/data/failers/badtypeparam +3 -0
- data/test/data/failers/noobjectrvalue +1 -0
- data/test/data/providers/cron/crontab.allthree +17 -0
- data/test/data/providers/cron/crontab.envNcomment +12 -0
- data/test/data/providers/cron/crontab.envNname +11 -0
- data/test/data/providers/cron/crontab.multirecords +12 -0
- data/test/data/providers/cron/crontab_collections.yaml +44 -0
- data/test/data/providers/cron/crontab_multiple_with_env.yaml +54 -0
- data/test/data/providers/cron/crontab_sample_records.yaml +272 -0
- data/test/data/providers/cron/examples/freebsd +2 -0
- data/test/data/providers/cron/examples/one +14 -0
- data/test/data/providers/cron/examples/openbsd +20 -0
- data/test/data/providers/package/testpackages.yaml +65 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +5 -0
- data/test/data/reports/1.yaml +108 -0
- data/test/data/reports/2.yaml +108 -0
- data/test/data/reports/tagmail_failers.conf +3 -0
- data/test/data/reports/tagmail_passers.conf +30 -0
- data/test/data/snippets/aliastest.pp +16 -0
- data/test/data/snippets/argumentdefaults +14 -0
- data/test/data/snippets/casestatement.pp +58 -0
- data/test/data/snippets/classheirarchy.pp +15 -0
- data/test/data/snippets/classincludes.pp +17 -0
- data/test/data/snippets/classpathtest +11 -0
- data/test/data/snippets/collection.pp +10 -0
- data/test/data/snippets/collection_within_virtual_definitions.pp +20 -0
- data/test/data/snippets/componentmetaparams.pp +11 -0
- data/test/data/snippets/componentrequire.pp +8 -0
- data/test/data/snippets/deepclassheirarchy.pp +23 -0
- data/test/data/snippets/defineoverrides.pp +17 -0
- data/test/data/snippets/emptyclass.pp +9 -0
- data/test/data/snippets/emptyexec.pp +3 -0
- data/test/data/snippets/falsevalues.pp +3 -0
- data/test/data/snippets/filecreate +11 -0
- data/test/data/snippets/fqdefinition.pp +5 -0
- data/test/data/snippets/fqparents.pp +11 -0
- data/test/data/snippets/implicititeration +15 -0
- data/test/data/snippets/multipleinstances +7 -0
- data/test/data/snippets/multisubs.pp +13 -0
- data/test/data/snippets/namevartest +9 -0
- data/test/data/snippets/scopetest +13 -0
- data/test/data/snippets/selectorvalues.pp +42 -0
- data/test/data/snippets/simpledefaults +5 -0
- data/test/data/snippets/simpleselector +38 -0
- data/test/data/snippets/singleary.pp +19 -0
- data/test/data/snippets/singlequote.pp +11 -0
- data/test/data/snippets/singleselector.pp +22 -0
- data/test/data/snippets/subclass_name_duplication.pp +11 -0
- data/test/data/snippets/tag.pp +9 -0
- data/test/data/snippets/tagged.pp +35 -0
- data/test/data/snippets/virtualresources.pp +14 -0
- data/test/data/types/hosts/1 +3 -0
- data/test/data/types/hosts/2 +13 -0
- data/test/data/types/hosts/solaris +5 -0
- data/test/data/types/mailalias/file1 +183 -0
- data/test/data/types/mount/freebsd.fstab +7 -0
- data/test/data/types/mount/linux.fstab +11 -0
- data/test/data/types/mount/solaris.fstab +11 -0
- data/test/data/types/port/1 +533 -0
- data/test/data/types/port/darwin +11866 -0
- data/test/data/types/ssh_authorized_key/1 +2 -0
- data/test/data/types/sshkey/1 +21 -0
- data/test/data/types/yumrepos/fedora-devel.repo +26 -0
- data/test/data/types/yumrepos/fedora.repo +9 -0
- data/test/language/parser.rb +8 -1
- data/test/lib/puppettest/runnable_test.rb +3 -0
- data/test/lib/puppettest/support/utils.rb +1 -1
- data/test/lib/rake/puppet_testtask.rb +3 -0
- data/test/lib/stubba.rb +1 -1
- data/test/network/client/ca.rb +1 -0
- data/test/network/client/master.rb +13 -127
- data/test/network/handler/master.rb +61 -80
- data/test/other/provider.rb +0 -45
- data/test/other/transactions.rb +53 -15
- data/test/rails/host.rb +0 -37
- data/test/ral/providers/cron/crontab.rb +32 -3
- data/test/ral/providers/provider.rb +28 -7
- data/test/ral/type/filesources.rb +2 -18
- data/test/ral/type/sshkey.rb +0 -1
- data/test/ral/type/user.rb +6 -0
- data/test/test +241 -0
- metadata +289 -113
- data/examples/root/etc/configfile +0 -0
- data/examples/root/etc/debian-passwd +0 -29
- data/examples/root/etc/debian-syslog.conf +0 -71
- data/lib/puppet/event.rb +0 -28
- data/lib/puppet/network/handler/configuration.rb +0 -184
- data/lib/puppet/network/http/mongrel/xmlrpc.rb +0 -4
- data/lib/puppet/network/http/webrick/xmlrpc.rb +0 -4
- data/lib/puppet/propertychange.rb +0 -141
- data/lib/puppet/provider/interface/redhat.rb +0 -250
- data/lib/puppet/provider/interface/sunos.rb +0 -133
- data/lib/puppet/type/interface.rb +0 -60
- data/lib/puppet/util/variables.rb +0 -38
- data/test/network/handler/configuration.rb +0 -160
- data/test/other/propertychange.rb +0 -140
- data/test/util/loadedfile.rb +0 -121
@@ -1,250 +0,0 @@
|
|
1
|
-
require 'puppet/provider/parsedfile'
|
2
|
-
require 'erb'
|
3
|
-
|
4
|
-
Puppet::Type.type(:interface).provide(:redhat) do
|
5
|
-
desc "Manage network interfaces on Red Hat operating systems. This provider
|
6
|
-
parses and generates configuration files in ``/etc/sysconfig/network-scripts``."
|
7
|
-
|
8
|
-
INTERFACE_DIR = "/etc/sysconfig/network-scripts"
|
9
|
-
confine :exists => INTERFACE_DIR
|
10
|
-
defaultfor :operatingsystem => [:fedora, :centos, :redhat]
|
11
|
-
|
12
|
-
# Create the setter/gettor methods to match the model.
|
13
|
-
mk_resource_methods
|
14
|
-
|
15
|
-
@templates = {}
|
16
|
-
|
17
|
-
# Register a template.
|
18
|
-
def self.register_template(name, string)
|
19
|
-
@templates[name] = ERB.new(string)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Retrieve a template by name.
|
23
|
-
def self.template(name)
|
24
|
-
@templates[name]
|
25
|
-
end
|
26
|
-
|
27
|
-
register_template :alias, <<-ALIAS
|
28
|
-
DEVICE=<%= self.device %>
|
29
|
-
ONBOOT=<%= self.on_boot %>
|
30
|
-
BOOTPROTO=none
|
31
|
-
IPADDR=<%= self.name %>
|
32
|
-
NETMASK=<%= self.netmask %>
|
33
|
-
BROADCAST=
|
34
|
-
ALIAS
|
35
|
-
|
36
|
-
|
37
|
-
register_template :normal, <<-LOOPBACKDUMMY
|
38
|
-
DEVICE=<%= self.device %>
|
39
|
-
ONBOOT=<%= self.on_boot %>
|
40
|
-
BOOTPROTO=static
|
41
|
-
IPADDR=<%= self.name %>
|
42
|
-
NETMASK=<%= self.netmask %>
|
43
|
-
BROADCAST=
|
44
|
-
LOOPBACKDUMMY
|
45
|
-
|
46
|
-
# maximum number of dummy interfaces
|
47
|
-
@max_dummies = 10
|
48
|
-
|
49
|
-
# maximum number of aliases per interface
|
50
|
-
@max_aliases_per_iface = 10
|
51
|
-
|
52
|
-
@@dummies = []
|
53
|
-
@@aliases = Hash.new { |hash, key| hash[key] = [] }
|
54
|
-
|
55
|
-
# calculate which dummy interfaces are currently already in
|
56
|
-
# use prior to needing to call self.next_dummy later on.
|
57
|
-
def self.instances
|
58
|
-
# parse all of the config files at once
|
59
|
-
Dir.glob("%s/ifcfg-*" % INTERFACE_DIR).collect do |file|
|
60
|
-
record = parse(file)
|
61
|
-
|
62
|
-
# store the existing dummy interfaces
|
63
|
-
@@dummies << record[:ifnum] if (record[:interface_type] == :dummy and ! @@dummies.include?(record[:ifnum]))
|
64
|
-
|
65
|
-
@@aliases[record[:interface]] << record[:ifnum] if record[:interface_type] == :alias
|
66
|
-
|
67
|
-
new(record)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# return the next avaliable dummy interface number, in the case where
|
72
|
-
# ifnum is not manually specified
|
73
|
-
def self.next_dummy
|
74
|
-
@max_dummies.times do |i|
|
75
|
-
unless @@dummies.include?(i.to_s)
|
76
|
-
@@dummies << i.to_s
|
77
|
-
return i.to_s
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# return the next available alias on a given interface, in the case
|
83
|
-
# where ifnum if not manually specified
|
84
|
-
def self.next_alias(interface)
|
85
|
-
@max_aliases_per_iface.times do |i|
|
86
|
-
unless @@aliases[interface].include?(i.to_s)
|
87
|
-
@@aliases[interface] << i.to_s
|
88
|
-
return i.to_s
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
# base the ifnum, for dummy / loopback interface in linux
|
94
|
-
# on the last octect of the IP address
|
95
|
-
|
96
|
-
# Parse the existing file.
|
97
|
-
def self.parse(file)
|
98
|
-
instance = new()
|
99
|
-
return instance unless FileTest.exist?(file)
|
100
|
-
|
101
|
-
File.readlines(file).each do |line|
|
102
|
-
if line =~ /^(\w+)=(.+)$/
|
103
|
-
instance.send($1.downcase + "=", $2)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
return instance
|
108
|
-
end
|
109
|
-
|
110
|
-
# Prefetch our interface list, yo.
|
111
|
-
def self.prefetch(resources)
|
112
|
-
instances.each do |prov|
|
113
|
-
if resource = resources[prov.name]
|
114
|
-
resource.provider = prov
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def create
|
120
|
-
self.class.resource_type.validproperties.each do |property|
|
121
|
-
if value = @resource.should(property)
|
122
|
-
@property_hash[property] = value
|
123
|
-
end
|
124
|
-
end
|
125
|
-
@property_hash[:name] = @resource.name
|
126
|
-
|
127
|
-
return (@resource.class.name.to_s + "_created").intern
|
128
|
-
end
|
129
|
-
|
130
|
-
def destroy
|
131
|
-
File.unlink(file_path)
|
132
|
-
end
|
133
|
-
|
134
|
-
def exists?
|
135
|
-
FileTest.exist?(file_path)
|
136
|
-
end
|
137
|
-
|
138
|
-
# generate the content for the interface file, so this is dependent
|
139
|
-
# on whether we are adding an alias to a real interface, or a loopback
|
140
|
-
# address (also dummy) on linux. For linux it's quite involved, and we
|
141
|
-
# will use an ERB template
|
142
|
-
def generate
|
143
|
-
itype = self.interface_type == :alias ? :alias : :normal
|
144
|
-
self.class.template(itype).result(binding)
|
145
|
-
end
|
146
|
-
|
147
|
-
# Where should the file be written out?
|
148
|
-
# This defaults to INTERFACE_DIR/ifcfg-<namevar>, but can have a
|
149
|
-
# more symbolic name by setting interface_desc in the type.
|
150
|
-
def file_path
|
151
|
-
if resource and val = resource[:interface_desc]
|
152
|
-
desc = val
|
153
|
-
else
|
154
|
-
desc = self.name
|
155
|
-
end
|
156
|
-
|
157
|
-
self.fail("Could not get name for interface") unless desc
|
158
|
-
|
159
|
-
if self.interface_type == :alias
|
160
|
-
return File.join(INTERFACE_DIR, "ifcfg-" + self.interface + ":" + desc)
|
161
|
-
else
|
162
|
-
return File.join(INTERFACE_DIR, "ifcfg-" + desc)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
# Use the device value to figure out all kinds of nifty things.
|
167
|
-
def device=(value)
|
168
|
-
case value
|
169
|
-
when /:/:
|
170
|
-
@property_hash[:interface], @property_hash[:ifnum] = value.split(":")
|
171
|
-
@property_hash[:interface_type] = :alias
|
172
|
-
when /^dummy/:
|
173
|
-
@property_hash[:interface_type] = :loopback
|
174
|
-
@property_hash[:interface] = "dummy"
|
175
|
-
|
176
|
-
# take the number of the dummy interface, as this is used
|
177
|
-
# when working out whether to call next_dummy when dynamically
|
178
|
-
# creating these
|
179
|
-
@property_hash[:ifnum] = value.sub("dummy",'')
|
180
|
-
|
181
|
-
@@dummies << @property_hash[:ifnum].to_s unless @@dummies.include?(@property_hash[:ifnum].to_s)
|
182
|
-
else
|
183
|
-
@property_hash[:interface_type] = :normal
|
184
|
-
@property_hash[:interface] = value
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
# create the device name, so this based on the IP, and interface + type
|
189
|
-
def device
|
190
|
-
case @resource.should(:interface_type)
|
191
|
-
when :loopback
|
192
|
-
@property_hash[:ifnum] ||= self.class.next_dummy
|
193
|
-
return "dummy" + @property_hash[:ifnum]
|
194
|
-
when :alias
|
195
|
-
@property_hash[:ifnum] ||= self.class.next_alias(@resource[:interface])
|
196
|
-
return @resource[:interface] + ":" + @property_hash[:ifnum]
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
# Set the name to our ip address.
|
201
|
-
def ipaddr=(value)
|
202
|
-
@property_hash[:name] = value
|
203
|
-
end
|
204
|
-
|
205
|
-
# whether the device is to be brought up on boot or not. converts
|
206
|
-
# the true / false of the type, into yes / no values respectively
|
207
|
-
# writing out the ifcfg-* files
|
208
|
-
def on_boot
|
209
|
-
case @property_hash[:onboot].to_s
|
210
|
-
when "true"
|
211
|
-
return "yes"
|
212
|
-
when "false"
|
213
|
-
return "no"
|
214
|
-
else
|
215
|
-
return "neither"
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
# Mark whether the interface should be started on boot.
|
220
|
-
def on_boot=(value)
|
221
|
-
# translate whether we come up on boot to true/false
|
222
|
-
case value.downcase
|
223
|
-
when "yes":
|
224
|
-
@property_hash[:onboot] = :true
|
225
|
-
else
|
226
|
-
@property_hash[:onboot] = :false
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
# Write the new file out.
|
231
|
-
def flush
|
232
|
-
# Don't flush to disk if we're removing the config.
|
233
|
-
return if self.ensure == :absent
|
234
|
-
|
235
|
-
@property_hash.each do |name, val|
|
236
|
-
if val == :absent
|
237
|
-
raise ArgumentError, "Propety %s must be provided" % val
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
File.open(file_path, "w") do |f|
|
242
|
-
f.puts generate()
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
def prefetch
|
247
|
-
@property_hash = self.class.parse(file_path)
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
@@ -1,133 +0,0 @@
|
|
1
|
-
require 'puppet/provider/parsedfile'
|
2
|
-
require 'erb'
|
3
|
-
|
4
|
-
Puppet::Type.type(:interface).provide(:sunos) do
|
5
|
-
confine :kernel => "SunOS"
|
6
|
-
|
7
|
-
# Add accessor/getter methods for each property/parameter; these methods
|
8
|
-
# modify @property_hash.
|
9
|
-
mk_resource_methods
|
10
|
-
|
11
|
-
# Get a list of interface instances.
|
12
|
-
def self.instances
|
13
|
-
Dir.glob("/etc/hostname.*").collect do |file|
|
14
|
-
device = File.basename(file).split(".").pop
|
15
|
-
|
16
|
-
instance = new(:interface => device)
|
17
|
-
instance.parse
|
18
|
-
instance
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.match(hash)
|
23
|
-
# see if we can match the has against an existing object
|
24
|
-
if model.find { |obj| obj.value(:name) == hash[:name] }
|
25
|
-
return obj
|
26
|
-
else
|
27
|
-
return false
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Prefetch our interface list, yo.
|
32
|
-
def self.prefetch(resources)
|
33
|
-
instances.each do |prov|
|
34
|
-
if resource = resources[prov.name]
|
35
|
-
resource.provider = prov
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def initialize(*args)
|
41
|
-
@property_hash = {}
|
42
|
-
super
|
43
|
-
end
|
44
|
-
|
45
|
-
def create
|
46
|
-
self.class.resource_type.validproperties.each do |property|
|
47
|
-
if value = resource.should(property)
|
48
|
-
@property_hash[property] = value
|
49
|
-
end
|
50
|
-
end
|
51
|
-
@property_hash[:name] = resource.name
|
52
|
-
|
53
|
-
return (@resource.class.name.to_s + "_created").intern
|
54
|
-
end
|
55
|
-
|
56
|
-
def destroy
|
57
|
-
File.unlink(file_path)
|
58
|
-
@property_hash[:ensure] = :absent
|
59
|
-
end
|
60
|
-
|
61
|
-
def exists?
|
62
|
-
FileTest.exist?(file_path)
|
63
|
-
end
|
64
|
-
|
65
|
-
# Where should the file be written out? Can be overridden by setting
|
66
|
-
# :target in the model.
|
67
|
-
def file_path
|
68
|
-
self.fail("Could not determine interface") unless interface = @property_hash[:interface] || (resource and resource[:interface])
|
69
|
-
return File.join("/etc", "hostname." + interface)
|
70
|
-
end
|
71
|
-
|
72
|
-
def flush
|
73
|
-
return if self.ensure == :absent
|
74
|
-
File.open(file_path, "w") { |f| f.print generate() + "\n" }
|
75
|
-
end
|
76
|
-
|
77
|
-
# Turn our record into a line.
|
78
|
-
def generate
|
79
|
-
ret = []
|
80
|
-
if self.interface_type == :alias
|
81
|
-
ret << "addif"
|
82
|
-
end
|
83
|
-
ret << self.name
|
84
|
-
|
85
|
-
if self.ifopts != :absent
|
86
|
-
if @property_hash[:ifopts].is_a?(Array)
|
87
|
-
ret << @property_hash[:ifopts].join(" ")
|
88
|
-
else
|
89
|
-
ret << @property_hash[:ifopts]
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
if self.onboot and ! [:absent, :false].include?(self.onboot)
|
94
|
-
ret << "up"
|
95
|
-
end
|
96
|
-
|
97
|
-
return ret.join(" ")
|
98
|
-
end
|
99
|
-
|
100
|
-
# Parse our interface file.
|
101
|
-
def parse
|
102
|
-
(@property_hash = {:ensure => :absent} and return) unless FileTest.exist?(file_path)
|
103
|
-
|
104
|
-
values = File.read(file_path).chomp.split(/\s+/)
|
105
|
-
|
106
|
-
@property_hash[:ensure] = :present
|
107
|
-
#@property_hash = {:ensure => :present}
|
108
|
-
|
109
|
-
# Are we the primary interface?
|
110
|
-
if values[0] == "addif"
|
111
|
-
@property_hash[:interface_type] = :alias
|
112
|
-
values.shift
|
113
|
-
else
|
114
|
-
@property_hash[:interface_type] = :normal
|
115
|
-
end
|
116
|
-
|
117
|
-
# Should the interface be up by default?
|
118
|
-
if values[-1] == "up"
|
119
|
-
@property_hash[:onboot] = :true
|
120
|
-
values.pop
|
121
|
-
else
|
122
|
-
@property_hash[:onboot] = :false
|
123
|
-
end
|
124
|
-
|
125
|
-
# Set the interface name.
|
126
|
-
@property_hash[:name] = values.shift
|
127
|
-
|
128
|
-
# Handle any interface options
|
129
|
-
unless values.empty?
|
130
|
-
@property_hash[:ifopts] = values.join(" ")
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
Puppet::Type.newtype(:interface) do
|
2
|
-
require 'erb'
|
3
|
-
|
4
|
-
@doc = "Create configuration for IP address aliases and loopback addresses."
|
5
|
-
|
6
|
-
newparam(:name, :namevar => true) do
|
7
|
-
desc "The ipaddress to add to alias or loopback/dummy interface"
|
8
|
-
end
|
9
|
-
|
10
|
-
ensurable
|
11
|
-
|
12
|
-
newparam(:interface) do
|
13
|
-
desc "The interface the IP should be added to"
|
14
|
-
end
|
15
|
-
|
16
|
-
newproperty(:interface_type) do
|
17
|
-
desc "The interface type, loopback (also dummy) or alias"
|
18
|
-
|
19
|
-
newvalue(:loopback)
|
20
|
-
newvalue(:alias)
|
21
|
-
newvalue(:normal)
|
22
|
-
|
23
|
-
# Make dummy and loopback equivalent
|
24
|
-
aliasvalue(:dummy, :loopback)
|
25
|
-
|
26
|
-
defaultto :normal
|
27
|
-
end
|
28
|
-
|
29
|
-
newparam(:interface_desc) do
|
30
|
-
desc "On Linux, the description / symbolic name you wish to refer to the
|
31
|
-
interface by. When absent, Redhat Linux defaults to uses the namevar
|
32
|
-
which will be either the IP address, or hostname."
|
33
|
-
end
|
34
|
-
|
35
|
-
newproperty(:onboot) do
|
36
|
-
desc "Whether the interface should be configured to come up on boot"
|
37
|
-
newvalue(:true)
|
38
|
-
newvalue(:false)
|
39
|
-
end
|
40
|
-
|
41
|
-
newproperty(:ifnum) do
|
42
|
-
desc "If not automatically configuring the dummy interface or
|
43
|
-
and alias. This is use to force a given number to be used"
|
44
|
-
end
|
45
|
-
|
46
|
-
newproperty(:netmask) do
|
47
|
-
desc "The netmask for the interface."
|
48
|
-
end
|
49
|
-
|
50
|
-
newproperty(:ifopts) do
|
51
|
-
desc "Interface options."
|
52
|
-
end
|
53
|
-
|
54
|
-
newparam(:target) do
|
55
|
-
include Puppet::Util::Warnings
|
56
|
-
desc "The path to the file this resource creates."
|
57
|
-
|
58
|
-
munge { |value| warnonce "Interface targets are deprecated and no longer have any function" }
|
59
|
-
end
|
60
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Puppet::Util::Variables
|
2
|
-
def inithooks
|
3
|
-
@instance_init_hooks.dup
|
4
|
-
end
|
5
|
-
|
6
|
-
def initvars
|
7
|
-
return unless defined? @class_init_hooks
|
8
|
-
self.inithooks.each do |var, value|
|
9
|
-
if value.is_a?(Class)
|
10
|
-
instance_variable_set("@" + var.to_s, value.new)
|
11
|
-
else
|
12
|
-
instance_variable_set("@" + var.to_s, value)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def instancevar(hash)
|
18
|
-
@instance_init_hooks ||= {}
|
19
|
-
|
20
|
-
unless method_defined?(:initvars)
|
21
|
-
define_method(:initvars) do
|
22
|
-
self.class.inithooks.each do |var, value|
|
23
|
-
if value.is_a?(Class)
|
24
|
-
instance_variable_set("@" + var.to_s, value.new)
|
25
|
-
else
|
26
|
-
instance_variable_set("@" + var.to_s, value)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
hash.each do |var, value|
|
32
|
-
raise("Already initializing %s" % var) if @instance_init_hooks[var]
|
33
|
-
|
34
|
-
@instance_init_hooks[var] = value
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|