Compare commits

1 Commits

Author SHA1 Message Date
33ce25edd0 solution 2023-10-13 09:25:36 +02:00
6 changed files with 40 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
---
- hosts: centos
- hosts: cibles
roles:
- sib.apache

View File

@@ -2,5 +2,5 @@
# handlers file for sib.apache
- name: restart httpd
service:
name: httpd
name: "{{ apache_service_name }}"
state: restarted

View File

@@ -1,22 +1,36 @@
---
# tasks file for sib.apache
- name: install apache
yum:
name: httpd
- name: read OS vars
tags: always
ansible.builtin.include_vars: "{{ ansible_os_family | lower }}.yml"
- name: install apache on Centos
package:
name: "{{ apache_package_name }}"
state: present
- name: conf httpd
template:
src: vhost.conf
dest: /etc/httpd/conf.d/vhost.conf
src: vhost.conf.jj
dest: "{{ apache_config_dir }}"
mode: 0640
owner: root
group: apache
group: "{{ apache_group_name }}"
notify: restart httpd
- name: delete default conf on debian
tags: debian
file:
path: "{{ apache_config_dir }}/000-default.conf"
state: absent
notify: restart httpd
when: ansible_os_family | lower == 'debian'
- name: activate apache
service:
name: httpd
name: "{{ apache_service_name }}"
enabled: yes
state: started
@@ -42,14 +56,17 @@
immediate: yes
state: enabled
ignore_errors: true
when: ansible_os_family == 'RedHat'
- name: create documentroot
file:
name: /var/www/html/example.org/
name: '{{ item.documentroot }}'
state: directory
loop: "{{ apache_vhosts }}"
- name: copy index file
template:
src: index.txt
dest: /var/www/html/example.org/index.html
dest: "{{ item.documentroot }}"
mode: 0644
loop: "{{ apache_vhosts }}"

View File

@@ -0,0 +1,4 @@
apache_service_name: apache2
apache_package_name: apache2
apache_group_name: www-data
apache_config_dir: /etc/apache2/sites-enabled/

View File

@@ -1,2 +1,3 @@
---
# vars file for sib.apache
http_port: 80

View File

@@ -0,0 +1,4 @@
apache_service_name: httpd
apache_package_name: httpd
apache_group_name: apache
apache_config_dir: /etc/httpd/conf.d/