Trying to deploy - FATAL: all hosts have already failed -- aborting

I setup a server on DO, added the keys and everything.

I’m trying to deploy with ansible-playbook -i hosts/staging server.yml -vvvv
It connects, it seems that it does the apt-get update and all, but fails after that.

You can check the log here: http://pastie.org/pastes/10189459/text

Any ideas on what could be the problem?

Never seen that error before but after brief searching it seems like a Jinja templating error.

Does it happen repeatedly?

I am still new to bedrock-ansible.

Here are some of my configs:
http://pastie.org/private/bqaxj6vecuyutpv7aova

It doesn’t pass the fail2ban settings. But also when I remove, it gives an error in the next stepp.

Not sure this matters for the error or if you just edited out your real host, but under site_hosts it should be a hostname like temp.org and not just temp.

I just tried again, new server, new ansible-bedrock setup.
Let’s say I want to deploy a blank Wordpress with it, I don’t know why it’s giving an error when it tries to run the tasks.

it’s a ubuntu 14.04 blank installation.

<128.199.254.221> ESTABLISH CONNECTION FOR USER: root
<128.199.254.221> EXEC ssh -C -tt -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/daniel/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 128.199.254.221 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1432105859.49-73450811581301 && echo $HOME/.ansible/tmp/ansible-tmp-1432105859.49-73450811581301'
fatal: [128.199.254.221] => Failed to template o2M4cKQVn.dCLC!G!%N_~_%OGt&SC[X3!08{%b1Q 5%ikS?!%[va)Q>FL%M,165N: template error while templating string: Encountered unknown tag 'b1Q'.

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/Users/daniel/server.retry

128.199.254.221            : ok=9    changed=7    unreachable=1    failed=0```

This happened when you have the ‘{%’ character in your salt string which Jinja treated as a statement delimiter. Same as having a space character or or other delimiters. Simply by replacing the character will prevent the error.

Quite a simple issue but did cause me big headache as a beginner I am.
I couldn’t find any guide on it so hope this help someone.

2 Likes

@eeebb_ interesting, thanks for posting this. Were your salt strings surrounded by quotes though? By default we have them as "generateme" so that the values remain in quotes which should avoid those templating issues but I should test that.

Enclosing the strings with single or double quotes show the same error in my case. Although, I am running ansible under cygwin, perhaps that somehow cause such issue

Looks like someone else ran into the same problem: http://stackoverflow.com/questions/30130681/how-do-i-prevent-ansible-templates-from-being-confused-by-the-content-they-recei

@eeebb_ thanks again for figuring this out. For now I’ve added a note to the files about this: https://github.com/roots/trellis/commit/da8d3c82f34ed0caf7903339295f1030c73eadb7