2013-08-30 2 views
0

내 조리법은 다음 삭제를 추가 한 다음 바인딩을 다음과 같이 shell_out 명령을 사용하여 https 바인딩을 추가 http와 함께 IIS 웹 사이트를 시작하려면 IIS 요리 책을 사용 요리사 shell_out 조기 호출

iis_site iis_site_name do 
    action :delete 
end 


    ... other things ... 

iis_site iis_site_name do 
    protocol :http 
    port 80 
    path site_dir 
    application_pool iis_site_name 
    host_header site_header 
    action [:add,:start] 
end 

if https 
    https_binding(iis_site_name, site_header) 
end 


def https_binding(site_name, site_header) 
    cmd = "#{appcmd} set site /site.name:\"#{site_name}\" /+bindings.[protocol='https',bindingInformation='*:443:#{site_header}']" 
    Chef::Log.info("Running HTTPS config command") 
    Chef::Log.debug(cmd) 
    shell_out!(cmd, {:returns => [0,42]}) 
    Chef::Log.info("HTTPS config command run") 
end 

디버그 로그를 살펴보면, 그것은 https_binding 로그 디버그/정보 통화가 삭제되는 IIS 사이트 이전에 호출되는 것을 보여줍니다
[2013-08-30T16:22:01+00:00] INFO: Running HTTPS config command 
[2013-08-30T16:22:01+00:00] DEBUG: C:\Windows\System32\inetsrv\appcmd.exe set site /site.name:"mysite" /+bindings.[protocol='https',bindingInformation='*:443:mysite.com'] 
ERROR (message:New binding object missing required attributes. Cannot add duplicate collection entry of type 'binding' 
with combined key attributes 'protocol, bindingInformation' respectively set to 'https, *:443:mysite.com' 
.) 
[2013-08-30T16:22:01+00:00] INFO: HTTPS config command run 
(up to date) 
Recipe: <Dynamically Defined Resource> 
* iis_site[mysite action delete[2013-08-30T16:22:01+00:00] INFO: Processing iis_site[mysite] action delete (c:/chef/cache/cookbooks/mycookbook/providers/website.rb line 47) 

왜 이러한 명령은 늦게 그들이 호출 할 때 반대로 실행되고있다?

답변

0

다음 코드를 변경하면 효과가 있지만이 방법이 마음에 들지 않습니다. 더 좋은 방법이 있습니까?

deleteSite = iis_site iis_site_name do 
end 

deleteSite.run_action(:delete) 


    ... other things ... 

createSite = iis_site iis_site_name do 
    protocol :http 
    port 80 
    path site_dir 
    application_pool iis_site_name 
    host_header site_header 
end 

createSite.run_action(:add) 
createSite.run_action(:start) 

if https 
    https_binding(iis_site_name, site_header) 
end 


def https_binding(site_name, site_header) 
    cmd = "#{appcmd} set site /site.name:\"#{site_name}\" /+bindings.[protocol='https',bindingInformation='*:443:#{site_header}']" 
    Chef::Log.info("Running HTTPS config command") 
    Chef::Log.debug(cmd) 
    shell_out!(cmd, {:returns => [0,42]}) 
    Chef::Log.info("HTTPS config command run") 
end