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

Fixes #35456 - Source environment before starting ansible-runner #66

Merged
merged 5 commits into from Nov 9, 2022

Conversation

adamruzicka
Copy link
Contributor

No description provided.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

On a related note, we also have a similar case in write_inventory where there's essentially a wrapper for cat written every time. Might be nice to have a more elegant solution for that too (in a different PR).

@@ -186,10 +189,12 @@ def write_ssh_key
def start_ansible_runner
env = {}
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned in theforeman/puppet-foreman_proxy#777 (comment) I wonder if we should present everything as environment variables by default. In that case I'd probably extract the env var construction to a separate method.

@@ -10,6 +10,9 @@ class AnsibleRunner < ::Proxy::Dynflow::Runner::Parent
include ::Proxy::Dynflow::Runner::ProcessManagerCommand
attr_reader :execution_timeout_interval

# To make this overridable in development
ENVIRONMENT_WRAPPER = ENV['SMART_PROXY_ANSIBLE_ENVIRONMENT_WRAPPER'] || '/usr/libexec/foreman-proxy/ansible-runner-environment'
Copy link
Member

Choose a reason for hiding this comment

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

This is missing the .sh file extension

Copy link
Member

Choose a reason for hiding this comment

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

It really shouldn't ;)
#66 (comment)

@@ -186,10 +189,12 @@ def write_ssh_key
def start_ansible_runner
env = {}
env['FOREMAN_CALLBACK_DISABLE'] = '1' if @rex_command
command = [env, 'ansible-runner', 'run', @root, '-p', 'playbook.yml']
env['ANSIBLE_ENVIRONMENT_FILE'] = Proxy::Ansible::Plugin.settings[:ansible_environment_file]
Copy link
Member

Choose a reason for hiding this comment

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

Is ANSIBLE_ENVIRONMENT_FILE an Ansible configuration value or something we are making up? I ask because if this is something we are making up we should probably avoid using the ANSIBLE_ prefix as that is a "known" pattern amongst Ansible configuration values when provided via environment variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is something I made up

Copy link
Member

Choose a reason for hiding this comment

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

A thought to avoid potential issues there would be to use your prefix from above SMART_PROXY_ANSIBLE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me SMART_PROXY_ANSIBLE_ENVIRONMENT_FILE reads like it is a file that should contain environment for smart-proxy-ansible, not ansible spawned by smart-proxy-ansible, but sure, why not

Copy link
Member

Choose a reason for hiding this comment

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

To me SMART_PROXY_ANSIBLE_ENVIRONMENT_FILE reads like it is a file that should contain environment for smart-proxy-ansible, not ansible spawned by smart-proxy-ansible, but sure, why not

Fair. Naming is hard. Maybe @evgeni has an opinion as our resident expert on all things "fun" that can get us in trouble with Ansible.

Copy link
Member

Choose a reason for hiding this comment

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

I think SMART_PROXY_ANSIBLE_ is a good prefix for config options for the smart_proxy_ansible plugin. In a container you'd probably do the same thing for all options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Done

Did you mean to push up new changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Erm, yes, sorry. It is out now

@stejskalleos stejskalleos merged commit 896a20c into theforeman:master Nov 9, 2022
@stejskalleos
Copy link
Contributor

Merging, thanks @adamruzicka @ekohl @ehelms !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants