I got the error at the end of deploy. This is the terminal ouput tail. I have checked again and again group_vars/production/wordpress_sites.yml
and I canât find what I am doing wrong.
TASK: [wordpress-setup | Create database of sites] ****************************
fatal: [abralaboca.net] => One or more undefined variables: 'str object' has no attribute 'env'
PLAY RECAP ********************************************************************
to retry, use: --limit @/Users/aitor/server.retry
abralaboca.net : ok=75 changed=2 unreachable=1 failed=0
Does your group_vars/production/wordpress_sites.yml file have this .env section? It should.
If the .env section is present, I suspect there is a yaml formatting problem. You could paste your entire group_vars/production/wordpress_sites.yml file here for us to inspect. Please edit out sensitive info like passwords before you submit your reply.
Try removing the line with admin_password and rerunning server.yml.
The admin_password variable appears only in the development wordpress_sites, not in staging or production wordpress_sites. Looks like the README does mention âdevelopment onlyâ for admin_password, but that would be easy to miss.
No need to understand the rest of this, but the error 'str object' has no attribute 'env' occurred when âCreate database of sitesâ looped over the hierarchically topmost elements of wordpress_sites: admin_password and abralaboca.net. The element admin_password doesnât have the env subelement called for.
The element admin_password should not appear in this list, especially not at this level (hierarchically). The only other element at this level would be another-site.com, and it would have all the subelements like you have for abralaboca.net. You would use that if you wanted your one server to serve two sites (or more).
Let us know if that resolves the issue. If something else comes up, feel free to open a separate issue.
Re: your 404, you probably just need to deploy the site now. Trellis runs dev.yml on the Vagrant VM, which includes the wordpress-install role. For staging and production, server.yml doesnât include this role.
Try running ./deploy.sh production abralaboca.net and then navigate to abralaboca.net in your browser. You should then see the wordpress install screen.
If that fails, debug for a bit and post a new issue if youâd like extra help.
One final question. I have Sage theme at dev environment, I can see it at abralaboca.dev when I do vagrant up, but Sage is not present at remote server. why?
Vagrant is probably syncing your theme between your host machine and the vm, so the dev site/server sees the theme files.
Youâll need to find a way to get your theme on the remote production server. For ideas, see this post addressing the question of âWhat approach are you taking to deploying your theme?â
Great! Your steps appear correct as I glance over them, although I didnât compare step-by-step with the README or with the docs.
One thing youâll probably need to address, if you havenât already, is how to get your themeâs compiled assets on the server. The dist directory typically wouldnât be committed to your repo and thus wouldnât be retrieved when the deploy clones the repo.
The recommended approach is to compile the assets on your local machine (gulp --production) then have the deploy sync the dist directory to your remote server. As @swalkinshaw recommended here, add this line to your deploy.yml:
Then create a deploy-hooks directory in your ansible directory, with a build-before.yml file that has contents similar to what @swalkinshaw listed at the link above. Decide which tasks to include. At a minimum, I think youâd want the last task - name: Copy project local files. Youâll want to adjust the paths for your theme name, etc.
Thatâs a little complex but charge through it and I think youâll continue understanding it as well as youâve done with the other steps before this.