- name: Make a database dump to /tmp just in case
  mysql_db:
    state: dump
    login_host: "{{ db_host}}"
    name: "{{ db_name }}"
    target: "{{ db_backup }}"

- name: Run database migrations
  django_manage:
    command: migrate
    app_path: "{{ deploy }}"
    virtualenv: "{{ deploy }}/env"
- name: check for old symlink
  stat:
    path: "/var/www/{{ symlink }}"
  register: sym
- name: Copy old symlink path from /var/www to "{{ install_root }}/old"
  file:
    src: /var/www/{{ symlink }}
    dest: "{{ install_root }}/old"
    state: link
  when: sym.stat.islnk is defined and sym.stat.islnk == True
- name: New symlink path
  file:
    src: "{{ deploy }}"
    dest: "/var/www/{{ symlink }}"
    state: link
- name: Create courtesy symlink in /srv/www
  file:
    src: "{{ deploy }}"
    dest: "{{ install_root }}/current"
    state: link
- name: Restart Apache (scl-httpd24-httpd)
  command: "sudo systemctl restart httpd24-httpd"

- name: Run database migrations
  django_manage:
    command: migrate
    app_path: "{{ deploy }}"
    virtualenv: "{{ deploy }}/env"
- name: check for old symlink
  stat:
    path: "/var/www/{{ symlink }}"
  register: sym
- name: Copy old symlink path from /var/www to "{{ install_root }}/old"
  file:
    src: /var/www/{{ symlink }}
    dest: "{{ install_root }}/old"
    state: link
  when: sym.stat.islnk is defined and sym.stat.islnk == True
- name: New symlink path
  file:
    src: "{{ deploy }}"
    dest: "/var/www/{{ symlink }}"
    state: link
- name: Create courtesy symlink in /srv/www
  file:
    src: "{{ deploy }}"
    dest: "{{ install_root }}/current"
    state: link
- name: Restart Apache (scl-httpd24-httpd)
  command: "sudo systemctl restart httpd24-httpd"

Remove problematic database backup from deploy
Remove problematic database backup from deploy
