Skip to content
Snippets Groups Projects
Commit 11dfb6b5 authored by Chris Croome's avatar Chris Croome
Browse files

Playbook for updating the dev with the live data

parent 3e5e8010
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,15 @@ ...@@ -2,6 +2,15 @@
These Playbooks are designed to be used on Debian Stretch virtual servers. These Playbooks are designed to be used on Debian Stretch virtual servers.
## live2dev
Ansible playbook to update the [dev site](https://dev.coops.tech/) from the [live site](https://www.coops.tech/).
```bash
export SERVERNAME="webarch1.co.uk"
ansible-playbook live2dev.yml -i "${SERVERNAME}," -e "hostname=${SERVERNAME}"
```
## Discourse ## Discourse
Ansible Playbooks to install Ansible Playbooks to install
......
---
- name: Populate the dev site with the live data
hosts: "{{ hostname }}"
become: yes
roles:
- live2dev
vars:
distro: stretch
users:
- cotech
- cotechdev
# https://stackoverflow.com/a/10034368
<FilesMatch "\.(ico|gif|jpg|png)$">
ExpiresActive On
ExpiresDefault "access plus 11 month"
Header append Cache-Control "public"
</FilesMatch>
<FilesMatch "\.(css|js)$">
ExpiresActive On
ExpiresDefault "access plus 1 week"
Header append Cache-Control "public"
</FilesMatch>
# Redirect HTTP to HTTPS
# https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>
# STS Header
# https://stackoverflow.com/questions/24144552/how-to-set-hsts-header-from-htaccess-only-on-https
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
---
- name: Update script in place
template:
src: templates/update.j2
dest: "/home/{{ item }}/bin/update"
mode: 0755
owner: "{{ item }}"
group: "{{ item }}"
with_items: "{{ users }}"
- name: Git config in place
template:
src: templates/gitconfig.j2
dest: "/home/{{ item }}/.gitconfig"
mode: 0644
owner: "{{ item }}"
group: "{{ item }}"
with_items: "{{ users }}"
- name: .htaccess file in place
copy:
src: files/htaccess
dest: "/home/{{ item }}/sites/web/.htaccess"
mode: 0644
owner: "{{ item }}"
group: "{{ item }}"
with_items: "{{ users }}"
- name: ~/bin in PATH
lineinfile:
regexp: '^export\ PATH='
line: 'export PATH="$PATH:$HOME/bin"'
dest: "/home/{{ item }}/.bashrc"
state: present
with_items: "{{ users }}"
- name: Live database dumped
shell: "mysqldump cotech > /home/cotech/private/cotech.sql"
- name: Dev database overwritten with live data
shell: "cat /home/cotech/private/cotech.sql | mysql cotechdev"
- name: Live files rsynced to dev
command: "rsync -aq --chown=cotechdev:cotechdev --chmod=D2775,F0664 /home/cotech/sites/web/app/uploads/ /home/cotechdev/sites/web/app/uploads/"
[user]
name = CoTech
email = {{ item }}@{{ hostname }}
#!/bin/bash
if [[ "${USER}" != "{{ item }}" ]]; then
echo "This script should be run as {{ item }}, please sudo first"
echo "sudo -u {{ item }} -s /bin/bash"
echo "${0}"
exit
fi
cd /home/{{ item }}/sites
git stash
git pull
rm -rf web/wp
composer update
cd web/app/themes/coop-tech-oowp-theme
composer update
npm install
nodejs ./node_modules/gulp/bin/gulp.js
cd ../../..
wp core update-db
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment