Below I have a parser function that I have created which was working,
but now is not working. I have made quite a few changes to this code,
but can't seem to find the right combination to make it work again.
After extensive conversations with Volcane, joe-mac and andrewcshafer
from #puppet, it was suggested that I put this on the list. I don't
know what exactly is going on, but I can say that I think this is a
bug now. However, I can't prove it beyond what I have here without
help.
I'd like to put this out to the puppeteers here and see if I can get
some more help identifying why I get the error at the end of the
information below.
Thanks in advance for all the help.
Cheers,
Clint
-------------------------
## modules/core/plugins/puppet/parser/functions/get_ad_uids.rb
require 'ldap'
# this function queries our Active Directory server and pulls users
with a uid greater than 50000.
# Specifically used for guaranteeing homedirs exist for users in the list
module Puppet::Parser::Functions
newfunction(:get_ad_uids, :type => :rvalue) do |args|
host = 'ad.xyz123.net'
port = LDAP::LDAP_PORT
# cn=ldap,ou=System Accounts,ou=Resources,dc=ad,dc=xyz123,dc=net
root = 'cn=ldap,ou=System Accounts,ou=Resources,dc=ad,dc=xyz123,dc=net'
base = 'ou=Engineering,ou=xyz123,dc=ad,dc=xyz123,dc=net'
password = 'password'
conn = LDAP::Conn.new(host, port)
conn.set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, 3 )
conn.bind(root, password)
uidnum = args[0]
ad_uids = Array.new
ids = conn.search2(base, LDAP::LDAP_SCOPE_SUBTREE,
"(uidNumber>=#{uidnum})", "uid")
uids = ad_uids.map { |i| i[0] }.flatten
uids
end
end
-- output of above code --
[r...@tuatara (puppetmaster) functions]# irb -r puppet -r get_ad_uids.rb
irb(main):001:0> Puppet::Parser::Functions::function(:get_ad_uids)
=> "function_get_ad_uids"
irb(main):002:0> s = Puppet::Parser::Scope.new
=> #<Puppet::Parser::Scope:0x2adf763d7220 @namespaces=[""],
@symtable={}, @defaults={}, @tags=[]>
irb(main):003:0> s.function_get_ad_uids('50000')
=> ["user1", "user2", "user3", "user4"]
## manifests/templates.pp
node common {
include core
.. snip ..
}
.. snip ..
node puppetmaster inherits common {
include puppet::server
include homedir::creator
$uids = get_ad_uids('50000') # should return an array of homedirs
to ensure are created
print { $uids: }
# make sure the home directories exist for all ad users above
# the specified uid
ensure_homedirs { $uids: }
.. snip ..
}
==> puppet-err.log <==
2009-10-19T14:02:25-06:00 tuatara puppetmasterd[4479]:
Puppet::Parser::AST::Resource failed with error ArgumentError:
Resources require a type and title at
/var/lib/puppet/manifests/templates.pp:34 on node tuatara
2009-10-19T14:02:25-06:00 tuatara puppetmasterd[4479]:
Puppet::Parser::AST::Resource failed with error ArgumentError:
Resources require a type and title at
/var/lib/puppet/manifests/templates.pp:34 on node tuatara
2009-10-19T14:02:25-06:00 tuatara puppetd[4538]: Could not retrieve
catalog: Puppet::Parser::AST::Resource failed with error
ArgumentError: Resources require a type and title at
/var/lib/puppet/manifests/templates.pp:34 on node tuatara
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---