0

I've written a recipe to install Aegir. I would like to bootstrap a new instance on aws with aegir recipe, The installation goes well but fails to execute "drush hostmaster-install" as it throws "Drupal installation not found" error.

It installs smoothly When i manually go into machine and have a chef-client run with aegir user.

ssh to ec2 with ubuntu user
sudo su - aegir
sudo chef-client

But the installation is getting failed when i bootstrap new instance with ubuntu user. I appreciate any idea's of switching users to run chef client.

execute "apt-get-update" do
  command "sudo apt-get update"
end

%w{curl apache2 php5 libapache2-mod-php5 openssl php-pear php5-cli php5-common php5-curl php5-dev php5-gd php5-imagick
php5-imap php5-intl php5-mcrypt php5-memcache php5-ming php5-mysql php5-ps php5-pspell php5-recode php5-tidy php5-gd
php5-xmlrpc php5-xsl apache2-utils postfix rsync sudo libcurl3 libcurl3-gnutls mysql-client mysql-common}.each do |x|
    package x do
        action :install
    end
end

user "aegir" do
    action :create
    supports :manage_home => true
    comment "aegir User"
    home "#{node[:aegir][:dir]}"
    shell "/bin/bash"
    password "VenEucAf1"
end

group "www-data" do
    action :modify
    members "aegir"
    append true
end

bash "install_mysql" do
    user "root"
    code  /etc/sudoers.d/aegir
    chmod 440 /etc/sudoers.d/aegir
    EOH
    not_if { ::File.exists?("/etc/sudoers.d/aegir") }
end


bash "Install_drush" do
    user "root"
    cwd "/var/aegir"
    code  '/var/aegir', 'USER' => 'aegir' }) 
        cwd "#{node[:aegir][:dir]}"
    command  true, :restart => true, :reload => true
    action :start
end

Updated my complete recipe.

Error: User aegir does not exists

Swaroop Kundeti
  • 515
  • 4
  • 11
  • 25

1 Answers1

0

Sounds like you might need to set the HOME environment variable. You can add it to the execute resource:

execute 'drush hostmaster-install' do
  user 'aegir'
  environment 'HOME' => '/home/whatever'
end
coderanger
  • 52,400
  • 4
  • 52
  • 75
  • I had it enabled in the same bash script installs aegir. bash "Install aegir" do user "aegir" group "www-data" environment ({'HOME' => "#{node[:aegir][:dir]}"}) cwd "#{node[:aegir][:dir]}" code <<-EOH – Swaroop Kundeti Jan 15 '15 at 19:34
  • Check other environment variables then. – coderanger Jan 15 '15 at 19:55
  • @SwaroopKundeti do you also have the `user "aegir"` property in your execute resource ? (if so, the script should be launched with this user, but as you're doing a `su -` for your manual test you may load some other env variables we can't guess. (a good test to confirm would be `sudo su -u aegir sudo chef-client`) – Tensibai Jan 16 '15 at 09:58
  • @Tensibal, I had that test successful "sudo su - aegir && sudo chef-client". I've updated question with complete recipe – Swaroop Kundeti Jan 16 '15 at 12:25