1 | ---
|
---|
2 | - hosts: localhost
|
---|
3 | connection: local
|
---|
4 | become: true
|
---|
5 | vars_files:
|
---|
6 | - vars/default-core.yml
|
---|
7 |
|
---|
8 | tasks:
|
---|
9 | - name: Checking gsdl3servlet_external.protocol is set to 'https'
|
---|
10 | debug: var=gsdl3servlet_external.protocol
|
---|
11 |
|
---|
12 | - command: echo "gsdl3servlet_external.prototol = {{ gsdl3servlet_external.protocol }}"
|
---|
13 | failed_when: gsdl3servlet_external.protocol != "https"
|
---|
14 |
|
---|
15 | - name: Upgrading Ansible to use 'aptitute' as package installation manager
|
---|
16 | apt: name=aptitude update_cache=yes state=latest force_apt_get=yes
|
---|
17 |
|
---|
18 | - name: Install Apache2
|
---|
19 | apt: name=apache2 update_cache=yes state=latest
|
---|
20 |
|
---|
21 | - name: Enable Apache2 Modules
|
---|
22 | shell: /usr/sbin/a2enmod rewrite headers proxy proxy_http proxy_wstunnel
|
---|
23 |
|
---|
24 | - name: Deriving 'gsdl3servlet_internal_domain_url'
|
---|
25 | set_fact:
|
---|
26 | gsdl3servlet_internal_domain_url: "{{ gsdl3servlet_internal | gsdl3servlet_domain_url() }}"
|
---|
27 |
|
---|
28 | - name: Adding 'gsdl3servlet_internal_domain_url' to 'gsdl3servlet_internal'
|
---|
29 | set_fact:
|
---|
30 | gsdl3servlet_internal: "{{ gsdl3servlet_internal | combine ({'domain_url': gsdl3servlet_internal_domain_url}) }}"
|
---|
31 |
|
---|
32 | - name: Deriving 'gsdl3servlet_external_domain_url'
|
---|
33 | set_fact:
|
---|
34 | gsdl3servlet_external_domain_url: "{{ gsdl3servlet_external | gsdl3servlet_domain_url() }}"
|
---|
35 |
|
---|
36 | - name: Adding 'gsdl3servlet_external_domain_url' to 'gsdl3servlet_external'
|
---|
37 | set_fact:
|
---|
38 | gsdl3servlet_external: "{{ gsdl3servlet_external | combine ({'domain_url': gsdl3servlet_external_domain_url}) }}"
|
---|
39 |
|
---|
40 | # Apache2
|
---|
41 | - include_tasks: reverse-proxy-http-tasks.yml
|
---|
42 |
|
---|
43 | - name: Activating revproxy properties in build.properties
|
---|
44 | set_fact:
|
---|
45 | build_properties_revproxy:
|
---|
46 | - "revproxy.protocol"
|
---|
47 | - "revproxy.domain"
|
---|
48 |
|
---|
49 | - name: Appending reproxy.opt_port
|
---|
50 | set_fact:
|
---|
51 | build_properties_revproxy: "{{ build_properties_revproxy + [ 'revproxy.opt_port' ] }}"
|
---|
52 | when: gsdl3servlet_external.port is defined
|
---|
53 |
|
---|
54 | - name: Appending reproxy.context
|
---|
55 | set_fact:
|
---|
56 | build_properties_revproxy: "{{ build_properties_revproxy + [ 'revproxy.context' ] }}"
|
---|
57 | when: gsdl3servlet_external.context is defined
|
---|
58 |
|
---|
59 | - debug:
|
---|
60 | var: build_properties_revproxy
|
---|
61 |
|
---|
62 | - name: Setting revproxy property values in build.properties if apache2_as_revproxy is True
|
---|
63 | ansible.builtin.lineinfile:
|
---|
64 | path: "{{ gsdl3srchome }}/build.properties"
|
---|
65 | regexp: '^#*{{ item }}='
|
---|
66 | line: "{{ item }}={{ gsdl3_buildproperties_revproxy[item] }}"
|
---|
67 | with_items: "{{ build_properties_revproxy }}"
|
---|
68 | when: apache2_as_revproxy == true
|
---|
69 |
|
---|
70 | - name: Commenting out revproxy property values in build.properties if apache2_as_revproxy is False
|
---|
71 | ansible.builtin.lineinfile:
|
---|
72 | path: "{{ gsdl3srchome }}/build.properties"
|
---|
73 | regexp: '^#*{{ item }}='
|
---|
74 | line: "#{{ item }}={{ gsdl3_buildproperties_revproxy[item] }}"
|
---|
75 | with_items: "{{ gsdl3_buildproperties_revproxy.keys() | list }}"
|
---|
76 | when: apache2_as_revproxy != true
|
---|
77 |
|
---|
78 |
|
---|
79 | - include_tasks: reverse-proxy-https-tasks.yml
|
---|
80 | when: apache2_revproxy_config.https_port is defined
|
---|
81 |
|
---|
82 | handlers:
|
---|
83 | - name: Reload Apache
|
---|
84 | service:
|
---|
85 | name: apache2
|
---|
86 | state: reloaded
|
---|
87 |
|
---|
88 | - name: Restart Apache
|
---|
89 | service:
|
---|
90 | name: apache2
|
---|
91 | state: restarted
|
---|