th/ansible_independent#23
Merged
Merged
Conversation
thom311
force-pushed
the
th/ansible-independent
branch
from
January 19, 2018 14:15
da839db to
de6ce89
Compare
Instead, pass the provider parameter.
It is really related to how the Cmd class operates during run. It should not be handled by AnsibleUtil.
Make it more independent of AnsibleUtil.connections. Eventually, we want to move parts to Cmd.
For now this looks more complicated then before. It will get better...
Now, that we only create the AnsibleUtil instance when we already know that we run under ansible (not from unit tests), we can avoid initializing the AnsibleModule lazily.
run() supports a --check mode (DRY_RUN) and a real mode, where the real mode consists of a PRE_RUN that only simulates the steps and a REAL_RUN. Actualy changes can only happen during REAL_RUN (and we pretend that they happen during DRY_RUN). Fix handling of the change flag, is was broken previously. Also, we need to set the is-changed flag to True before actually invoking the action. Because, if we fail, we might fail_json() right away, and need to correct changed flag.
thom311
force-pushed
the
th/ansible-independent
branch
from
January 22, 2018 09:33
de6ce89 to
068db05
Compare
Collaborator
|
Looks good to me. |
thom311
added a commit
that referenced
this pull request
Jan 22, 2018
Refactor the code, to make Cmd independent of ansible includes. This would simplify to extend the library to run as stand-alone application or to re-use parts without ansible. Also, it better separates the code. #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor the module, to make it mostly independent of the ansible runtime.
The module is just one large python script. Ansible will execute it and communicated with it via stdout/stdin.
However, most of the stuff that the script does, is independent of ansible or how it is called.
Refactor the code, so that the parts that require the ansible environment can be replaced. This way, one could import the code in another python application, or we could run it from the command line and feed our own input format.