Consolidate tasks using loops.

This commit is contained in:
staticsafe 2014-05-07 19:01:11 +00:00
parent b473d55d1f
commit 6860ad0b70
1 changed files with 15 additions and 15 deletions

View File

@ -9,27 +9,27 @@
service: name=nginx enabled=yes service: name=nginx enabled=yes
- name: Stop nginx for now - name: Stop nginx for now
service: name=nginx state=stopped service: name=nginx state=stopped
- name: Clean out default vhost file in enabled dir - name: Make nginx related dirs
file: path=/etc/nginx/sites-enabled/default state=absent file: path={{ item }} state=directory
- name: Clean out default vhost file in available dir with_items:
file: path=/etc/nginx/sites-available/default state=absent - /etc/nginx/global
- name: Make global nginx conf directory - /srv/www/catch-all
file: path=/etc/nginx/global state=directory - name: Clean out default vhost file in enabled and available dirs
- name: Copy our nginx.conf over file: path={{ item }} state=absent
copy: src=nginx.conf dest=/etc/nginx/nginx.conf backup=yes with_items:
- name: Copy our default catch-all vhost over - /etc/nginx/sites-enabled/default
copy: src=0-catch-all dest=/etc/nginx/sites-available/0-catch-all - /etc/nginx/sites-available/default
- name: Symlink the default catch-all vhost - name: Copy over all nginx configuration files
file: src=/etc/nginx/sites-available/0-catch-all dest=/etc/nginx/sites-enabled/0-catch-all state=link
- name: Copy over global includes, make catchall dir, and start nginx
copy: src={{ item.name }} dest={{ item.dir }} copy: src={{ item.name }} dest={{ item.dir }}
with_items: with_items:
- { name: 'nginx.conf', dir: '/etc/nginx/nginx.conf' }
- { name: '0-catch-all', dir: '/etc/nginx/sites-available/0-catch-all' }
- { name: 'cloudflare.conf', dir: '/etc/nginx/global/cloudflare.conf' } - { name: 'cloudflare.conf', dir: '/etc/nginx/global/cloudflare.conf' }
- { name: 'php-generic.conf', dir: '/etc/nginx/global/php-generic.conf' } - { name: 'php-generic.conf', dir: '/etc/nginx/global/php-generic.conf' }
- { name: 'security-generic.conf', dir: '/etc/nginx/global/security-generic.conf' } - { name: 'security-generic.conf', dir: '/etc/nginx/global/security-generic.conf' }
- { name: 'wordpress-generic.conf', dir: '/etc/nginx/global/wordpress-generic.conf' } - { name: 'wordpress-generic.conf', dir: '/etc/nginx/global/wordpress-generic.conf' }
- { name: 'wordpress-security.conf', dir: '/etc/nginx/global/wordpress-security.conf' } - { name: 'wordpress-security.conf', dir: '/etc/nginx/global/wordpress-security.conf' }
- name: Make catch-all vhost root dir - name: Symlink the default catch-all vhost
file: path=/srv/www/catch-all state=directory owner=www-data group=www-data file: src=/etc/nginx/sites-available/0-catch-all dest=/etc/nginx/sites-enabled/0-catch-all state=link
notify: notify:
- start nginx - start nginx