Roots Discourse

Deploy bedrock from windows to Digital Ocean with ansible

Hi!

I have been working to make bedrock-ansible, bedrock, sage working in the past 4 days. Im almost in the finish, but I have some problems with deploying to production server.

I dont really know from where should I run the deploy script. Should I run it from vagrant box or from windows console?

When I’m trying to run the command from windows (babun cygwin) im getting this error:

{ ansible } master » ./deploy.sh hosts/production blog.mysite.co.uk
: invalid shell option name nullglob
./deploy.sh: line 3: $'\r': command not found
./deploy.sh: line 8: $'\r': command not found
./deploy.sh: line 9: syntax error near unexpected token `$'{\r''
'/deploy.sh: line 9: `show_usage() {

… than i tried to run the playbook command directly:

{ ansible } master » ansible-playbook -i hosts/production deploy.yml --extra-vars="site=blog.mysite.co.uk" -vvvv

PLAY [Deploy WP site] *********************************************************

GATHERING FACTS ***************************************************************
<blog.mysite.smarter.uk.com> ESTABLISH CONNECTION FOR USER: web
<blog.mysite.smarter.uk.com> REMOTE_MODULE setup
<blog.mysite.smarter.uk.com> EXEC ssh -C -tt -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/ROBI/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=web -o ConnectTimeout=10 blog.mysite.smarter.uk.com /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1433972511.14-229562164514219 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1433972511.14-229562164514219 && echo $HOME/.ansible/tmp/ansible-tmp-1433972511.14-229562164514219'
fatal: [blog.mysite.uk.com] => SSH Error: Permission denied (publickey,password).
	while connecting to 46.101.38.193:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

The ssh is working correctly I can easily ssh web@blog.mysite.co.uk in. If I run the ssh command directly the problem is different. The ControlPath="/home/ROBI/.ansible/ not found. And yes its not there.

When I tried to run the deploy script from vagrant than I got into the executables problem than many others reported already.

My question after this: Is it possible to depkoy sites with ansible from windows? If yes, what am I doing wrong?

Thank you!

Robert

On Windows, Ansible is installed to the VM, and the VM basically provisions itself (as opposed to an OS X or Linux host, where Ansible is installed on the host machine and provision the VM).

In order to keep instructions the same, it’s expected on Windows to SSH into the box and run the same commands to deploy as are in the README.

What “executables problem” are you experiencing?

And sorry to say, although I set up the provisioning for Windows, I have not tested it much deploying, although since it is an Ubuntu VM, and I run Ubuntu as my host, it should work without much issue. But perhaps someone who has deployed via the VM on Windows could chime in.

1 Like
vagrant@blog:/vagrant/ansible$ ansible-playbook -i hosts/production deploy.yml --extra-vars="site=blog.mysite.co.uk" -vvvv
ERROR: The file hosts/production is marked as executable, but failed to execute correctly. If this is not supposed to be an executable script, correct this with `chmod -x hosts/production`.
vagrant@blog:/vagrant/ansible$

I was trying to solve this issue but any of the solution failed for me. And we have an issue still open:
https://github.com/ansible/ansible/issues/10068

Ah I see, yes that is an issue. I wouldn’t call it a final solution, but you could copy the project to another folder in the VM that is not a shared directory, that should allow you to remove the executable flag and be able to deploy.

The other somewhat clunky workaround someone suggested is mounting the project twice, once with no executable files, and deploy from that.

Hopefully they figure something out in the Ansible project, as mounting folders as a Windows host is somewhat limited, but pretty common.

1 Like

Thanks copy the files and chmod -x ansible/hosts/production helped.
Now im getting a different error. Maybe its because of my DO setup. I didn’t find any specific about what should I set up on DO, so currently I have a simple clean install.

The error message:

vagrant@blog:~/blog.mysite.co.uk/ansible$ ansible-playbook -i hosts/production
 deploy.yml --extra-vars="site=blog.mysite.co.uk"

PLAY [Deploy WP site] *********************************************************


GATHERING FACTS ***************************************************************

ok: [blog.mysite.uk.com]

TASK: [deploy | Initialize] ***************************************************

failed: [blog.mysite.uk.com] => {"failed": true, "parsed": false}
Traceback (most recent call last):
  File "/home/web/.ansible/tmp/ansible-tmp-1434106906.51-187844715946739/deploy_
helper", line 2015, in <module>
    main()
  File "/home/web/.ansible/tmp/ansible-tmp-1434106906.51-187844715946739/deploy_
helper", line 382, in main
    changes += deploy_helper.create_path(facts['project_path'])
  File "/home/web/.ansible/tmp/ansible-tmp-1434106906.51-187844715946739/deploy_
helper", line 276, in create_path
    os.makedirs(path)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/srv/www'
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 2
Shared connection to blog.mysite.uk.com closed.


FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************

           to retry, use: --limit @/home/vagrant/deploy.retry

blog.mysite.uk.com : ok=1    changed=0    unreachable=0    failed=1

Hey, I was just searching the forums for an error I am receiving from WSL and I found this post.

The error I am getting is:
invalid shell option nameopt: nullglob

This happens when I run:
./bin/deploy.sh staging sitename.com

But not when I run:
ansible-playbook deploy.yml -e "site=sitename.com env=staging"

Another site I deploy with WSL works fine using both commands and I have checked the .deploy.sh files - They are exactly the same.