Skip to content

Instantly share code, notes, and snippets.

@mlutfy
Created December 7, 2018 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlutfy/6441b6db192528d7b22e823f3e30329c to your computer and use it in GitHub Desktop.
Save mlutfy/6441b6db192528d7b22e823f3e30329c to your computer and use it in GitHub Desktop.
Ansible role for batch migrating sites with hosting_remote_import
---
# server_XXXX is the remote server
# server_YYYY is the database server
# platform_civicrm is the alias for my platform
# The names can be found by going in the Aegir front-end, in the URL alias, or from ~/.drush/server[...].
- name: Run Aegir's remote-import
shell: "drush --backend=2 @server_XXXX provision-remote_import --old_url={{ inventory_hostname }} --new_url={{ inventory_hostname }} --platform=platform_civicrm --db_server=server_YYYY"
delegate_to: localhost
tags:
- aegir-remote-import-site
# You probably don't need to do this
# I just wanted the front-end to reflect the actual install profile that was initially used
- name: Fix the install profile of the sites
shell: "echo 'update hosting_site set profile=241 where platform=160 and profile=62' | drush @hm sqlc"
delegate_to: localhost
tags:
- aegir-remote-import-cleanup
- name: Get the node ID of the site
shell: "echo \"select node.nid from node left join hosting_site s on (s.nid = node.nid) where title = '{{ inventory_hostname }}' and s.status != -1;\" | drush @hm sqlc | grep -v nid"
register: nid
delegate_to: localhost
tags:
- aegir-remote-import-cleanup
# There should be a better way of doing this? provision-enable didn't work.
- name: Enable the site in Aegir
shell: "echo \"update hosting_site set status = 1 where nid = {{ nid.stdout }}\" | drush @hm sqlc"
delegate_to: localhost
tags:
- aegir-remote-import-cleanup
# Legacy: this server is still using hosting_ssl with a wildcard ssl cert.
- name: Enable https for the site in Aegir
shell: "echo \"update hosting_ssl_site set ssl_enabled = 2, ssl_key = 1 WHERE nid = {{ nid.stdout }}\" | drush @hm sqlc"
delegate_to: localhost
tags:
- aegir-remote-import-cleanup
- name: Run verify on the site
shell: "drush @{{ inventory_hostname }} provision-verify"
delegate_to: localhost
tags:
- aegir-remote-import-cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment