Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update _install-windows.rb #934

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 12 additions & 22 deletions recipes/_install-windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@
module Windows
class Helper
def clean_user(context)
resource = context.resource_collection.lookup('windows_env[DDAGENTUSER_NAME]')
resource.run_action(:delete)
context.node.run_state['datadog']['windows_ddagentuser_name'] = nil
end

def clean_password(context)
resource = context.resource_collection.lookup('windows_env[DDAGENTUSER_PASSWORD]')
resource.run_action(:delete)
context.node.run_state['datadog']['windows_ddagentuser_password'] = nil
Comment on lines 32 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ question: ‏ Is this still necessary given that run_state always gets discarded at the end of the Chef Infra Client run?

end

def unmute_host(context)
Expand All @@ -55,9 +53,12 @@ def unmute_host(context)
Windows::Helper.new.clean_user(Chef.run_context)
end
end
windows_env 'DDAGENTUSER_NAME' do
value ddagentuser_name
ruby_block 'Store Datadog User Name' do
block do
node.run_state['datadog']['windows_ddagentuser_name'] = ddagentuser_name
end
sensitive true
action :run
end
end

Expand All @@ -67,9 +68,12 @@ def unmute_host(context)
Windows::Helper.new.clean_password(Chef.run_context)
end
end
windows_env 'DDAGENTUSER_PASSWORD' do
value ddagentuser_password
ruby_block 'Store Datadog User Password' do
block do
node.run_state['datadog']['windows_ddagentuser_password'] = ddagentuser_password
end
sensitive true
action :run
end
end

Expand Down Expand Up @@ -249,17 +253,3 @@ def unmute_host(context)
unsafe
end
end

if ddagentuser_name
windows_env 'DDAGENTUSER_NAME' do
action :delete
sensitive true
end
end

if ddagentuser_password
windows_env 'DDAGENTUSER_PASSWORD' do
action :delete
sensitive true
end
end