solution abr
This commit is contained in:
62
apache.yml
Normal file
62
apache.yml
Normal file
@@ -0,0 +1,62 @@
|
||||
---
|
||||
- name: install apache via ansible playbook
|
||||
hosts: all
|
||||
handlers:
|
||||
- name: restart apache
|
||||
service:
|
||||
name: "{{ apache_service_name }}"
|
||||
state: restarted
|
||||
|
||||
tasks:
|
||||
- name: read OS var file
|
||||
include_vars: "{{ ansible_os_family | lower }}.yml"
|
||||
|
||||
- name: install apache
|
||||
package:
|
||||
name: "{{ apache_package_name }}"
|
||||
state: latest
|
||||
|
||||
- name: conf httpd
|
||||
template:
|
||||
src: vhost.conf
|
||||
dest: "{{ apache_config_dir }}/vhost.conf"
|
||||
mode: 0640
|
||||
owner: root
|
||||
group: "{{ apache_group }}"
|
||||
notify: restart apache
|
||||
|
||||
- name: delete defaultconf on debian
|
||||
file:
|
||||
path: "{{ apache_config_dir }}/000-default.conf"
|
||||
state: absent
|
||||
notify: restart apache
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: call handlers, if needed
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
- name: activate apache
|
||||
service:
|
||||
name: "{{ apache_service_name }}"
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: open firewall port
|
||||
firewalld:
|
||||
service: http
|
||||
permanent: yes
|
||||
immediate: yes
|
||||
state: enabled
|
||||
ignore_errors: yes
|
||||
when: ansible_os_family=='RedHat'
|
||||
|
||||
- name: create documentroot
|
||||
file:
|
||||
name: /var/www/html/example.org
|
||||
state: directory
|
||||
|
||||
- name: create index file
|
||||
copy:
|
||||
src: index.txt
|
||||
dest: /var/www/html/example.org/index.html
|
||||
mode: 0644
|
||||
9
debian.yml
Normal file
9
debian.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
#/home/formation/sib_12_handlers/debian.yml
|
||||
---
|
||||
apache_service_name: apache2
|
||||
apache_package_name: apache2
|
||||
apache_user: www-data
|
||||
apache_group: www-data
|
||||
apache_config_dir: /etc/apache2/sites-enabled/
|
||||
apache_log_dir: /var/log/apache2/
|
||||
|
||||
8
redhat.yml
Normal file
8
redhat.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
#/home/formation/sib_12_handlers/redhat.yml
|
||||
---
|
||||
apache_service_name: httpd
|
||||
apache_package_name: httpd
|
||||
apache_user: apache
|
||||
apache_group: apache
|
||||
apache_config_dir: /etc/httpd/conf.d/
|
||||
apache_log_dir: /var/log/httpd/
|
||||
Reference in New Issue
Block a user