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

Add Ansible diff mode #98

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion lib/smart_proxy_ansible/runner/ansible_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def initialize(input, suspended_action:, id: nil)
@verbosity_level = action_input[:verbosity_level]
@rex_command = action_input[:remote_execution_command]
@check_mode = action_input[:check_mode]
@diff_mode = action_input[:diff_mode]
@tags = action_input[:tags]
@tags_flag = action_input[:tags_flag]
@passphrase = action_input['secrets']['key_passphrase']
Expand Down Expand Up @@ -213,7 +214,7 @@ def start_ansible_runner
end

def cmdline
cmd_args = [tags_cmd, check_cmd].reject(&:empty?)
cmd_args = [tags_cmd, check_cmd, diff_cmd].reject(&:empty?)
return nil unless cmd_args.any?
cmd_args.join(' ')
end
Expand All @@ -227,6 +228,10 @@ def check_cmd
check_mode? ? '"--check"' : ''
end

def diff_cmd
diff_mode? ? '"--diff"' : ''
end

def verbosity
'-' + 'v' * @verbosity_level.to_i
end
Expand All @@ -239,6 +244,10 @@ def check_mode?
@check_mode == true && @rex_command == false
end

def diff_mode?
@diff_mode.nil? ? false : @diff_mode == true
rpluem-vf marked this conversation as resolved.
Show resolved Hide resolved
end

def prepare_directory_structure
inner = %w[inventory project env].map { |part| File.join(@root, part) }
([@root] + inner).each do |path|
Expand Down