Skip to content

add ansible playbook runner to ansiblegate module - #48254

Merged
rallytime merged 17 commits into
saltstack:developfrom
gtmanfred:ansible
Jul 13, 2018
Merged

rallytime merged 17 commits into
saltstack:developfrom
gtmanfred:ansible

Conversation

@gtmanfred

@gtmanfred gtmanfred commented Jun 21, 2018 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the ability to run ansible playbooks from salt execution modules or from states, specifically for orchestration states.

Tests written?

Added

Commits signed with GPG?

Yes

@gtmanfred gtmanfred added the needs-testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases label Jun 21, 2018
@rallytime
rallytime requested review from isbm and terminalmage June 21, 2018 19:58

@terminalmage terminalmage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just one minor change I would make, otherwise this is ++.

Comment thread salt/states/ansiblegate.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can use six.itervalues() here and not need to use the "throwaway" variable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

cool

@gtmanfred

Copy link
Copy Markdown
Contributor Author

Still need to write tests for this.

@isbm isbm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generally, if we want to validate the params, we should do it explicitly. Otherwise I would use Pythonic checks (see the comment).

Otherwise, excellent, woohoo!! 😎

Comment thread salt/modules/ansiblegate.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the reason to explicitly check the type alongside the value? I.e. why if check: is not sufficient?

Comment thread salt/modules/ansiblegate.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, still the same question though. I'd say if extra_vars:

@gtmanfred gtmanfred changed the title [WIP] add ansible playbook runner to ansiblegate module add ansible playbook runner to ansiblegate module Jun 21, 2018
@gtmanfred gtmanfred removed the needs-testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases label Jun 21, 2018
@gtmanfred

Copy link
Copy Markdown
Contributor Author

Test added

@gtmanfred
gtmanfred force-pushed the ansible branch 2 times, most recently from ce14410 to 6ef47ae Compare June 22, 2018 00:09
@gtmanfred

Copy link
Copy Markdown
Contributor Author

re-run py

@isbm isbm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool, thanks! Some last little nitpicks though.

Comment thread salt/states/ansiblegate.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If gitrepo is an empty string this will fail.

Comment thread salt/states/ansiblegate.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe this is better way, unless we do not want to validate all that and crash with the error "You've passed an empty string instead of a parameters" (or something like that):

if not ansible_kwargs:
    ansible_kwargs = {}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am just going to check if it a dict and if it isn't then i will set it to {}.

@rallytime

Copy link
Copy Markdown
Contributor

@gtmanfred

Copy link
Copy Markdown
Contributor Author

This should be all set to go on the next test run.

@gtmanfred

Copy link
Copy Markdown
Contributor Author

@gtmanfred
gtmanfred requested review from isbm and terminalmage June 23, 2018 16:19

@terminalmage terminalmage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is gitrepo part of a naming convention used elsewhere? If not, it may make sense to change it. I'm just worried about confusion between gitrepo (no underscore) and git_kwargs (underscore). It seems like this could lead to confusion/typos.

@isbm isbm left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@terminalmage actually a very good catch, it slipped out of my radar: the git_<something> is better convention than git<something>.

@gtmanfred could you please appease BOFH (and terminalmage) by looking into name conventions and checking to None one more time? 😉 I would appreciate that.

Other then that, it is good to go as of my current views.

@isbm isbm left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LOL 😆 👍 good to go.

@rallytime
rallytime requested a review from terminalmage June 25, 2018 14:31
@rallytime

Copy link
Copy Markdown
Contributor

@gtmanfred Lint :)

@isbm isbm left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@gtmanfred docs, tests. :)

Comment thread salt/states/ansiblegate.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Docs :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

bah... i did a search replace... apparently i am just terrible at regex.

@isbm isbm Jun 26, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@isbm isbm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@gtmanfred thanks! Hopefully now it is OK to go.

@rallytime

Copy link
Copy Markdown
Contributor

@gtmanfred

Copy link
Copy Markdown
Contributor Author

re-run py

@rallytime

Copy link
Copy Markdown
Contributor

@gtmanfred The Py3 tests are failing your new test. Can you take a look?

https://jenkins.saltstack.com/job/PR/job/salt-pr-linode-cent7-py3/6163/

  • integration.states.test_ansiblegate.AnsiblePlaybooksTestCase.test_ansible_playbook

@gtmanfred

Copy link
Copy Markdown
Contributor Author

One last test to fix. Working on it this morning

@gtmanfred

Copy link
Copy Markdown
Contributor Author

Ok, this should be ready.

@rallytime

Copy link
Copy Markdown
Contributor

@gtmanfred

Copy link
Copy Markdown
Contributor Author

re-run py

@gtmanfred

Copy link
Copy Markdown
Contributor Author

re-run all

@rallytime

Copy link
Copy Markdown
Contributor

re-run py

@rallytime

Copy link
Copy Markdown
Contributor

@gtmanfred I think the following test is related. I am not seeing this fail elsewhere:

  • integration.modules.test_cmdmod.CMDModuleTest.test_run

https://jenkins.saltstack.com/job/PR/job/salt-pr-linode-ubuntu16-py3/11261/

@rallytime
rallytime merged commit 490d7fb into saltstack:develop Jul 13, 2018
@gtmanfred
gtmanfred deleted the ansible branch July 13, 2018 19:29
@gtmanfred

Copy link
Copy Markdown
Contributor Author

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants