2
0

make it work on more distros

This commit is contained in:
2020-05-05 22:56:05 +02:00
parent 1c6027864a
commit 50081cc5d8
4 changed files with 20 additions and 28 deletions

View File

@@ -1,7 +1,5 @@
--- ---
- name: install apache via ansible playbook - name: install apache via ansible playbook
hosts: all hosts: all
user: root
become: false
roles: roles:
- myapache3 - myapache3

View File

@@ -1,18 +1,5 @@
apache_vhosts: servername: laposte.net
- servername: cines.fr serveralias: www.laposte.net
serveralias: documentroot: /var/www/html/laposte.net
- www.cines.fr accesslog: /var/log/httpd/access_laposte.net_log
- cines.org errorlog: /var/log/httpd/error_laposte.net_log
- www.cines.org
documentroot: /var/www/html/cines.fr
accesslog: /var/log/httpd/access_cines.fr_log
errorlog: /var/log/httpd/error_cines.fr_log
- servername: thomas.fr
serveralias:
- www.thomas.fr
- thomas.com
- www.thomas.cm
documentroot: /var/www/html/thomas.fr
accesslog: /var/log/httpd/access_thomas.fr_log
errorlog: /var/log/httpd/error_thomas.fr_log
documentrootoptions: indexes

View File

@@ -2,7 +2,7 @@
# handlers file for myapache # handlers file for myapache
- name: reload httpd - name: reload httpd
service: service:
name: httpd name: "{{ apache_service_name }}"
state: reloaded state: reloaded
- name: reload firewalld - name: reload firewalld

View File

@@ -1,16 +1,22 @@
--- ---
# tasks file for myapache # tasks file for myapache
- name: install apache #
- name: include distribution specific variables
include_vars: "{{ ansible_distribution|lower }}.yml"
- name: install apache almost anywhere
tags: httpd tags: httpd
yum: package:
name: httpd name: "{{ apache_package_name}}"
state: latest state: latest
- name: conf httpd - name: conf httpd
tags: httpd tags: httpd
notify: reload httpd notify: reload httpd
template: template:
src: vhost.conf.jj src: vhost.conf.jj
dest: /etc/httpd/conf.d/vhost.conf dest: "{{ apache_conf_dir}}/vhost.conf"
mode: 0640 mode: 0640
owner: root owner: root
group: apache group: apache
@@ -18,7 +24,7 @@
- name: activate apache - name: activate apache
tags: httpd tags: httpd
service: service:
name: httpd name: "{{ apache_service_name }}"
enabled: yes enabled: yes
- name: open firewall port - name: open firewall port
@@ -30,11 +36,12 @@
state: enabled state: enabled
ignore_errors: yes ignore_errors: yes
notify: reload firewalld notify: reload firewalld
when: ansible_distribution=="CentOS" or "RedHat"
- name: create documentroot - name: create documentroot
tags: httpd tags: httpd
file: file:
name: "/var/www/html/{{ item.documentroot }}" name: "{{ item.documentroot }}"
state: directory state: directory
with_items: with_items:
- "{{ apache_vhosts }}" - "{{ apache_vhosts }}"
@@ -43,7 +50,7 @@
tags: httpd tags: httpd
copy: copy:
src: index.html src: index.html
dest: "/var/www/html/{{ item.documentroot }}/index.html" dest: "{{ item.documentroot }}/index.html"
mode: 0644 mode: 0644
with_items: with_items:
- "{{ apache_vhosts }}" - "{{ apache_vhosts }}"