Swaroop Kundeti
Swaroop Kundeti

Reputation: 667

switch chef-client user during bootstrap

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

Upvotes: 0

Views: 308

Answers (1)

coderanger
coderanger

Reputation: 54191

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

Upvotes: 0

Related Questions