diff --git a/defaults/main.yml b/defaults/main.yml index 697e4f18eb1e0525c43ed0313e132ac5993db1e0..39350b742a7951d835c586aec09135dc66433c81 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,27 +15,27 @@ apache_modules: - rewrite - ssl - vhost_alias -apache_version: '2.4' -apache_conf_dir: 'conf-available' -apache_conf_ext: '.conf' -apache_conf_default_prefix: '000-' -apache_server_admin: 'webmaster@paragon-es.de' -apache_server_default: 'yes' -apache_server_default_ssl: 'no' +apache_version: 2.4 +apache_conf_dir: conf-available +apache_conf_ext: .conf +apache_conf_default_prefix: 000- +apache_server_admin: webmaster@paragon-es.de +apache_server_default: yes +apache_server_default_ssl: no apache_server_default_aliases: [] apache_server_default_aliases_redirect: [] apache_server_defs: [] -apache_server_default_root: '/html' +apache_server_default_root: /html apache_server_default_svn_source: false -apache_server_default_svn_target: 'live' +apache_server_default_svn_target: live apache_certificates: [] apache_auth: false apache_cache: active: true - default: 'A14400' + default: A14400 bytype: - - type: 'text/html' - default: 'A900' + - type: text/html + default: A900 apache_global_redirect: ip: [] agent: [] diff --git a/handlers/main.yml b/handlers/main.yml index b4c0c0b201fd1f8446d968357fa7755dc2986517..c3cf3a3cd56424abb1699d455f6e6d4b9c3192bf 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,32 +1,32 @@ --- # file: roles/apache/handlers/main.yml -- name: 'Apache | Restart Apache' +- name: Apache | Restart Apache service: name=apache2 state=restarted -- name: 'Apache | Checkout htdocs for default' +- name: Apache | Checkout htdocs for default subversion: 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: Apache | 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: Apache | Checkout htdocs for our site(s) subversion: 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: Apache | Change ownership for web server files async: 3000 poll: 0 -- name: 'Apache | Change ownership for web server files' +- name: Apache | Change ownership for web server files file: path="/var/www" owner="www-data" @@ -34,14 +34,14 @@ recurse=yes follow=no -- name: 'Apache | Change mode for web server files' +- name: Apache | Change mode for web server files file: path=/var/www mode=g+w recurse=yes follow=no -- name: 'Apache | Change mode for web server root dir' +- name: Apache | Change mode for web server root dir file: path=/var/www mode='755' diff --git a/tasks/apache.yml b/tasks/apache.yml index 147224e570b6411b1fcee7570c1cdab7e69b044c..5b81c1cdfe8a358658c2cb2cdf65754b9e55aa7e 100644 --- a/tasks/apache.yml +++ b/tasks/apache.yml @@ -1,42 +1,42 @@ --- # file: roles/apache/tasks/apache.yml -- name: "Apache | Apt Repository" +- name: Apache | Apt Repository apt_repository: repo='{{ item }}' state='present' mode='644' with_items: '{{ apache_repositories }}' -- name: "Apache | Install required packages." +- name: Apache | Install required packages. apt: pkg='{{ apache_packages }}' state=present force=yes notify: "Apache | Restart Apache" -- name: "Apache | Enable some required modules" +- name: Apache | Enable some required modules apache2_module: name='{{ item }}' state=present with_items: '{{ apache_modules }}' notify: "Apache | Restart Apache" -- name: "Apache | Turn on Extended Status" +- name: Apache | Turn on Extended Status lineinfile: dest=/etc/apache2/apache2.conf regexp='^ExtendedStatus ' line='ExtendedStatus On' notify: "Apache | Restart Apache" -- name: "Apache | Turn on SendFile" +- name: Apache | Turn on SendFile lineinfile: dest=/etc/apache2/apache2.conf regexp='^EnableSendfile ' line='EnableSendfile On' notify: "Apache | Restart Apache" -- name: "Apache | Configure Security, Global Redirect, Global Deny, Logging" +- name: Apache | Configure Security, Global Redirect, Global Deny, Logging template: src='etc-apache2-conf-available-{{item }}' dest='/etc/apache2/{{ apache_conf_dir }}/{{ item }}.conf' @@ -44,49 +44,49 @@ group='root' mode='644' with_items: - - 'security' - - 'global-redirect' - - 'global-deny' - - 'letsencrypt-redirect' - - 'redirect-ssl' - - 'other-vhosts-access-log' + - security + - global-redirect + - global-deny + - letsencrypt-redirect + - redirect-ssl + - other-vhosts-access-log notify: - "Apache | Restart Apache" - tags: 'ApacheConfig' + tags: + - ApacheConfig -- name: "Apache | Write SSL Apache Options" +- name: Apache | Write SSL Apache Options template: - src: 'options-ssl-apache.conf' - dest: '/etc/apache2/{{ apache_conf_dir }}/options-ssl-apache.conf' - owner: 'root' - group: 'root' - mode: '644' - tags: 'abcabcabc' - -- name: "Apache | Install SSL certificates" + src: options-ssl-apache.conf + dest: /etc/apache2/{{ apache_conf_dir }}/options-ssl-apache.conf + owner: root + group: root + mode: 644 + +- name: Apache | Install SSL certificates copy: src={{inventory_dir}}/files/ssl/{{item.1.file}} dest=/etc/ssl/private with_subelements: - - '{{ apache_certificates }}' + - {{ apache_certificates }} - certs notify: "Apache | Restart Apache" -- name: "Apache | Create htdocs directory for default" +- name: Apache | Create htdocs directory for default file: dest=/var/www{{ apache_server_default_root }} state=directory owner=www-data group=www-data -- name: "Apache | Create htdocs directory for SVN default" +- name: Apache | Create htdocs directory for SVN default file: 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: Apache | Create htdocs directory for our site(s) file: dest=/var/www/{{ item.svn_target }} state=directory @@ -94,7 +94,7 @@ group=www-data with_items: '{{ apache_server_defs }}' -- name: "Apache | Configuration file for default site" +- name: Apache | 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 }} @@ -106,7 +106,7 @@ - "Apache | Restart Apache" - "Apache | Checkout htdocs for default" -- name: "Apache | Configuration file for default ssl site" +- name: Apache | 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 }} @@ -118,7 +118,7 @@ - "Apache | Restart Apache" - "Apache | Checkout htdocs for default" -- name: "Apache | Configuration file for our site(s)" +- name: Apache | Configuration file for our site(s) template: src=etc-apache2-sites-available-vhost dest=/etc/apache2/sites-available/{{ item.vhost }}{{ apache_conf_ext }} @@ -130,42 +130,42 @@ - "Apache | Restart Apache" - "Apache | Checkout htdocs for our site(s)" -- name: "Apache | Disable the default site" +- name: Apache | Disable the default site command: a2dissite {{ item }} with_items: - - 'default' - - '{{ apache_conf_default_prefix }}default' + - default + - {{ apache_conf_default_prefix }}default ignore_errors: true when: apache_server_default == "no" -- name: "Apache | Disable the default ssl site" +- name: Apache | Disable the default ssl site command: a2dissite {{ item }} with_items: - - 'default-ssl' - - '{{ apache_conf_default_prefix }}default-ssl' + - default-ssl + - {{ apache_conf_default_prefix }}default-ssl ignore_errors: true when: apache_server_default_ssl == "no" -- name: "Apache | Enable the default site" +- 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 }} when: apache_server_default == "yes" -- name: "Apache | Enable the default ssl site" +- 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 }} when: apache_server_default_ssl == "yes" -- name: "Apache | Enable our new site(s)" +- name: Apache | Enable our new site(s) command: a2ensite {{ item.vhost }} creates=/etc/apache2/sites-enabled/{{ item.vhost }}{{ apache_conf_ext }} with_items: '{{ apache_server_defs }}' -- name: "Apache | Create passwords directory for AuthType Basic" +- name: Apache | Create passwords directory for AuthType Basic file: dest=/var/www/passwords state=directory owner=www-data group=www-data -- name: "Apache | Setup AuthType Basic" +- name: Apache | Setup AuthType Basic htpasswd: path="/var/www/passwords/{{ apache_auth.user }}" name="{{ apache_auth.user }}" @@ -175,14 +175,14 @@ mode='640' when: apache_auth -- name: "Apache | Create default content directory" +- name: Apache | Create default content directory file: dest=/var/www/html state=directory owner=www-data group=www-data -- name: "Apache | Copy default HTML site" +- name: Apache | Copy default HTML site template: src=index.html dest=/var/www/html/index.html diff --git a/tasks/main.yml b/tasks/main.yml index 5f599ffed01ad2ef718549f025f337a50b380df2..2bbaa4078c0b0e53ff298ccc09f29bb4c685b4ae 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,16 +5,20 @@ --- # file: roles/apache/tasks/main.yml -- name: "Apache Role" - set_fact: role_apache_started=true - tags: 'always' +- name: Apache Role + set_fact: + role_apache_started: yes + tags: + - always - block: - import_tasks: apache.yml - - name: 'Remember that this role had been run' - set_fact: role_apache_completed=true - tags: 'always' + - name: Remember that this role had been run + set_fact: + role_apache_completed: yes + tags: + - always - when: '"apache" not in excluded_roles and role_apache_completed is not defined' + when: not excluded_roles or "apache" not in excluded_roles and role_apache_completed is not defined