-
Notifications
You must be signed in to change notification settings - Fork 897
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
Ansible runner allow to run roles without playbook #17757
Ansible runner allow to run roles without playbook #17757
Conversation
Allow to run role without playbook
Allow to run run_role via queue
Fix the queue methods args
300612c
to
18f9abb
Compare
@miha-plesko @borod108 this way, we can call the roles directly and we can delete the simple playbooks |
run_via_cli(env_vars, extra_vars, :playbook_path => playbook_path) | ||
end | ||
|
||
def run_role(env_vars, extra_vars, role_name, roles_path:, role_skip_facts: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Galaxy roles, roles_path
argument won't mean anything because they are installed globally AFAIK. We would probably want to make it optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but right now ansible-runner looks only in the working dir, I need to create an Issue so it also checks the system roles/galaxy roles. So right now, we need to provide the right path ourselves (or I could put there a default value ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agrare although we probably didn't want to install the roles in a global dir, because of the possible conflicts with other providers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right we'll need to look into if we can install galaxy roles to directories other than a global location. Ideally we would scope this to per-provider repos so nothing conflicts.
lib/ansible/runner.rb
Outdated
|
||
if roles_path | ||
role_params[:"roles-path"] = roles_path | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest we inline it with
role_params[:"roles-path"] = roles_path if roles_path
lib/ansible/runner.rb
Outdated
end | ||
|
||
if role_skip_facts | ||
role_params[:"role-skip-facts"] = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should set to true
here instead nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, this argument is without value
so it's like ansible-runner XY
vs. ansible-runner XY --role-skip-facts
Simplify the role param condition
Fix circular argument reference
Checked commits Ladas/manageiq@93bdb15~...00bd9be with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
…s_without_playbook Ansible runner allow to run roles without playbook
unless File.exist?(path) | ||
raise "File doesn't exist: #{path}" | ||
end | ||
end | ||
|
||
def ansible_command(base_dir) | ||
# TODO add possibility to use custom path, e.g. from virtualenv | ||
"ansible-runner run #{base_dir} --json -i result" | ||
"ansible-runner run #{base_dir} --json -i result --hosts localhost" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future stuff but we might want to make the --hosts
configurable if people want to run playbooks on other systems i.e. post-provisioning
Ansible runner allow to run roles without playbook
The example usage is:
So we run a role directly and we do not need to write a playbook like https://github.com/ManageIQ/manageiq-providers-amazon/pull/453/files#diff-043bd0af7eaf90b61c703f5629a40845 , since that will be generated for us