Error deploying

Deploy with a single command: ./deploy.sh <environment> <domain> don’t work in my case only when I use ansible-playbook deploy.yml -e "site=dev.zitronenzauber.de env=staging" yes, that is not a big problem, I can type the full command, but I have then I have this message error after try to make my first deployment.

fatal: [46.101.174.179]: FAILED! => {"failed": true, "msg": "ERROR! The conditional check 'git_project.stat.exists and remote_origin_url.stdout != project_git_repo' failed. The error was: ERROR! error while evaluating conditional (git_project.stat.exists and remote_origin_url.stdout != project_git_repo): ERROR! ERROR! ERROR! 'dict object' has no attribute u'dev.zitronenzauber.de'\n\nThe error appears to have been in '/vagrant/roles/deploy/tasks/update.yml': line 17, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Update git remote URL\n  ^ here\n"}

When I run the server command is all ok http://dev.zitronenzauber.de/ I have the error 404 but I read here is because I didn’t realize a deploy yet.

@jdaquila Do you find any helpful threads when you search discourse for the error you received ('dict object' has no attribute)? I’m guessing this one may be most relevant to your situation:

This is certainly unexpected. What was the error message from the command using deploy.sh?

the error messge is -bash: ./deploy.sh: /bin/bash^M: bad interpreter: No such file or directory

When I google search that error :arrow_up: I’m almost certain any of the the first handful of search results will solve that issue. Try searching and see if it works for you.

Ok I fix my problem with the command ./deploy.sh the solution was delete the file and create the file again in linux paste the content form the original save again and works.

But I have the same error message when I want to deploy :frowning:

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

TASK [setup] *******************************************************************
ok: [46.101.174.179]

TASK [deploy : include] ********************************************************

TASK [deploy : include] ********************************************************
included: /vagrant/roles/deploy/tasks/initialize.yml for 46.101.174.179

TASK [deploy : include] ********************************************************

TASK [deploy : Initialize] *****************************************************
changed: [46.101.174.179]

TASK [deploy : include] ********************************************************

TASK [deploy : include] ********************************************************
included: /vagrant/roles/deploy/tasks/update.yml for 46.101.174.179

TASK [deploy : include] ********************************************************

TASK [deploy : Check whether project source path is a git repo] ****************
ok: [46.101.174.179]

TASK [deploy : Get current git remote URL] *************************************
skipping: [46.101.174.179]

TASK [deploy : Update git remote URL] ******************************************
fatal: [46.101.174.179]: FAILED! => {"failed": true, "msg": "ERROR! The conditional check     'git_project.stat.exists and remote_origin_url.stdout != project_git_repo' failed. The error was: ERROR! error while evaluating conditional (git_project.stat.exists and remote_origin_url.stdout != project_git_repo): ERROR! ERROR! ERROR! 'dict object' has no attribute u'zitronenzauber.de'\n\nThe error appears to have been in '/vagrant/roles/deploy/tasks/update.yml': line 17, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Update git remote URL\n  ^ here\n"}

PLAY RECAP *********************************************************************
46.101.174.179             : ok=5    changed=1    unreachable=0    failed=1

I suggest you update your Trellis to the current version, or at least to c76089d of Jan 16, 2016 (see recent versions). This will offer a few benefits for you on Windows and will output a custom debug message for the error you’re reporting.

If you complete the above and still encounter the same error, please search discourse for “'dict object' has no attribute” because the many threads will help you understand the problem.

In addition, it appears you are probably using Ansible 2.0+. You may want to use v1.9.4 till Ansible updates the deploy_helper module. Follow along in roots/trellis#469.

Thx @fullyint I will try all yours subjection and let you know if I make that works for me.

1 Like

I fix that error I had, the problem was my file host was not correct setting

was like that

[web]
46.101.174.179

[development:children]
web

and I using dev, so when I update that to:

[web]
46.101.174.179

[dev:children]
web

Runs good until the DB

Now I have this message

TASK [deploy : include] ********************************************************
included: /vagrant/roles/deploy/hooks/finalize-after.yml for 46.101.174.179

TASK [deploy : WordPress Installed?] *******************************************
fatal: [46.101.174.179]: FAILED! => {"changed": false, "cmd": ["wp", "core", "is-installed"], "delta": "0:00:00.165723", "end": "2016-01-21 09:23:36.840057", "failed": true, "failed_when_result": true, "rc": 1, "start": "2016-01-21 09:23:36.674334", "stderr": "Error: Error establishing a database connection", "stdout": "", "stdout_lines": [], "warnings": []}

PLAY RECAP *********************************************************************
46.101.174.179             : ok=26   changed=10   unreachable=0    failed=1

How I change the version of Snsible 2.0 to 1.9.4 ?

I fix my issues I made my first deploy no error, but when I go to check the site I see the wp installation

http://dev.zitronenzauber.de/wp/wp-admin/install.php

Congratulations!

Alternatively you could perform the install using wp-cli, or set up some automated install script of your own.

Subsequent deploys of this site won’t require the install step, of course, because the site will already be installed.

Sorry but all wrong now :frowning: feel total frustrating now.

I try to make a clean install in my droplet with the same configuration I change nothing.

1- make vagrant destroy and up in my local.
2- run ansible-playbook server.yml -e env=dev
First Error try to login with admin so I run ansible-playbook -i hosts/dev server.yml and then comes this error

TASK [mariadb : Set root user password] ****************************************
failed: [46.101.174.179] => (item=46.101.174.179) => {"failed": true, "item": "46.101.174.179", "msg": "unable to   connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials. Exception message: (1045, \"Access denied for user 'root'@'localhost' (using password: YES)\")"}
failed: [46.101.174.179] => (item=127.0.0.1) => {"failed": true, "item": "127.0.0.1", "msg": "unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials. Exception message: (1045, \"Access denied for user 'root'@'localhost' (using password: YES)\")"}
failed: [46.101.174.179] => (item=::1) => {"failed": true, "item": "::1", "msg": "unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials. Exception message: (1045, \"Access denied for user 'root'@'localhost' (using password: YES)\")"}
failed: [46.101.174.179] => (item=localhost) => {"failed": true, "item": "localhost", "msg": "unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials. Exception message: (1045, \"Access denied for user 'root'@'localhost' (using password: YES)\")"}

PLAY RECAP *********************************************************************
46.101.174.179             : ok=36   changed=1    unreachable=0    failed=1

I don’t know why what I’m doing wrong I almost have it.

How can do all the installation in the server from 0

here is my dev/wordpress_sites.yml

# Documentation: https://roots.io/trellis/docs/remote-server-setup/
wordpress_sites:
  zitronenzauber.de:
site_hosts:
  - dev.zitronenzauber.de
local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
repo: git@github.com:MenschDankeGmbH/md-zitronenzauber-trellis.git
branch: master
subtree_path: site # relative path to your Bedrock/WP directory in your repo (above) if it is not the root (like the roots-example-project structure)
multisite:
  enabled: false
  subdomains: false
ssl:
  enabled: false
cache:
  enabled: false
  duration: 30s
env:
  disable_wp_cron: true
  wp_home: http://dev.zitronenzauber.de
  wp_siteurl: http://dev.zitronenzauber.de/wp
  wp_env: dev
  db_name: dev_zitronenzauber
  db_user: root
  db_password: root
  # Generate your keys here: https://api.wordpress.org/secret-key/1.1/salt/
  # These CANNOT contain the characters "{%" in succession
  auth_key: 'twq|YKjS2r8x%okAj|=.C)oazsIy-v4P+2.Hga(XCh6O,-BR,U<G^NDOy f-wd{c'
  secure_auth_key: ':sme:FQ@>H@G|;~sF4[I|6aLCXDZh|pgy3>g<,f7p}RYjCGvK08M2x++(SlfW`S0'
  logged_in_key: 'MhftN;(Y8YGa_&~KdU-/,Xa)+X+e,?FiSED5%+,M+h|3Ty`5USCuu%dqG, p+QK_'
  nonce_key: '_v(z5z&]B MQ[3F!md_BeWMmSzU>+Q*:yhHYD`oh-A&d)68yVce^`ON~CUBQa~^='
  auth_salt: '^8/fJb=?dK+w+ ^ruk!l40dj|VC*+P|/GmC+F+1mV7Ca-c;.%(x]wt+F>xt/oM/U'
  secure_auth_salt: '!,fVVxr/GQ2Ir(PpU]~ze_HS&k(:]<I%)P#^],{<}}sMY5qOX+8tH_-h+RPL(L]|'
  logged_in_salt: 'G[vOHI$|Uj$>**z!N2^}}&[eVtOc{&sD4.>OgEK;E6y]r+!$%sz_(af5gCBQ/-mJ'
  nonce_salt: 'T<Bg<]bN)jd~4v4y`=dIR;B|]qJ/Ovn$uT}*6MVf{Hvou5a-4z4@5ky!QEvGyt,d'

all/users.yml

# Documentation: https://roots.io/trellis/docs/ssh-keys/
admin_user: admin

users:
 - name: "{{ web_user }}"
 groups:
  - "{{ web_group }}"
keys:
  - "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
  # - https://github.com/username.keys
- name: "{{ admin_user }}"
groups:
  - sudo
keys:
  - "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
  # - https://github.com/username.keys

web_user: web
web_group: www-data
web_sudoers:
 - "/usr/sbin/service hhvm *"
 - "/usr/sbin/service php5-fpm *"

hosts/dev

[web]
46.101.174.179

[dev:children]
web

I also don’t know how to install ansible 1.9.4 maybe becouse of that I have some many issues or better I’m to stupid for this, don’t know

I change my user password also from root to a new one try to run all from the beginning and happen the same the process die when TASK [mariadb : Set root user password] .

I look in my droplet and there not db on the server so I have not idea how can I setup all my server from 0 in my droplet

Hi @fullyint Good news, I setup all from 0 again and good results.
The best solution was change the version of asible to 1.9.4 and works perfect.

Now I have again the WP setup page, I see the link you sent me before but I have some question if you can help me with.

My idea is to work with bedrock and sage, so what is the best way to do it, there is a doc where I can read about it.

I read https://github.com/roots/roots-example-project.com where explain how setup sage/theme.
That part is clear and I can o it without problem, but then how is with the server?

I have to run a server.yml again or commit to github and then make a deploy?

if I have to make a deploy first I need to have the setup done from WP?

Thanks!

@jdaquila Great job!!!

Just a side note that I suspect may clarify some things:

  • dev: dev.yml will provision your vm and install WordPress
  • stag/prod: server.yml provisions server generally, deploy.yml deploys specific website.

The point I want to make is that it is very unlikely you would use either server.yml or deploy.yml for dev, as I think you may have tried at one point.


Some resources – some you have seen already:
Sage README, Docs, book, screencast
Bedrock README, Docs, screencast
Trellis README, Docs, blog post about deploying

Search discourse and google for your questions, error messages, etc. Most of the getting started issues have been covered. Searching may feel painstaking and slow, but you’ll actually be learning a lot in the process, even when it feels like you aren’t finding the specific answer you’re seeking. You’ve proven you can find the answers and figure things out, but if/when you’ve searched long and hard and are truly stuck, you’ll be able to describe the steps you’ve taken etc. and the discourse community will be more eager to help.


Below is a sparse overview of one possible process for using the Roots tools to build a WordPress site as a solo developer. I’m listing it to offer the general concepts. Any specifics are for you to work out using the resources listed above.

Dev

  • vagrant up to create vm
  • develop theme using vagrant vm (edit php, css, js, etc.)
  • run gulp [--production] to compile assets whenever desired. Assuming this vm is on your local machine, the synced folders will update the dev site in real time.

Staging or Production

  • commit the edits you’ve made to sage/bedrock/trellis to your remote repo so that when you have Trellis run deploy.yml, it can checkout/clone those updated source files from the remote repo.
  • because you’re on Windows, run gulp --production on your local machine instead of relying on Trellis to do it for you during deploy.yml
  • run server.yml to provision a remote server
  • set up Trellis to sync your compiled assets to your server using the example build-before.yml file (see notes below; see docs about deploy hooks).
  • run deploy.yml to deploy your site

Keep iterating

  • on dev vm, continue editing as desired and run gulp to compile
  • commit changes to remote repo as desired
  • use deploy.yml to have Trellis deploy your remote repo’s changes to your site/server and to sync your compiled assets (dist) to your site/server. You don’t need to re-run server.yml if you’ve only changed your site/theme files.
  • on the rare occasion you need to update the config to your server (perhaps to update to latest Trellis configs), run server.yml

Using build-before.yml as a Windows user, you’ll probably want to run npm, bower, and gulp commands manually on your Windows machine (vs. having Trellis run these commands). Then you can have Trellis sync to your server the compiled assets (stuff gulp builds into your sage dist folder).

To achieve this sync, you’ll probably want to uncomment and use the single task below, making the one change for Trellis to know where to find the files on your vm.

 - name: Copy project local files
   synchronize:
-    src: "{{ project.local_path }}/web/app/themes/sage/dist"
+    src: "{{ project_root }}/current/web/app/themes/sage/dist"
     dest: "{{ deploy_helper.new_release_path }}/web/app/themes/sage"
     group: no
     owner: no
     rsync_opts: --chmod=Du=rwx,--chmod=Dg=rx,--chmod=Do=rx,--chmod=Fu=rw,--chmod=Fg=r,--chmod=Fo=r

Keep an eye on ansible_local coming soon to Trellis, which should simplify some of your steps on Windows.

1 Like

Thank you very much for the help, I will have a look to all the link and now the process is much more clear for me, now I’m trying to see what is the best way to work with databases to upload and download from the server and change the wp-option, but really exiting to work with this system :grinning:

1 Like

I making some commits and deploy and works all good :slightly_smiling:

I install sage and rund the command in windows then I commit and make a deploy to server I activate sage but was with out style.

Then I can see in sage folder the gitignore, that is how looks that is ok or I have to comment dist so then I can use the deploy hook you show me?

articles/ignoring-files
dist
bower_components
node_modules
npm-debug.log