From: Oleg Broytman Date: Fri, 26 Jul 2019 20:04:58 +0000 (+0300) Subject: Refactor(add_apache_vhost): Split `tasks/main` X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=d75839f853d60353ccb4eb4796491720f014d4f1;p=ansible.git Refactor(add_apache_vhost): Split `tasks/main` Split `tasks/main` into `tasks/add_vhost`. --- diff --git a/playbooks/debian/roles/add_apache_vhost/tasks/add_vhost.yml b/playbooks/debian/roles/add_apache_vhost/tasks/add_vhost.yml new file mode 100644 index 0000000..145982d --- /dev/null +++ b/playbooks/debian/roles/add_apache_vhost/tasks/add_vhost.yml @@ -0,0 +1,30 @@ +- name: Configure site + become: true + template: + src: vhost.conf + dest: "/etc/apache2/sites-available/{{ virtual_host }}.conf" + owner: root + group: root + mode: '0640' + force: no + notify: Reload apache + when: vhost.rc != 0 + +- name: Enable site + become: true + command: "a2ensite {{ virtual_host }}" + notify: Reload apache + when: vhost.rc != 0 + +- name: Create directories + become: true + file: + path: "{{ item }}/{{ virtual_host }}" + state: directory + owner: root + group: www-data + mode: '0755' + loop: ['/usr/local/apache2/cgi-bin', '/usr/local/apache2/htdocs', + '/var/log/apache2', + ] + when: vhost.rc != 0 diff --git a/playbooks/debian/roles/add_apache_vhost/tasks/main.yml b/playbooks/debian/roles/add_apache_vhost/tasks/main.yml index 0c95675..a8bda13 100644 --- a/playbooks/debian/roles/add_apache_vhost/tasks/main.yml +++ b/playbooks/debian/roles/add_apache_vhost/tasks/main.yml @@ -4,33 +4,8 @@ register: vhost changed_when: vhost.rc != 0 -- name: Configure site - become: true - template: - src: vhost.conf - dest: "/etc/apache2/sites-available/{{ virtual_host }}.conf" - owner: root - group: root - mode: '0640' - force: no - notify: Reload apache +- name: Add vhost + import_tasks: add_vhost.yml when: vhost.rc != 0 -- name: Enable site - become: true - command: "a2ensite {{ virtual_host }}" - notify: Reload apache - when: vhost.rc != 0 - -- name: Create directories - become: true - file: - path: "{{ item }}/{{ virtual_host }}" - state: directory - owner: root - group: www-data - mode: '0755' - loop: ['/usr/local/apache2/cgi-bin', '/usr/local/apache2/htdocs', - '/var/log/apache2', - ] when: vhost.rc != 0