-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Allow specifying --diff for ansible-pull #37645
Conversation
!component =lib/ansible/cli/pull.py |
@webknjaz can you rerun the CI? I don't think the failure has to do with my changes, some test says |
@debugloop I've restarted CI. |
@debugloop this PR contains the following merge commits: Please rebase your branch to remove these commits. |
Sorry to bother you guys, but it's been a month. What can I do to help get this approved? Anything you need from my side? |
lib/ansible/cli/pull.py
Outdated
self.parser.add_option("--check", default=False, dest='check', action='store_true', | ||
help="don't make any changes; instead, try to predict some of the changes that may occur") | ||
self.parser.add_option('--syntax-check', dest='syntax', action='store_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.
im not sure syntax check makes any sense in this context, why do it via pull? the playbook should be checked by ansible-playbook, using pull as a proxy for a check seems contrived.
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.
It is. This change works around the Check CLI Option Group being blocked by the -C
flag being already present in the ansible-pull specifig flags. I was originally going for the --diff
option, but ended up including all flags from the check group. I can remove it of course.
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 removed the syntax checking option from this PR and used the opportunity to squash my commits and rebase to latest devel.
dcba8d8
to
db52564
Compare
self.parser.add_option("--check", default=False, dest='check', action='store_true', | ||
help="don't make any changes; instead, try to predict some of the changes that may occur") | ||
self.parser.add_option("--diff", default=C.DIFF_ALWAYS, dest='diff', action='store_true', | ||
help="when changing (small) files and templates, show the differences in those files; works great with --check") |
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.
tempted to say just use check_opts=True and remove syntax check afterward with remove_option (we do this in ansible-inventory).
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.
If we did that, we'd have to remove --check
too and and re-add it without it's shorthand -C
? Instead of check_opts=False
with two adds we'd end up with a True
and two removals and one re-add. I suppose it would reduce the number of duplicate help strings by one. You prefer the second option? Then I'll invert the current PR to do it that way.
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.
if it were not for the -C
i would not say 'tempted' but actually request it
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.
Okay, I'll consider this merge-ready then.
Hello @dagwieers , sorry for bugging you but this seems to be waiting for your review. It's been a while and I've rebased the PR with the latest devel again. I guess this feature won't make 2.6 now that RCs have been released? |
+1 please merge :) |
@debugloop That's easily fixed ;-) Although I don't think this was the blocking issue... |
@bcoca Can this be merged for v2.7 ? Update: Maybe I'll put it on the core meeting agenda instead. |
!rebuild_merge |
SUMMARY
The ansible-pull command does not support the
--diff
(and--syntax-check
) flags. This is due to the fact that thePullCLI
parsing does not include the generalcheck_opts
CLI flag group which contains the two flags in question, as well as the--check
flag. Thecheck_opts
group was propably left out due to a conflict between the ansible-pull specific--checkout
/-C
flag and the--check
/-C
flag which is part of the default CLI. Instead, the--check
flag was added manually to the ansible-pull CLI parser, without its shorthand-C
.This PR does the same for the
--diff
and--syntax-check
flags, and also adds comments describing the rationale behind adding these three manually (and without their shorthand versions).ISSUE TYPE
COMPONENT NAME
ansible-pull
ANSIBLE VERSION
ADDITIONAL INFORMATION
The change works as expected. Running
ansible-pull --diff -U git@github.com:debugloop/test-playbook.git test.yml
on my machine yields the following results. The playbook can be viewed in said repo, but it is just acopy
to a tmpfile with static content.Before:
After: