solution
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
---
|
||||
- hosts: centos
|
||||
- hosts: cibles
|
||||
roles:
|
||||
- sib.apache
|
||||
@@ -2,5 +2,5 @@
|
||||
# handlers file for sib.apache
|
||||
- name: restart httpd
|
||||
service:
|
||||
name: httpd
|
||||
name: "{{ apache_service_name }}"
|
||||
state: restarted
|
||||
@@ -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 }}"
|
||||
4
sib.apache/vars/debian.yml
Normal file
4
sib.apache/vars/debian.yml
Normal 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/
|
||||
@@ -1,2 +1,3 @@
|
||||
---
|
||||
# vars file for sib.apache
|
||||
http_port: 80
|
||||
4
sib.apache/vars/redhat.yml
Normal file
4
sib.apache/vars/redhat.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
apache_service_name: httpd
|
||||
apache_package_name: httpd
|
||||
apache_group_name: apache
|
||||
apache_config_dir: /etc/httpd/conf.d/
|
||||
Reference in New Issue
Block a user