ZuluPro/myblog

View on GitHub
extras/ansible/roles/frontend/tasks/main.yml

Summary

Maintainability
Test Coverage
---
- include: ../../common/tasks/install_nginx.yml
- include: ../../common/tasks/install_ssl_key.yml

# Sites
- name: Setup myblog Nginx configuration
  template: src=nginx-site.conf.j2 dest=/etc/nginx/sites-available/myblog.conf
  notify: reload nginx

- name: Enable myblog Nginx configuration
  file: src=/etc/nginx/sites-available/myblog.conf dest=/etc/nginx/sites-enabled/myblog.conf state=link
  notify: restart nginx

# Configuration
- name: Disable server_tokens
  lineinfile: dest=/etc/nginx/nginx.conf regexp=server_tokens
              line="        server_tokens off;" 
# Static
- name: Add robots.txt
  copy: src=robots.txt dest=/var/www/robots.txt mode=660 owner=www-data group=www-data

- name: Update static files
  command: rsync -e "ssh -o StrictHostKeyChecking=no" -acogtvz --modify-window=3600 --delete-after --force --no-motd --chown=www-data:www-data root@{{ item }}:{{ static_root }} /var/www/
  with_items: (groups.get('all', []) + groups.get('middleware', []))[0]
  register: update_static
  changed_when: "update_static.stdout.count('\n') > 4"