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

Ansible runner async method #17763

Merged
merged 5 commits into from Jul 27, 2018
Merged

Conversation

Ladas
Copy link
Contributor

@Ladas Ladas commented Jul 26, 2018

Make it possible to run ansible-runner on the background, so it doesn't block the generic worker.

@Ladas Ladas force-pushed the ansible_runner_async_method branch from f62d646 to 681cd14 Compare July 26, 2018 13:16
@Ladas
Copy link
Contributor Author

Ladas commented Jul 26, 2018

@miq-bot assign @agrare
@miq-bot add_label enhancement

@Ladas Ladas force-pushed the ansible_runner_async_method branch from 681cd14 to 4c50f10 Compare July 26, 2018 13:29
@Ladas Ladas changed the title Ansible runner async method [WIP] Ansible runner async method Jul 26, 2018
@miq-bot miq-bot added the wip label Jul 26, 2018
@Ladas Ladas force-pushed the ansible_runner_async_method branch 2 times, most recently from 0398e04 to 99c2851 Compare July 27, 2018 10:50
@Ladas Ladas changed the title [WIP] Ansible runner async method Ansible runner async method Jul 27, 2018
@miq-bot miq-bot removed the wip label Jul 27, 2018
@Ladas
Copy link
Contributor Author

Ladas commented Jul 27, 2018

@agrare ok, so this is ready for testing:

Your workflow would be:

res = AnsibleRunner.run_async(...)

if res.running?, do content = res.dump and store the content to the db
then repeat: AnsibleResponseAsync.load(content).running?

Once it is not running, fetch the you will fetch the response with:
response = AnsibleResponseAsync.load(content).response # this is the same Response object as returned by the synced version


For testing, you can use a simple playbook:

---
- name: Create a security group
  hosts: localhost
  connection: local
  gather_facts: False
  tasks:
    - name: simulate long running op (15 sec), wait for up to 45 sec, poll every 5 sec
      command: /bin/sleep 90
      async: 405
      poll: 5

Just don't do sleep bigger than 120s, since that will fail now ansible/ansible-runner#99 (comment)

And the run_async works now, run_role_async doesn't run on the background because of
ansible/ansible-runner#100

# @param base_dir [String] Base directory containing Runner metadata (project, inventory, etc). ansible-runner
# refers to it as 'private_data_dir'
# @param ident [String] An identifier that will be used when generating the artifacts directory and can be used to
# uniquely identify a playbook run. sWe use unique base dir per run, so this idrntifier can be static for
Copy link
Member

Choose a reason for hiding this comment

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

couple of typos, swe and idrntifier

Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

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

LGTM just those typos

Add a possibility to start async ansible-runner
Make Response object work also for the async run
Implement stop and running? methods with proper response and cleanup
Add missing YARD docs
Fix YARD typos
@Ladas Ladas closed this Jul 27, 2018
@Ladas Ladas reopened this Jul 27, 2018
@Ladas Ladas force-pushed the ansible_runner_async_method branch from 0a01bef to c6571ea Compare July 27, 2018 14:34
@miq-bot
Copy link
Member

miq-bot commented Jul 27, 2018

Checked commits Ladas/manageiq@a12d80d~...c6571ea with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 2 offenses detected

lib/ansible/runner/response.rb

@agrare agrare merged commit 12b109c into ManageIQ:master Jul 27, 2018
@agrare agrare added this to the Sprint 91 Ending Jul 30, 2018 milestone Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants