Does not work with ansible 2.x
jakobwesthoff opened this issue · 9 comments
The currently installed dependency using pip is ansible 2.0.0.2. Unfortunately this does not work with battleschool.
It seems the templates
package moved from utils.templates
to .templates
Current workaround: manually install ansible 1.x (>= 1.9.1) before installing battleschool
@jakobwesthoff Have you had any luck with newer versions of Ansible?
@jakobwesthoff 👍 So is the only change to battle school the move of the templates package?
Anyone up for a PR?
I don't think it's as simple as editing a few import
statements:
diff --git a/lib/battleschool/main.py b/lib/battleschool/main.py
index a3b943b..2a8abd7 100644
--- a/lib/battleschool/main.py
+++ b/lib/battleschool/main.py
@@ -5,8 +5,8 @@ import battleschool.constants as C
AC.DEFAULT_CALLBACK_PLUGIN_PATH = C.DEFAULT_CALLBACK_PLUGIN_PATH
import ansible.playbook
-import ansible.utils.template
-from ansible import callbacks
+import ansible.template
+from ansible.plugins import callback
from ansible import errors
from ansible import utils
And now getting errors like this:
$ battle
Traceback (most recent call last):
File "/usr/local/bin/battle", line 4, in <module>
from battleschool.main import main
File "/Library/Python/2.7/site-packages/battleschool/main.py", line 14, in <module>
from battleschool.printing import *
File "/Library/Python/2.7/site-packages/battleschool/printing.py", line 1, in <module>
from ansible.callbacks import call_callback_module
ImportError: No module named callbacks
Looks like the internal Ansible APIS have changed for 2.X.
@spencergibb this seems like what is needed: https://docs.ansible.com/ansible/porting_guide_2.0.html
I gave it a shot but am running into issues with code that uses DefaultRunnerCallbacks
I'm seeing the same thing @ksylvan, haven't performed a full OS X system provision mostly because El Capitan made the reinstall a pain. My intention was to test this with a virtualized copy of OS X but simply haven't had the time to dive in. A bunch of my playbooks written pre-2.0 are having some issues or deprecation warnings.
Hoping that once things cool down post 2.0 I can issue a couple of PRs for this.
@qbunt I was able to follow this tutorial and get El Capitan up and running with only a few snags:
- On Step 5 I think there is something wrong with the syntax to remove the broken link, I ended up just opening it in finder and trashed it.
- There's a bit of a typo on Step 7, some of the html got stuck in the expression
Besides that it all seems to be working so far :)