solution
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
---
|
---
|
||||||
- hosts: centos
|
- hosts: cibles
|
||||||
roles:
|
roles:
|
||||||
- sib.apache
|
- sib.apache
|
||||||
@@ -2,5 +2,5 @@
|
|||||||
# handlers file for sib.apache
|
# handlers file for sib.apache
|
||||||
- name: restart httpd
|
- name: restart httpd
|
||||||
service:
|
service:
|
||||||
name: httpd
|
name: "{{ apache_service_name }}"
|
||||||
state: restarted
|
state: restarted
|
||||||
@@ -1,22 +1,36 @@
|
|||||||
---
|
---
|
||||||
# tasks file for sib.apache
|
# tasks file for sib.apache
|
||||||
- name: install apache
|
|
||||||
yum:
|
- name: read OS vars
|
||||||
name: httpd
|
tags: always
|
||||||
|
ansible.builtin.include_vars: "{{ ansible_os_family | lower }}.yml"
|
||||||
|
|
||||||
|
|
||||||
|
- name: install apache on Centos
|
||||||
|
package:
|
||||||
|
name: "{{ apache_package_name }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: conf httpd
|
- name: conf httpd
|
||||||
template:
|
template:
|
||||||
src: vhost.conf
|
src: vhost.conf.jj
|
||||||
dest: /etc/httpd/conf.d/vhost.conf
|
dest: "{{ apache_config_dir }}"
|
||||||
mode: 0640
|
mode: 0640
|
||||||
owner: root
|
owner: root
|
||||||
group: apache
|
group: "{{ apache_group_name }}"
|
||||||
notify: restart httpd
|
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
|
- name: activate apache
|
||||||
service:
|
service:
|
||||||
name: httpd
|
name: "{{ apache_service_name }}"
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
@@ -41,15 +55,18 @@
|
|||||||
permanent: yes
|
permanent: yes
|
||||||
immediate: yes
|
immediate: yes
|
||||||
state: enabled
|
state: enabled
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
when: ansible_os_family == 'RedHat'
|
||||||
|
|
||||||
- name: create documentroot
|
- name: create documentroot
|
||||||
file:
|
file:
|
||||||
name: /var/www/html/example.org/
|
name: '{{ item.documentroot }}'
|
||||||
state: directory
|
state: directory
|
||||||
|
loop: "{{ apache_vhosts }}"
|
||||||
|
|
||||||
- name: copy index file
|
- name: copy index file
|
||||||
template:
|
template:
|
||||||
src: index.txt
|
src: index.txt
|
||||||
dest: /var/www/html/example.org/index.html
|
dest: "{{ item.documentroot }}"
|
||||||
mode: 0644
|
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
|
# 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