Role: httpd tasks
This commit is contained in:
parent
2c9840d347
commit
217591d525
22
ANSIBLE/roles/httpd/tasks/httpd_default_config.yml
Normal file
22
ANSIBLE/roles/httpd/tasks/httpd_default_config.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
- name: Create index.html
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: httpd/index.html.j2
|
||||||
|
dest: "{{ httpd_site_root }}/index.html"
|
||||||
|
owner: www-data
|
||||||
|
group: www-data
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: Create Apache virtual host config
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: httpd/vhost.conf.j2
|
||||||
|
dest: "/etc/apache2/sites-available/{{ httpd_site_name }}.conf"
|
||||||
|
notify: Reload Apache
|
||||||
|
|
||||||
|
- name: Enable site
|
||||||
|
ansible.builtin.command: "a2ensite {{ httpd_site_name }}"
|
||||||
|
notify: Reload Apache
|
||||||
|
|
||||||
|
- name: Enable SSL module
|
||||||
|
ansible.builtin.command: a2enmod ssl
|
||||||
|
notify: Reload Apache
|
22
ANSIBLE/roles/httpd/tasks/httpd_install.yml
Normal file
22
ANSIBLE/roles/httpd/tasks/httpd_install.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
- name: Install Apache2
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: apache2
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Install Certbot and Apache plugin
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- certbot
|
||||||
|
- python3-certbot-apache
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure site root exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ httpd_site_root }}"
|
||||||
|
state: directory
|
||||||
|
owner: www-data
|
||||||
|
group: www-data
|
||||||
|
mode: '0755'
|
||||||
|
|
@ -1,55 +1,18 @@
|
|||||||
---
|
---
|
||||||
- name: Install Apache2
|
|
||||||
ansible.builtin.apt:
|
|
||||||
name: apache2
|
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
|
|
||||||
- name: Install Certbot and Apache plugin
|
- name: Apache2 Install
|
||||||
ansible.builtin.apt:
|
ansible.builtin.include_tasks: httpd_install.yml
|
||||||
name:
|
- name: Apache2 Default Config
|
||||||
- certbot
|
ansible.builtin.include_tasks: httpd_default_config.yml
|
||||||
- python3-certbot-apache
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Ensure site root exists
|
|
||||||
file:
|
|
||||||
path: "{{ httpd_site_root }}"
|
|
||||||
state: directory
|
|
||||||
owner: www-data
|
|
||||||
group: www-data
|
|
||||||
mode: '0755'
|
|
||||||
|
|
||||||
- name: Create index.html
|
|
||||||
template:
|
|
||||||
src: httpd/index.html.j2
|
|
||||||
dest: "{{ httpd_site_root }}/index.html"
|
|
||||||
owner: www-data
|
|
||||||
group: www-data
|
|
||||||
mode: '0644'
|
|
||||||
|
|
||||||
- name: Create Apache virtual host config
|
|
||||||
template:
|
|
||||||
src: httpd/vhost.conf.j2
|
|
||||||
dest: "/etc/apache2/sites-available/{{ httpd_site_name }}.conf"
|
|
||||||
notify: Reload Apache
|
|
||||||
|
|
||||||
- name: Enable site
|
|
||||||
command: "a2ensite {{ httpd_site_name }}"
|
|
||||||
notify: Reload Apache
|
|
||||||
|
|
||||||
- name: Enable SSL module
|
|
||||||
command: a2enmod ssl
|
|
||||||
notify: Reload Apache
|
|
||||||
|
|
||||||
- name: Ensure Apache is running and enabled
|
- name: Ensure Apache is running and enabled
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: apache2
|
name: apache2
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: true
|
||||||
|
|
||||||
- name: Obtain Let's Encrypt certificate using certbot
|
- name: Obtain Let's Encrypt certificate using certbot
|
||||||
command: >
|
ansible.builtin.command: >
|
||||||
certbot --apache -n --agree-tos --redirect
|
certbot --apache -n --agree-tos --redirect
|
||||||
-d {{ httpd_site_name }}
|
-d {{ httpd_site_name }}
|
||||||
--email {{ admin_email }}
|
--email {{ admin_email }}
|
||||||
@ -57,6 +20,5 @@
|
|||||||
creates: "/etc/letsencrypt/live/{{ httpd_site_name }}/fullchain.pem"
|
creates: "/etc/letsencrypt/live/{{ httpd_site_name }}/fullchain.pem"
|
||||||
|
|
||||||
- name: PHP Application
|
- name: PHP Application
|
||||||
when: httpd_php == true
|
when: httpd_php
|
||||||
ansible.builtin.include_tasks: php.yml
|
ansible.builtin.include_tasks: php.yml
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user