Skip to content
Snippets Groups Projects
Commit 42d55cd1 authored by jurgenhaas's avatar jurgenhaas
Browse files

ansible-playbooks/general#85 Linting

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