diff --git a/defaults/main.yml b/defaults/main.yml index 39350b742a7951d835c586aec09135dc66433c81..2f18baf9f2045be211592c8016c0e591c8859a25 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,5 @@ +--- + apache_repositories: [] apache_packages: - apache2 @@ -26,12 +28,12 @@ apache_server_default_aliases: [] apache_server_default_aliases_redirect: [] apache_server_defs: [] apache_server_default_root: /html -apache_server_default_svn_source: false +apache_server_default_svn_source: no apache_server_default_svn_target: live apache_certificates: [] -apache_auth: false +apache_auth: no apache_cache: - active: true + active: no default: A14400 bytype: - type: text/html diff --git a/handlers/main.yml b/handlers/main.yml index c3cf3a3cd56424abb1699d455f6e6d4b9c3192bf..774090a02133db388e03736d0caee3dc59eebfa4 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,47 +1,49 @@ --- # file: roles/apache/handlers/main.yml -- name: Apache | Restart Apache +- name: Restart Apache service: - name=apache2 - state=restarted + name: apache2 + state: restarted -- name: Apache | Checkout htdocs for default +- name: Checkout htdocs for default subversion: - repo={{ apache_server_default_svn_source }} - dest=/var/www/{{ apache_server_default_svn_target }} + repo: '{{ apache_server_default_svn_source }}' + dest: /var/www/{{ apache_server_default_svn_target }} become: no - notify: Apache | Change ownership for web server files + notify: + - Change ownership for web server files async: 3000 poll: 0 when: apache_server_default_svn_source != false -- name: Apache | Checkout htdocs for our site(s) +- name: Checkout htdocs for our site(s) subversion: - repo={{ item.svn_source }} - dest=/var/www/{{ item.svn_target }} + repo: '{{ item.svn_source }}' + dest: /var/www/{{ item.svn_target }} become: no with_items: '{{ apache_server_defs }}' - notify: Apache | Change ownership for web server files + notify: + - Change ownership for web server files async: 3000 poll: 0 -- name: Apache | Change ownership for web server files +- name: Change ownership for web server files file: - path="/var/www" - owner="www-data" - group="www-data" - recurse=yes - follow=no + path: /var/www + owner: www-data + group: www-data + recurse: yes + follow: no -- name: Apache | Change mode for web server files +- name: Change mode for web server files file: - path=/var/www - mode=g+w - recurse=yes - follow=no + path: /var/www + mode: g+w + recurse: yes + follow: no -- name: Apache | Change mode for web server root dir +- name: Change mode for web server root dir file: - path=/var/www - mode='755' + path: /var/www + mode: 0755 diff --git a/tasks/apache.yml b/tasks/apache.yml index ce04af8755662c7d1ef7ebf163e152d16138f2fd..099c24e629ff374e8eb6f4fdf0cf6702f05f8143 100644 --- a/tasks/apache.yml +++ b/tasks/apache.yml @@ -1,48 +1,52 @@ --- # file: roles/apache/tasks/apache.yml -- name: Apache | Apt Repository +- name: Apt Repository apt_repository: - repo='{{ item }}' - state='present' - mode='644' + repo: '{{ item }}' + state: present + mode: 0644 with_items: '{{ apache_repositories }}' -- name: Apache | Install required packages. +- name: Install required packages. apt: - pkg='{{ apache_packages }}' - state=present - force=yes - notify: "Apache | Restart Apache" + pkg: '{{ apache_packages }}' + state: present + force: yes + notify: + - Restart Apache -- name: Apache | Enable some required modules +- name: Enable some required modules apache2_module: - name='{{ item }}' - state=present + name: '{{ item }}' + state: present with_items: '{{ apache_modules }}' - notify: "Apache | Restart Apache" + notify: + - Restart Apache -- name: Apache | Turn on Extended Status +- name: Turn on Extended Status lineinfile: - dest=/etc/apache2/apache2.conf - regexp='^ExtendedStatus ' - line='ExtendedStatus On' - notify: "Apache | Restart Apache" + dest: /etc/apache2/apache2.conf + regexp: '^ExtendedStatus ' + line: ExtendedStatus On + notify: + - Restart Apache -- name: Apache | Turn on SendFile +- name: Turn on SendFile lineinfile: - dest=/etc/apache2/apache2.conf - regexp='^EnableSendfile ' - line='EnableSendfile On' - notify: "Apache | Restart Apache" + dest: /etc/apache2/apache2.conf + regexp: '^EnableSendfile ' + line: EnableSendfile On + notify: + - Restart Apache -- name: Apache | Configure Security, Global Redirect, Global Deny, Logging +- name: Configure Security, Global Redirect, Global Deny, Logging template: - src='etc-apache2-conf-available-{{item }}' - dest='/etc/apache2/{{ apache_conf_dir }}/{{ item }}.conf' - owner='root' - group='root' - mode='644' + src: etc-apache2-conf-available-{{item }} + dest: /etc/apache2/{{ apache_conf_dir }}/{{ item }}.conf + owner: root + group: root + mode: 0644 with_items: - security - global-redirect @@ -51,11 +55,11 @@ - redirect-ssl - other-vhosts-access-log notify: - - "Apache | Restart Apache" + - "Restart Apache" tags: - ApacheConfig -- name: Apache | Write SSL Apache Options +- name: Write SSL Apache Options template: src: options-ssl-apache.conf dest: /etc/apache2/{{ apache_conf_dir }}/options-ssl-apache.conf @@ -63,128 +67,135 @@ group: root mode: 0644 -- name: Apache | Install SSL certificates +- name: Install SSL certificates copy: - src={{inventory_dir}}/files/ssl/{{item.1.file}} - dest=/etc/ssl/private + src: '{{inventory_dir}}/files/ssl/{{item.1.file}}' + dest: /etc/ssl/private with_subelements: - {{ apache_certificates }} - certs - notify: "Apache | Restart Apache" + notify: + - Restart Apache -- name: Apache | Create htdocs directory for default +- name: Create htdocs directory for default file: - dest=/var/www{{ apache_server_default_root }} - state=directory - owner=www-data - group=www-data + dest: /var/www{{ apache_server_default_root }} + state: directory + owner: www-data + group: www-data -- name: Apache | Create htdocs directory for SVN default +- name: Create htdocs directory for SVN default file: - dest=/var/www/{{ apache_server_default_svn_target }} - state=directory - owner=www-data - group=www-data + dest: /var/www/{{ apache_server_default_svn_target }} + state: directory + owner: www-data + group: www-data -- name: Apache | Create htdocs directory for our site(s) +- name: Create htdocs directory for our site(s) file: - dest=/var/www/{{ item.svn_target }} - state=directory - owner=www-data - group=www-data + dest: /var/www/{{ item.svn_target }} + state: directory + owner: www-data + group: www-data with_items: '{{ apache_server_defs }}' -- name: Apache | Configuration file for default site +- name: Configuration file for default site template: - src=etc-apache2-sites-available-default - dest=/etc/apache2/sites-available/{{ apache_conf_default_prefix }}default{{ apache_conf_ext }} - owner=root - group=root - mode='644' + src: etc-apache2-sites-available-default + dest: /etc/apache2/sites-available/{{ apache_conf_default_prefix }}default{{ apache_conf_ext }} + owner: root + group: root + mode: 0644 when: apache_server_default == "yes" notify: - - "Apache | Restart Apache" - - "Apache | Checkout htdocs for default" + - "Restart Apache" + - "Checkout htdocs for default" -- name: Apache | Configuration file for default ssl site +- name: Configuration file for default ssl site template: - src=etc-apache2-sites-available-default-ssl - dest=/etc/apache2/sites-available/{{ apache_conf_default_prefix }}default-ssl{{ apache_conf_ext }} - owner=root - group=root - mode='644' + src: etc-apache2-sites-available-default-ssl + dest: /etc/apache2/sites-available/{{ apache_conf_default_prefix }}default-ssl{{ apache_conf_ext }} + owner: root + group: root + mode: 0644 when: apache_server_default_ssl == "yes" notify: - - "Apache | Restart Apache" - - "Apache | Checkout htdocs for default" + - "Restart Apache" + - "Checkout htdocs for default" -- name: Apache | Configuration file for our site(s) +- name: Configuration file for our site(s) template: - src=etc-apache2-sites-available-vhost - dest=/etc/apache2/sites-available/{{ item.vhost }}{{ apache_conf_ext }} - owner=root - group=root - mode='644' + src: etc-apache2-sites-available-vhost + dest: /etc/apache2/sites-available/{{ item.vhost }}{{ apache_conf_ext }} + owner: root + group: root + mode: 0644 with_items: '{{ apache_server_defs }}' notify: - - "Apache | Restart Apache" - - "Apache | Checkout htdocs for our site(s)" + - "Restart Apache" + - "Checkout htdocs for our site(s)" -- name: Apache | Disable the default site +- name: Disable the default site command: a2dissite {{ item }} with_items: - default - - {{ apache_conf_default_prefix }}default - ignore_errors: true + - '{{ apache_conf_default_prefix }}default' + ignore_errors: yes when: apache_server_default == "no" -- name: Apache | Disable the default ssl site +- name: Disable the default ssl site command: a2dissite {{ item }} with_items: - default-ssl - - {{ apache_conf_default_prefix }}default-ssl - ignore_errors: true + - '{{ apache_conf_default_prefix }}default-ssl' + ignore_errors: yes when: apache_server_default_ssl == "no" -- name: Apache | Enable the default site - command: a2ensite {{ apache_conf_default_prefix }}default creates=/etc/apache2/sites-enabled/{{ apache_conf_default_prefix }}default{{ apache_conf_ext }} +- name: Enable the default site + command: a2ensite {{ apache_conf_default_prefix }}default + args: + creates: /etc/apache2/sites-enabled/{{ apache_conf_default_prefix }}default{{ apache_conf_ext }} when: apache_server_default == "yes" -- name: Apache | Enable the default ssl site - command: a2ensite {{ apache_conf_default_prefix }}default-ssl creates=/etc/apache2/sites-enabled/{{ apache_conf_default_prefix }}default-ssl{{ apache_conf_ext }} +- name: Enable the default ssl site + command: a2ensite {{ apache_conf_default_prefix }}default-ssl + args: + creates: /etc/apache2/sites-enabled/{{ apache_conf_default_prefix }}default-ssl{{ apache_conf_ext }} when: apache_server_default_ssl == "yes" -- name: Apache | Enable our new site(s) - command: a2ensite {{ item.vhost }} creates=/etc/apache2/sites-enabled/{{ item.vhost }}{{ apache_conf_ext }} +- name: Enable our new site(s) + command: a2ensite {{ item.vhost }} + args: + creates: /etc/apache2/sites-enabled/{{ item.vhost }}{{ apache_conf_ext }} with_items: '{{ apache_server_defs }}' -- name: Apache | Create passwords directory for AuthType Basic +- name: Create passwords directory for AuthType Basic file: - dest=/var/www/passwords - state=directory - owner=www-data - group=www-data + dest: /var/www/passwords + state: directory + owner: www-data + group: www-data -- name: Apache | Setup AuthType Basic +- name: Setup AuthType Basic htpasswd: - path="/var/www/passwords/{{ apache_auth.user }}" - name="{{ apache_auth.user }}" - password="{{ apache_auth.password }}" - owner=www-data - group=www-data - mode='640' + path: /var/www/passwords/{{ apache_auth.user }} + name: '{{ apache_auth.user }}' + password: '{{ apache_auth.password }}' + owner: www-data + group: www-data + mode: 0640 when: apache_auth -- name: Apache | Create default content directory +- name: Create default content directory file: - dest=/var/www/html - state=directory - owner=www-data - group=www-data + dest: /var/www/html + state: directory + owner: www-data + group: www-data -- name: Apache | Copy default HTML site +- name: Copy default HTML site template: - src=index.html - dest=/var/www/html/index.html - owner=www-data - group=www-data + src: index.html + dest: /var/www/html/index.html + owner: www-data + group: www-data diff --git a/tasks/main.yml b/tasks/main.yml index 2bbaa4078c0b0e53ff298ccc09f29bb4c685b4ae..0bf5f628dba62dfe37b0fa7c08aefc9aef3c52c3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,12 +13,12 @@ - block: - - import_tasks: apache.yml + - import_tasks: apache.yml - - name: Remember that this role had been run - set_fact: - role_apache_completed: yes - tags: - - always + - name: Remember that this role had been run + set_fact: + role_apache_completed: yes + tags: + - always when: not excluded_roles or "apache" not in excluded_roles and role_apache_completed is not defined