Skip to content

Instantly share code, notes, and snippets.

@spuder
Last active April 21, 2016 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spuder/4aa3eb104e9c24b0d6f80cef5fa80f77 to your computer and use it in GitHub Desktop.
Save spuder/4aa3eb104e9c24b0d6f80cef5fa80f77 to your computer and use it in GitHub Desktop.
chef variable conflicts

I find that my custom resource (not LWRP) gets a conflict with the variable "service_name" in the alert logic cookbook.

Steps to reproduce:

Create custom resource with attribute "service_name"

Create a runlist that includes alert_logic cookbok and recipe with custom resource Make sure alert logic is first in the run list (unproven theory)

Expected outcome

The powershell script should run as follows:

sc.exe create 'NDConfigurationServer' binPath= C:\\SomeFolder\\ndConfServer.exe start= auto displayname= 'ND Configuration Server'

Actual outcome

powershell script runs:

sc.exe create 'alert_logic' binPath= C:\\SomeFolder\\ndConfServer.exe start= auto displayname= 'ND Configuration Server'
resource_name :nd_configurator
property :neserv_location, String, required: true
property :domain, String, required: true
property :user, String, required: true
property :port, String, required: true
property :service_name, String, required: true
property :display_name, String, required: true
action :create do
powershell_script 'Install ND Configuration Server' do
guard_interpreter :powershell_script # http://stackoverflow.com/a/25413011/1626687
code <<-EOH
sc.exe create '#{service_name}' binPath= #{neserv_location}\\ndConfServer.exe start= auto displayname= '#{display_name}'
EOH
action :run
not_if "Get-Service -Name '#{display_name}'"
end
end
end
omain = node['domain']
user = 'nereg'
port = '8081'
service_name = 'NDConfigurationServer'
display_name = 'ND Configuration Server'
if node['kernel']['cs_info']['domain_role'].to_i == 1 || node['kernel']['cs_info']['domain_role'].to_i == 3
# Custom resource that accepts actions :create, :stop, :start, :restart
nd_configurator 'ndconf server' do
neserv_location node['nd-web']['neserv_path']
domain domain
user user
port port
service_name service_name
display_name display_name
action :create
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment