What we really want is for the deploy LWRP to be able to specify the branch to the GIT. Ideally this is pulled off of an environment attirbute.
we are calling it like this :
my_deploy 'install my-client-portal' do
repo 'https://hqdevgit01.my.lan/sites/my-client-portal.git'
destination '/var/sites/my-client-portal'
action :installNodeFromGit
branch node[:my_deploy][:branch_name]
end
The branch above is not working..
LWRP Resource
actions :installNodeFromGit
default_action :installNodeFromGit if defined?(default_action)
attribute :repo, :kind_of => String, :required => true
attribute :destination, :kind_of => String, :required => true
attribute :branch, :kind_of => String, :required => false, :default => 'master'
LWRP provider
use_inline_resources
action :installNodeFromGit do
converge_by("Installing.") do
resp = install
@new_resource.updated_by_last_action(resp)
end
end
def load_current_resource
@current_resource = Chef::Resource::MyDeploy.new(@new_resource.name)
@current_resource.repo(@new_resource.repo)
@current_resource.destination(@new_resource.destination)
@current_resource.branch(@new_resource.branch)
end
def install
ENV['GIT_SSL_NO_VERIFY']="true"
directory new_resource.destination do
owner 'root'
group 'root'
mode '0755'
action :create
recursive true
end
git new_resource.destination do
repository new_resource.repo
action :sync
revision new_resource.branch
end
if new_resource.destination
path = new_resource.destination
cmd = "npm install"
execute "npm install at #{path}" do
cwd path
command cmd
end
end
end