Warning on deploy with ansible 2.4

After merging the ansible-2.4 changes I get the following waring on each deploy:

TASK [deploy : include_tasks] **************************************************
 [WARNING]: Failure using method (v2_runner_item_on_ok) in callback plugin
(<ansible.plugins.callback.output.CallbackModule object at 0x7fe7022be750>):
string indices must be integers

Anyone knows what’s up with that?


@mockey Thanks for reporting this. Could you check if temporarily commenting out this line in lib/trellis/plugins/callback/output.py prevents the warning message?

- output.replace_item_with_key(self, result)
+ # output.replace_item_with_key(self, result)

It would help to know which instance of TASK [deploy : include_tasks] prints the warning. Could you share the names of the two tasks prior and two tasks after the task in your original post?

I’m guessing you have a custom deploy-hook include with some formatting or task scenario that went unanticipated in the Trellis custom output plugin. Could you share the contents of any custom include files? The most relevant file would probably be the one containing tasks that run right after the task in your original post.

In any case, I think this issue only affects console output and that your deploys are still successful and unaffected.

@fullyint Really sorry for replying so late.

Yes, this prevents the warning.

The two tasks prior are:
TASK [deploy : Run git archive to populate new build dir]
TASK [deploy : Run git archive with subdirectory to populate new build dir]

The two tasks afterwards are:
TASK [deploy : Copy project templates]
TASK [deploy : Check if project folders exist]

Yes, I have a custom hook share-after.yml, that installs language files.
Contents are listed here:

That’s right. Deploys went through without any problems.

This is a bit weird. Actually my custom hook was not included. I must have missed to change its include location in some update. I placed it into group_vars/all/main.yml now and it ran OK (the warning remained).

I added another hook initialize_after and now the warning appeared at another place, right before this hook.

So this warning must be caused by a change that I made, right? You don’t get this warning?

Also: why is sometimes the included file displayed and sometimes only TASK [deploy : include_tasks] without any file path?

The deploy hooks are specified as loops where with_items defaults to an empty list (i.e., []) (example). When the output shows nothing, the default empty list was passed to the include_tasks task. When the output shows one or more files, it means with_items was not empty, either because Trellis already defined includes for the hook or because you did. Finally, in the case you get the string indices must be integers error, probably no file is listed.

I tried a setup as in your gist files and I haven’t been able to reproduce the string indices must be integers error.

This suggests a problem with the deploy_build_before hook or the deploy-hooks/build-before.yml file. You could post the contents of that file if you’d like, but I suspect the problem may be something even more fundamental, like perhaps a glitch in the process of applying Trellis updates, or just with your Ansible installation or Python version.

Could you share info about your Trellis and system generally?

  • topmost entry in your Trellis CHANGELOG.md file
  • what OS you’re running
  • output from python --version
  • output from ansible --version
  • and how you installed Ansible (pip, homebrew, etc.)

You might try a complete uninstall and reinstall of Ansible. Also note that Ansible 2.4 requires Python 2.6 or greater.

If the problem persists, you might try a completely fresh clone of Trellis (with Bedrock) with no customizations other than a real host or IP. Also add an uncommented task to the deploy-hooks/build-before.yml file, just so the file will be included (must be nonempty to be included):

- debug:
    msg: test

The point of that test is to see if the issue is with your system in general or perhaps with your current project’s customizations or its series of applied Trellis updates.

For example, I can produce a similar error (same include task, but not quite the same message) if I revert the change in https://github.com/roots/trellis/pull/817. That replace_item_with_key method hasn’t changed since then. You could verify that yours matches latest Trellis.

I see, every hook is a list now. Makes sense.

build.yml and build-before.yml are not changed in my installation.

That’s surely possible.

I try to stay in sync with the git version, so it’s:
* Dynamically increase ansible_group_priority for selected env...
But it’s quite possible that I made some mistake merging all the changes.

I’m running Linux Mint 17.3 (based on Ubuntu 14.04).

Python 2.7.6


I installed Ansible from the Ubuntu PPA. I remember there was a problem with the jinja2 package from Ubuntu. I think version 2.8 was needed but Ubuntu only provides 2.7 for 14.04. So I used the package from 16.04 (which is jinja2 version 2.8). There might be a problem with that. Maybe I should better use pip, but I don’t know how that combines with the standard package management. I have no python expertise…

I think I’ll try an install on a different computer with Ubuntu 16.04. Thanks for the thorough analysis, though.

1 Like

That seems to be correct in my install. Thanks again.