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

Accept a dictionary for playbook #855

Merged
merged 8 commits into from
Oct 13, 2021

Conversation

samdoran
Copy link
Contributor

@samdoran samdoran commented Sep 28, 2021

Fixes #852
Fixes #642

The validation function isplaybook() expects a playbook to be a list of dictionaries, not a bare dictionary or a string. Update the docs to reflect this requirement and cast a bare dictionary to a list before passing to isplaybook().

  • Add tests

@samdoran
Copy link
Contributor Author

It may also be a good idea to add some error handling here for invalid values to playbook in order to fail early rather than later in unexpected ways.

@samdoran samdoran force-pushed the issue/852-playbook-as-dict branch 3 times, most recently from 75e16a8 to 190e50c Compare October 6, 2021 20:28
@samdoran
Copy link
Contributor Author

samdoran commented Oct 7, 2021

recheck

1 similar comment
@samdoran
Copy link
Contributor Author

recheck

@samdoran samdoran requested a review from a team October 11, 2021 18:58
@samdoran samdoran marked this pull request as ready for review October 11, 2021 18:59
ansible_runner/interface.py Outdated Show resolved Hide resolved
ansible_runner/utils/__init__.py Show resolved Hide resolved
@samdoran samdoran force-pushed the issue/852-playbook-as-dict branch 3 times, most recently from 6aa48d2 to 2796c6f Compare October 12, 2021 15:58
A string isn't valid.
Use Python 3.8 for linters

Remove Python 3.8 specific code changes

CI is stuck on Python 3.6 for tests currently, so these changes won't pass.
Copy link
Member

@shanemcd shanemcd left a comment

Choose a reason for hiding this comment

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

Nice work

Remove the use of reset_mock() and create separate tests.
Add tests for role vars and skipping fact gathering
A dictionary is more accuratey a MutableMapping.
Copy link
Contributor

@ansible-zuul ansible-zuul bot left a comment

Choose a reason for hiding this comment

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

LGTM!

@ansible-zuul ansible-zuul bot merged commit 3d6886d into ansible:devel Oct 13, 2021
@patchback
Copy link

patchback bot commented Oct 13, 2021

Backport to release_2.0: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 3d6886d on top of patchback/backports/release_2.0/3d6886d1a26358ead139fef736d1c8ca07f7ab71/pr-855

Backporting merged PR #855 into devel

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/ansible/ansible-runner.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/release_2.0/3d6886d1a26358ead139fef736d1c8ca07f7ab71/pr-855 upstream/release_2.0
  4. Now, cherry-pick PR Accept a dictionary for playbook #855 contents into that branch:
    $ git cherry-pick -x 3d6886d1a26358ead139fef736d1c8ca07f7ab71
    If it'll yell at you with something like fatal: Commit 3d6886d1a26358ead139fef736d1c8ca07f7ab71 is a merge but no -m option was given., add -m 1 as follows intead:
    $ git cherry-pick -m1 -x 3d6886d1a26358ead139fef736d1c8ca07f7ab71
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Accept a dictionary for playbook #855 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/release_2.0/3d6886d1a26358ead139fef736d1c8ca07f7ab71/pr-855
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@samdoran samdoran deleted the issue/852-playbook-as-dict branch October 13, 2021 17:59
samdoran pushed a commit to samdoran/ansible-runner that referenced this pull request Oct 13, 2021
Accept a dictionary for playbook

Fixes ansible#852
Fixes ansible#642
The validation function isplaybook() expects a playbook to be a list of dictionaries, not a bare dictionary or a string. Update the docs to reflect this requirement and cast a bare dictionary to a list before passing to isplaybook().

 Add tests

Reviewed-by: David Shrewsbury <None>
Reviewed-by: Sam Doran <sdoran@redhat.com>
Reviewed-by: Shane McDonald <me@shanemcd.com>
Reviewed-by: None <None>
(cherry picked from commit 3d6886d)
samdoran pushed a commit to samdoran/ansible-runner that referenced this pull request Oct 18, 2021
The validation function isplaybook() expects a playbook to be a list of dictionaries, not a bare dictionary or a string. Update the docs to reflect this requirement and cast a bare dictionary to a list before passing to isplaybook().

(cherry picked from commit 3d6886d)
samdoran pushed a commit to samdoran/ansible-runner that referenced this pull request Oct 19, 2021
The validation function isplaybook() expects a playbook to be a list of dictionaries, not a bare dictionary or a string. Update the docs to reflect this requirement and cast a bare dictionary to a list before passing to isplaybook().

(cherry picked from commit 3d6886d)
samdoran pushed a commit to samdoran/ansible-runner that referenced this pull request Oct 19, 2021
The validation function isplaybook() expects a playbook to be a list of dictionaries, not a bare dictionary or a string. Update the docs to reflect this requirement and cast a bare dictionary to a list before passing to isplaybook().

(cherry picked from commit 3d6886d)
ansible-zuul bot added a commit that referenced this pull request Oct 19, 2021
[release_2.0] Accept a dictionary for playbook (#855)

Backport of #855 for Ansible Runner 2.0.

Reviewed-by: David Shrewsbury <None>
Reviewed-by: None <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants