Provisioning failure - all hosts have already failed

I am new to Bedrock.

I am on WIN8.1 (not by choice :()and after hitting one wall after another I am now at the point where I get this error during provisioning, please see below:

==> default: TASK: [wordpress-install | Create .env file] **********************
************
==> default: failed: [vagrant] => (item={'key': 'localdev1.dev', 'value': {'site
_install': True, 'admin_user': 'admin', 'local_path': '../localdev1.dev', 'syste
m_cron': True, 'repo': 'git@github.com:roots/bedrock.git', 'ssl': {'enabled': Fa
lse}, 'multisite': {'enabled': False, 'subdomains': False}, 'site_title': 'local
dev1 Site', 'admin_password': 'admin', 'env': {'db_name': 'localdev1_dev', 'wp_e
nv': 'development', 'db_user': 'localdev1_dbuser', 'db_password': 'localdev1_dbp
assword', 'wp_home': 'http://localdev1.dev', 'wp_siteurl': 'http://localdev1.dev
/wp'}, 'site_hosts': ['localdev1.dev'], 'admin_email': 'admin@localdev1.dev'}})
=> {"failed": true, "item": {"key": "localdev1.dev", "value": {"admin_email": "a
dmin@localdev1.dev", "admin_password": "admin", "admin_user": "admin", "env": {"
db_name": "localdev1_dev", "db_password": "localdev1_dbpassword", "db_user": "lo
caldev1_dbuser", "wp_env": "development", "wp_home": "http://localdev1.dev", "wp
_siteurl": "http://localdev1.dev/wp"}, "local_path": "../localdev1.dev", "multis
ite": {"enabled": false, "subdomains": false}, "repo": "git@github.com:roots/bed
rock.git", "site_hosts": ["localdev1.dev"], "site_install": true, "site_title":
"localdev1 Site", "ssl": {"enabled": false}, "system_cron": true}}}
==> default: msg: Could not replace file: /root/.ansible/tmp/ansible-tmp-1429691
400.4-145743800409621/source to /srv/www/localdev1.dev/current/.env: [Errno 26]
Text file busy
==> default:
==> default: FATAL: all hosts hav
==> default: e already failed -- aborting
==> default:
==> default: PLAY RECAP ********************************************************
************
==> default:            to retry, use: --limit @/root/dev.retry
==> default:
==> default: vagrant                    : ok=68   changed=38   unreachable=0
failed=1

C:\localdev1\bedrock-ansible>

I am unsure if this is related to FATAL: all hosts have already failed

I assume that I don’t HAVE to use HHVM to get around this issue? (Assuming that it is indeed the same issue as in the link above).

Anyway I did try using HHVM and including the workaround referenced in the above link (I also destroyed the machine when switching between HHVM true/false as per Foxaii’s post here Cannot connect to database).

Below is that workaround:

 Solution/workaround for directory permissions in Vagrantfile when using HHVM:

Change:

config.bindfs.bind_folder nfs_path(name), remote_site_path(name), u: 'vagrant', g: 'www-data'


to:

config.bindfs.bind_folder nfs_path(name), remote_site_path(name), u: 'vagrant', g: 'www-data', :'create-as-user' => true, :perms => "u=rwx:g=rwx:o=rx", :'create-with-perms' => "u=rwx:g=rwx:o=rx", :'chown-ignore' => true, :'chgrp-ignore' => true, :'chmod-ignore' => true


That lets group write to directories. Probably not the best solution, would love to hear opinions for something better.

However I still received the same error.

Any troubleshooting tips or general suggestions/ideas would be greatly appreciated!

Thank you,

Craig

[Errno 26] Text file busy
I haven’t seen this error before. After a quick search, it seems windows users have this error occasionally with Ansible and vagrant, especially with ansible’s template module, which is used in the task where you got the error.

You might research that a bit and let us know what leads you come up with. Maybe you’ve looked into that already? I fear it could be one of those issues where there’s no consensus on the fix and everyone’s got their own little trick workaround.

Yes my initial findings were the same as yours, i.e. there seems to be no consensus, I was hoping this was not the case.

Thank you for the info and the link, I will keep digging and let you know what I come up with.

Craig

1 Like

Ok, after having some sleep, I doubt that my issue is related to FATAL: all hosts have already failed which therefore accounts for receiving my original error after applying the ‘workaround’ related to the issue in the link… :stuck_out_tongue:

@Craig it sounds like you’ve done a lot of work to get this going. I’m glad you plan to keep digging. I admire that. It seems that windows users do get bedrock-ansible working, so hang in there.

If you haven’t recently tried a complete vagrant destroy to start from scratch with your latest and best settings, definitely try it. That will often resolve obscure issues that otherwise linger after multiple failed vagrant up s. You could also double-check that you have the latest Ansible, Vagrant etc., but you’ve probably done that already.

1 Like

@fullyint you were right the issue was in the code that you linked to and so inspired by jensenbox’s comment here:

  jensenbox commented 27 days ago



          @bcoca I think I have at least narrowed down the problem to something that is mildly fixable...

So it is in fact a 'cross partition' issue. The template task is 
creating a temp file of the result in the current users home directory 
and then doing an atomic os.rename.

Because /vagrant is technically on a different filesystem it is failing - but with what I suspect to be an invalid error code. 

msg: Could not replace file: /root/.ansible/tmp/ansible-tmp-1427476564.34-155580542794406/source to /vagrant/src/officepools/local_settings.py: [Errno 26] Text file busy


There are two points in the following code that could be returning the same error here: https://github.com/ansible/ansible/blob/60f972dfe4bc58180c666f820ef2d602acf917e4/v2/ansible/module_utils/basic.py#L1336

I even went as far to have the templated file store its result on the
 current posix filesystem then copy the file to the non-posix directory 
and the copy function fails as well. Pretty much the same error:

msg: Could not replace file: /root/.ansible/tmp/ansible-tmp-1427477026.96-38878336250870/source to /vagrant/src/officepools/local_settings.py: [Errno 26] Text file busy


Turns out that they are both using the exact same module base (nice and DRY)

So I tried the 'command' to have the os move it and all was good.

This:

- template: src=local_settings.py.jinja2 dest="{{ directories.src }}/{{ names.codename }}/local_settings.py"


becomes this:

- template: src=local_settings.py.jinja2 dest=/root/local_settings.py.temp
- command: mv /root/local_settings.py.temp {{ directories.src }}/{{ names.codename }}/local_settings.py


and all is good. 

Seems like Ansible could be modified pretty easily to fix at least this corner case.

In main.yml (C:\localdev1\bedrock-ansible\roles\wordpress-install\tasks\main.yml), I changed this:

- name: Create .env file
  template: src="env.j2"
            dest="{{ www_root }}/{{ item.key }}/current/.env"
            owner="{{ web_user }}"
            group="{{ web_group }}"
  with_dict: wordpress_sites

To this:

- name: Create .env file
  template: src="env.j2"
            dest="../.env.temp"
            owner="{{ web_user }}"
            group="{{ web_group }}"
  with_dict: wordpress_sites

- name: Move .env file
  command: mv "../.env.temp" "{{ www_root }}/{{ item.key }}/current/.env"
  with_dict: wordpress_sites

Now provisioning completes and I can view my theme/site in my host machine browser. I do wonder if this method is similar to what others have employed?

1 Like

@fullyint how kind, thank you.

To be honest I have to work hard to make up for a lack of talent…

Yes I had employed vagrant destroy and verified versions.

Thank you for your help!

Craig

great work @Craig

A number of other tasks in bedrock-ansible use Ansible’s template module but apparently don’t exhibit the same problem for you. This problematic instance may differ from the others in that it it is manipulating a dotfile and declares the owner parameter. However, those characteristics were absent from the example you excerpted from the other thread, so they’re probably irrelevant.

1 Like

@fullyint Thank you.

While I haven’t had the time to fully dig into this workaround I feel that the other example I linked to is probably unrelated and so therefor it is possible that you are heading in the right direction.

Use /tmp/.env.temp rather than …/.env.temp

Edit: main.yml has now been updated to this , however I learned the hard way :stuck_out_tongue: