Deploy Clone Project Files dictionary error

I have just created my DO droplet and tried deploying my first roots site. This is the error I’m receiving, and I’m not sure what errors in my config would cause this.

I run ansible-playbook -vvvv deploy.yml -i hosts/production --extra-vars="site=salonvoandspa.com" and everything works up to the following task:

TASK: [deploy | Clone project files] ******************************************
<45.55.227.142> ESTABLISH CONNECTION FOR USER: root
fatal: [45.55.227.142] => One or more undefined variables: 'dict object' has no attribute u'salonvoandspa.com'

For reference, my project repo is on bitbucket, and I have added the DigitalOcean droplet’s public ssh key to the Bitbucket repo as a deployment key.

@jwkicklighter The dict object (“dictionary”) in the error message is wordpress_sites and the attribute it is looking for is the site header in that list. Could you check that salonvoandspa.com is the site name header in your wordpress_sites list? If you have a different header name there, use that name in your deploy command:

./deploy production siteheader

or

ansible-playbook deploy.yml -i hosts/production --extra-vars="site=siteheader"

Also consider this note about ssh keys with bitbucket. Trellis is set up to connect to Bitbucket using your local machine’s ssh key pair instead of the DO droplet’s keypair, so Bitbucket should have your local machine’s public ssh key. The purpose of this “ssh agent forwarding” setup is so that you don’t have to add extra deploy keys to your private repo – Trellis will just forward your regular ssh agent info through your droplet to Bitbucket to make the connection.

I would also recommend changing your web_user back to web or something other than root (then rerun server.yml and deploy.yml). Otherwise you will probably run into the Error: YIKES! It looks like you're running this as root described here. If you run into trouble after changing web_user back, there’s some chance that you’ll need to destroy/rebuild the droplet and rerun with web_user: web. I haven’t tested, but I suspect it’s possible that running everything once with web_user: root could cause permissions/ownership issues that might not resolve with just rerunning with web_user: web.

1 Like

I had completely missed my site header, that fixed the error! However, I’m now getting a new error at a later step:

TASK: [deploy | Run post_build_commands in the new_release_path] **************
failed: [45.55.227.142] => (item={‘cmd’: ‘composer install --no-ansi --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts’}) => {“cmd”: “composer install --no-ansi --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts”, “failed”: true, “item”: {“cmd”: “composer install --no-ansi --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts”}, “rc”: 2}
msg: [Errno 2] No such file or directory

As far as changing from root back to web, the only reason I am using root is because it appears that I cannot ssh into the droplet without using the root user. It always fails at the first step. Any suggestions there?

I can’t remember off the top of my head, but this might be one of two things:

1. Check on your usage/non-usage/value of repo_subtree_path. I’m not sure which version of Trellis you are using, so note that the subtree variable was renamed subtree_path on Sep 6, 2015, then repo_subtree_path on Dec 29, 2015. You could find more info by searching subtree in discourse and docs.

2. Double-check that you have committed your updated composer files to the repo that is cloned during deploy, like Downgrade WP when deploy - #6 by swalkinshaw.

Try changing web_user: web, running server.yml, then testing ssh web@45.55.227.142. When you run server.yml its users role adds these users to the server, so you and ansible can then ssh as admin and web. If that doesn’t work, then there is more debugging to do, and I’d start with this (even though it shouldn’t be directly related to issue of whether web can make an ssh connection):

1 Like

I completely missed the server.yml step before, so that was likely part of my problem. I had uncommented the subtree line before, but hadn’t committed and pushed yet. After taking care of the things you suggested, it seems to have worked!

I did have to rebuild the droplet and run server.yml like you suggested And for the sake of completeness, that changed the SSH fingerprint of the droplet and required me to delete the server from ~/.ssh/known_hosts (this error wasn’t obvious, as ansible was giving the same error as I originally posted… Didn’t see the fingerprint error until trying to SSH into the droplet myself).

Thanks for the help, I’ll remember all of this for future Roots projects.

On a separate note, it doesn’t appear that bower dependencies were installed for my custom theme. Is there something that I needed to do to make that happen?

Nice job sorting it out!

Trellis intentionally allows flexibility in how you get your compiled theme files on the remote server (i.e., dist files that aren’t committed to your repo). The recommended approach is to use custom tasks hooked into the deploy_build_before hook. All you need to do is uncomment the build-before tasks which will ensure your bower components are up-to-date locally then sync them to your remote server.

Related: Build Steps and Deployment from @austin.

1 Like

So I actually found this right after posting my last response, however I’m using Trellis 0.9.1 which was before the custom tasks seem to have been standardized this way (there is no sample build-before task to use). I tried copying that file and uncommenting, and then adding the deploy_build_before variable to deploy.yml, but ansible seems to just ignore it.

My project consists of Trellis, Bedrock, and Sage all in one repo as is advised to do (I removed their individual .git folders when first cloning them), so I cannot figure out a way to update Trellis without losing all of my config. I read about using a separate remote for Trellis and having git target a subdirectory of the main repo, then cherry-picking commits to avoid conflicts, but I can’t seem to get that to work.

Is there any other advised way to update Trellis without losing the configs I have? There are a lot of commits between 0.9.1 and current for me to have to manually diff myself.

Also, thank you for all the help. You’ve been incredibly beneficial to this new guy!

Looks like Trellis 0.9.1 was released Aug 18, 2015. Here is how these tasks were handled in the roots-example-project as of Aug 21, 2015:

As for updating Trellis when it is combined with bedrock, etc., I’m guessing you’ve read this thread. Admittedly it is a more complex–or at least less common–process than updating a project with only one upstream (e.g., Trellis alone).

If you decide to enlist support on this latter topic, consider reading up on git projects with multiple remotes, then perhaps adding to the thread mentioned above, or starting a new thread on the topic, or maybe starting a thread over at stackoverflow given that it is more of a git question than a Roots question. Or go nuts, figure it all out, write some beautiful docs and PR the trellis docs. :slightly_smiling:

Unfortunately at the moment this is the only way other than doing it manually. You could possibly compare folders and see all changes at once.

Why doesn’t the cherry picking work though?

@fullyint That solution totally worked, how did you find the documentation as of a specific date? That’s the one thing I couldn’t figure out to try and find a solution myself. Also yes, that’s one thread I checked out. I may attempt that later, but this solution seems to be working well for the time being.

@kalenjohnson I don’t remember exactly what it was, but I got some error (before the actual cherry picking) involved with trying to tell git to sync the trellis branch with the trellis subdirectory. I may try and figure that out later.

On a different note, it seems like the imagemin task is bombing on me. I had to comment out the following lines in order to get gulp --production to complete.

.pipe(imagemin({
progressive: true,
interlaced: true,
svgoPlugins: [{removeUnknownsAndDefaults: false}, {cleanupIDs: false}]
}))

I can look for more on this myself, just wanted to see if it was a known issue you guys were aware of.

Let’s try to keep this thread to the current topic, please

Looking at the list of commits for the project, I clicked the <> button on the far right of the commit with the desired date (hover over the button and the tooltip says “browse repository at this point in the history”). There are probably other ways too.