amazon ec2 - Chef: How to use different OS default users based on environment (Vagrant, EC2)? -
i writing cookbook run on ubuntu. create directory in home of default user.
directory "/home/<default-user>/my-directory" owner <default-user> end
the problem is, default user different across environments:
- it vagrant when running on virtual machine using vagrant.
- and ubuntu when running on ec2 instance.
what practice solve kind of problem? , how it?
thank you!
make user attribute , set according environment.
directory "/home/#{node[:my_app][:default_user]}/my-directory" owner node[:my_app][:default_user] end
then, on attributes/default.rb
file:
default[:my_app][:default_user] = 'ubuntu'
and on vagrantfile
:
vagrant.configure("2") |config| config.vm.provision "chef_solo" |chef| # ... chef.json = { "my_app" => { "default_user" => "vagrant" } } end end
this set default user ubuntu
, overridden when running in vagrant vm.
Comments
Post a Comment