Closed grahamharper closed 7 years ago
My apologies, never mind, I misunderstood the instructions about the hosts configuration.
Hi @grahamharper could you tell what did you misunderstood? I'm having the same problem and can't get it working…
@BrunoFenzl if I remember correctly, I think I appended the example hosts config to my existing hosts config, but what I needed to do was replace my existing hosts config with the example config (and of course modify your_server_hostname
).
@grahamharper Thanks for the quick reply! Well that's what I have… my staging host file looks like:
staging_host ansible_host=SERVER_IP
[staging]
staging_host
[web]
staging_host
and development host file:
# This file is only used for Windows hosts.
#
# Windows
# -------------------------------------------------------------
# If you want to run `dev.yml` manually you can SSH into the VM
# to the directory with the `dev.yml` playbook and run:
# `ansible-playbook dev.yml`
#
# Non-Windows
# -------------------------------------------------------------
# If you want to run `dev.yml` manually via the `ansible-playbook`
# command (vs. `vagrant up` or `vagrant provision`), you might be
# inclined to define your development host information in this file.
# We recommend instead that you use the `-i` (inventory) option with
# your `ansible-playbook` command to specify the custom inventory file
# Vagrant has created for the VM. Vagrant's custom inventory
# includes necessary non-standard SSH connection information.
#
# Here is an example command:
#
# `ansible-playbook dev.yml -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory`
#
# The `.vagrant` directory above is usually in the same directory as
# your `Vagrantfile`. If not, you will need to adjust this path in the
# command.
#
# Why run `dev.yml` manually?
# -------------------------------------------------------------
# One reason you may want to run `dev.yml` via the `ansible-playbook`
# command is for the convenience of adding Ansible options via the
# command line (e.g., `--tags`, `--skip-tags`, or `-vvvv`). In contrast,
# the commands `vagrant up` and `vagrant provision` would only run the
# `dev.yml` playbook with such options if you were edit the options
# into the Vagrantfile's `config.vm.provision` section.
development_host ansible_host=192.168.50.5 ansible_connection=ssh ansible_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/default/virtualbox/private_key ansible_ssh_extra_args="-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null"
[development]
192.168.50.5 ansible_connection=local
[web]
192.168.50.5 ansible_connection=local
Just in case, I'm running trellis 1.0.0-rc.2, Ansible 2.5.3 and macOS 10.13.4. Any hint?
@grahamharper is the opposite of what you wrote. I had to append the configurations to my host files. Now everything works fine. Thanks again for the input!
Now my staging host file looks like:
# Add each host to the [staging] group and to a "type" group such as [web] or [db].
# List each machine only once per [group], even if it will host multiple sites.
[staging]
IP_ADDRESS
[web]
IP_ADDRESS
staging_host ansible_host=IP_ADDRESS
[staging]
staging_host
[web]
staging_host
@valentinocossar Is it supposed to be this way? Thanks for the tool btw!
Ok, maybe that was it, sorry it's been so long.
Hi, the right way is to replace the content of each host file with those available in the README. But I've never tested the tool with Ansible 2.5.3. Maybe with Ansible >= 2.5.0 I'll have to update the tool to improve compatibility.
Could be a good idea adding somewhere in the README a notice like "Tested up to Ansible 2.X.X".
ansible 2.4.3.0 While trying to database push I get this error with both the append and replace method of editing the hosts file.
TASK [Search for {{ url_from }} and replace with {{ url_to }} on development] ***********************
System info:
Ansible 2.4.3.0; Darwin
Trellis version (per changelog): "Enable `fastcgi_cache_background_update` by default"
---------------------------------------------------
The task includes an option with an undefined variable. The error was: {{
hostvars.development_host.wordpress_sites[site].site_hosts.0.canonical }}:
'dict object' has no attribute 'wordpress_sites'
The error appears to have been in
'/myfolder/database-push.yml': line 89,
column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Search for {{ url_from }} and replace with {{ url_to }} on
development
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
exception type: <class 'ansible.errors.AnsibleUndefinedVariable'>
exception: {{
hostvars.development_host.wordpress_sites[site].site_hosts.0.canonical }}:
'dict object' has no attribute 'wordpress_sites'
fatal: [production_host]: FAILED! => {}
to retry, use: --limit @/myfolder/database-push.retry
PLAY RECAP ******************************************************************************************
production_host : ok=11 changed=8 unreachable=0 failed=1
Hi, Trellis version?
@valentinocossar using the latest Trellis version from the master branch. When i commented that was including the June 3rd commit in Trellis (commit # e140c05e18db87bce01d92bd1433c17e415adac3). There's been one more commit since then
Followed the instructions and recommendations in this repo's readme. Really not sure why it's not working. Uploads works fine though.
Using OSX
I've just tested it out with Ansible 2.4.3.0 and the latest Trellis version (from branch master) and works as expected. Could you show me the hosts files (with obviously a fake IP) and the wordpress_sites files (without sensitive information)? Thanks!
Thanks for testing, Valentinocaossar. Here is a gist of the files (with redacted sensitive info) from my server which produces the error: https://gist.github.com/eriteric/85f2820892edb9024984916ae4ae2063
I've tried this with a fresh copy of both trellis and this repo, and it worked too.
I then added in my customizations one by one, provisioned both dev and prod and then attempted to run ./bin/database.sh at each step.
The trellis that produces the error has 4 websites as you'll see in the gist. Aside from that I only know of one more variable to try, and that's adding the Typisttech/trellis-cloudflare-origin-ca trellis add-on & turn on SSL on production. However I can't try that right now on the domain I'm testing with as it's in use, but i will be able to in the next few days.
I'm hoping there is something I'm just not seeing in my wordpress_sites files.
edit: Thought of another variable... I did provision the working server once before making the changes for trellis-database-uploads-migration. On the server that gives the error I provisioned with trellis-database-uploads-migration added from the start.
Ok I started another server. And DB sync was working up until the point I added the cloudflare origin certificate trellis add-on. Any ideas as to why that would interfere?
Any progress on this? I am using Ansible 2.5.3, the Cloudflare Origin Certificate Trellis addon, and get an error...
My wordpress_sites file:
example.com:
site_hosts:
- canonical: example.com
redirects:
- www.example.com
local_path: ../bedrock # path targeting local Bedrock site directory (relative to Ansible root)
repo: git@bitbucket.org:xxxxxx/example.com.git # replace with your Git repo URL
# repo_subtree_path: '.' # relative path to your Bedrock/WP directory in your repo
branch: master
multisite:
enabled: false
ssl:
enabled: true
stapling_enabled: false
provider: cloudflare-origin-ca
cache:
enabled: true
I issue the command:
`./bin/database.sh production example.com backup`
I get the following error:
The task includes an option with an undefined variable. The error was:
'unicode object' has no attribute 'wordpress_sites'
The error appears to have been in '/../../../trellis/database-backup.yml': line 48, column 7, but
may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Pull exported database from {{ env }} to development
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
fatal: [xx.xx.xx.xx]: FAILED! => {}
Hi, maybe could be an issue related to the hosts configuration? See #6.
Any progress on this? I am using Ansible 2.5.3, the Cloudflare Origin Certificate Trellis addon, and get an error...
My wordpress_sites file:
example.com: site_hosts: - canonical: example.com redirects: - www.example.com local_path: ../bedrock # path targeting local Bedrock site directory (relative to Ansible root) repo: git@bitbucket.org:xxxxxx/example.com.git # replace with your Git repo URL # repo_subtree_path: '.' # relative path to your Bedrock/WP directory in your repo branch: master multisite: enabled: false ssl: enabled: true stapling_enabled: false provider: cloudflare-origin-ca cache: enabled: true
I issue the command:
`./bin/database.sh production example.com backup`
I get the following error:
The task includes an option with an undefined variable. The error was: 'unicode object' has no attribute 'wordpress_sites' The error appears to have been in '/../../../trellis/database-backup.yml': line 48, column 7, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - name: Pull exported database from {{ env }} to development ^ here We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance: with_items: - {{ foo }} Should be written as: with_items: - "{{ foo }}" fatal: [xx.xx.xx.xx]: FAILED! => {}
I never solved it. I ended up just using WP-CLI aliases to push & pull the database, but still use the uploads script. You can pull to your local in one command by using the pipe operator. like:
wp @prod db export - | wp @dev db import - && wp @dev search-replace 'prodsite.com' 'devsite.test' --skip-columns=GUID
Thanks, @eriteric that looks much simpler..!
First, thanks for creating this project, I've been looking for something like this.
I followed the installation instructions and ran
./bin/database.sh production <my_site_name> pull
but I'm getting this error:I'm on macOS 10.12.3 and using Trellis 1.0.0-rc1.