[automateit] AccountManager incorrectly determining driver availability when AutomateIt is invoked from Ubuntu firstboot.sh

Skip to first unread message

Jamie Jamison

May 3, 2010, 5:44:28 PM5/3/10
to AutomateIt
I'm using AutomateIt 0.91104 on a system running Ubuntu Karmic and
it's great. The only problem I've run into so far has to do with
invoking recipes that use AccountManager from scripts run from the
firstboot.sh file in virtual machine created with Ubuntu's vmbuilder
command. I have a very basic firstboot.sh script that downloads and
executes a shell script that does the following:

1) Installs ruby and rubygems 1.3.6 from rubyforge (not the version
available via apt-get)
2) Downloads and installs AutomateIt 0.91104
3) Checks out a Subversion repository containing an AutomateIt
4) Invokes automateit on a recipe called master.rb with the command

automateit -p /var/automateit/myproject /var/automateit/myproject/

The master.rb recipe looks at an argument fed to the bootstrap shell
script or a tag value for the system hostname defined config/tags.yml
and invokes another recipe that calls the recipes necessary to build
the system.

# master.rb
# Master build recipe. This automateit recipe checks the value of the
tags in config/tags.yml
# and builds and configures the host depending upon how it is tagged.
# If no tags are set for the host install the default set of packages
and configurations.
invoke 'basic-packages.rb'
# Configure the server based upon tag value
if tagged?("webserver") then
invoke 'webserver.rb'
elsif tagged?("hudson_ci") then
invoke 'hudson-ci.rb'
elsif tagged?("development") then
invoke 'development.rb'
end #if tagged?

The problem I'm running into is with the development recipe. The
recipe looks like this

# Master recipe for building a development system running aspen and
snowbell. This builds a
# development host
# Where the aspen and snowbell trees are checked out This recipe
# does not allow for multiple separate builds on a host. Hosts are
tagged in config/tags.yml as to
# which tree they are working on and the appropriate tree is checked
invoke 'basic-packages.rb'
invoke 'config-dev-packages.rb'
invoke 'config-gems.rb'
invoke 'install-java6.rb'
invoke 'config-jruby-jgems.rb'
invoke 'install-apache2.rb'
invoke 'config-postfix.rb'
invoke 'config-mysql.rb'
invoke 'config-sphinx.rb'
invoke 'config-aspen-snowbell-dev.rb'
invoke 'config-pure-ftpd.rb'
invoke 'config-passenger.rb'
invoke 'config-logrotate.rb'

When invoked as part of the boot process in the Ubuntu /root/
firstboot.sh script everything runs fine until the config-aspen-
snowbell-dev.rb recipe is invoked. This recipe creates the users for
our internal application, creates workspace directories and checks out
the software tree for each user. When this recipe is invoked from
firstboot.sh it fails as soon as it tries to create the new aspen and
snowbell users with the following error.

=> invoking config-aspen-snowbell-dev.rb
=> invoking /var/automateit/myproject/recipes/config-aspen-snowbell-
=> Driver AutomateIt::AccountManager::POSIX is available
=> Driver AutomateIt::AccountManager::Etc isn't available
Raw backtrace:
!! AutomateIt error trace:
manager.rb:206:in `driver_for': can't find driver for method
'has_user?' with arguments: ["aspen"] (NotImplementedError)}
manager.rb:154:in `dispatch_to'
manager.rb:126:in `dispatch'
account_manager.rb:55:in `has_user?'
account_manager/posix.rb:133:in `send'
account_manager/posix.rb:133:in `method_missing'
account_manager/base.rb:34:in `_add_user_helper'
account_manager/posix.rb:16:in `add_user'
manager.rb:156:in `send'
manager.rb:156:in `dispatch_to'
manager.rb:126:in `dispatch'
account_manager.rb:42:in `add_user'
interpreter.rb:406:in `each'
interpreter.rb:406:in `invoke'
/var/automateit/myproject/recipes/development.rb:16:in `invoke'
interpreter.rb:406:in `each'
interpreter.rb:406:in `invoke'
/var/automateit/myproject/recipes/master.rb:18:in `invoke'
interpreter.rb:406:in `each'
interpreter.rb:406:in `invoke'
interpreter.rb:389:in `invoke'
root.rb:15:in `invoke'
39:in `run'
/usr/lib/ruby/1.8/optparse.rb:791:in `initialize'
/usr/bin/automateit:19:in `load'

But, and here's what's driving me nuts, if, after this failure, I
login to the system and run that script manually with

sudo automateit -p /var/automateit/myproject /var/automateit/myproject/

It runs without error, creating the new users, setting up their
workspace directories, etc. If I create a new virtual machine with
vmbuilder, log in to it and manually run the bootstrap script that
firstboot.sh runs this it also completes the system build without any

From looking at the error output the problem appears to be that the
AccountManager::Etc driver isn't available. AccountManager::Etc
contains the has_user? method which apparently is called by the
add_user method in the AccountManager::POSIX driver and for some
reason platform autodetection is failing in this one case when called
from firstboot.sh.

AutomateIt is properly detecting the system type and determining which
driver types are loaded for all of my other recipes. As you can see
from the output below when the master.rb recipe is invoked AutomateIt
determines that it's running on an Ubuntu/Debian system and loads the
appropriate drivers for PlatformManager, ShellManager and

=> Driver AutomateIt::PlatformManager::Uname is available
=> Driver AutomateIt::PlatformManager::LSB is available
=> Driver AutomateIt::PlatformManager::Debian is available
=> Driver AutomateIt::PlatformManager::Gentoo isn't available
=> Driver AutomateIt::PlatformManager::FreeBSD isn't available
=> Driver AutomateIt::PlatformManager::SunOS isn't available
=> Driver AutomateIt::PlatformManager::OpenBSD isn't available
=> Driver AutomateIt::ShellManager::WhichUnix is available
=> Driver AutomateIt::ShellManager::WhichWindows isn't available
=> Loading project from path: /var/automateit/myproject
=> Loading project tags: /var/automateit/myproject/config/tags.yml
=> Loading project fields: /var/automateit/myproject/config/fields.yml
=> Driver AutomateIt::AddressManager::SunOS isn't available
=> Driver AutomateIt::AddressManager::Linux is available
=> Driver AutomateIt::AddressManager::BSD isn't available
=> Driver AutomateIt::AddressManager::OpenBSD isn't available
=> Driver AutomateIt::AddressManager::FreeBSD isn't available
=> Driver AutomateIt::PlatformManager::Darwin isn't available

When the recipes that use ServiceManager and PackageManager are
invoked they are also available to determine and load the proper
drivers. I'm using the following code to create the new users in the
config-aspen-snowbell-dev recipe

account_manager.add_user("aspen", :description => "\"Aspen User
\"", :home => "/home/aspen", :shell =>"/bin/bash")
account_manager.add_user("snowbell", :description => "\"Snowbell User
\"", :home => "/home/snowbell", :shell =>"/bin/bash")

The firstboot script is run with /bin/sh -e, the environment variables
it runs with are:

whoami = root

I can work around this by creating users with a shell command from
within AutomateIt, but I hate doing that because it defeats the whole
point of using AutomateIt. Any enlightenment on this subject will be
greatly appreciated.


Jamie Jamison

But if I log into the server and run the config-aspen-snowbell-dev.rb
recipe with


You received this message because you are subscribed to the Google Groups "AutomateIt" group.
To post to this group, send email to autom...@googlegroups.com.
To unsubscribe from this group, send email to automateit+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/automateit?hl=en.

Reply all
Reply to author
0 new messages