From 8bcc5220092f2892794cc6a339d388d280c56a93 Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Fri, 28 Sep 2018 13:31:05 +0200 Subject: [PATCH] mise au point ex variable 2 --- 17.2_variable/host_vars/cible1 | 11 +++++++++++ 17.2_variable/host_vars/cible2 | 11 +++++++++++ 17.2_variable/myapache2/README.md | 16 ++++++++++------ 17.2_variable/myapache2/tasks/main.yml | 6 +++--- 17.2_variable/myapache2/vars/main.yml | 13 +------------ 5 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 17.2_variable/host_vars/cible1 create mode 100644 17.2_variable/host_vars/cible2 diff --git a/17.2_variable/host_vars/cible1 b/17.2_variable/host_vars/cible1 new file mode 100644 index 0000000..f916d4d --- /dev/null +++ b/17.2_variable/host_vars/cible1 @@ -0,0 +1,11 @@ +apache_vhosts: +- servername: orsys.fr + serveralias: www.orsys.fr + documentroot: /var/www/html/orsys.fr + accesslog: /var/log/httpd/access_orsys.fr_log + errorlog: /var/log/httpd/error_orsys.fr_log +- servername: thomas.fr + serveralias: www.thomas.fr + documentroot: /var/www/html/thomas.fr + accesslog: /var/log/httpd/access_thomas.fr_log + errorlog: /var/log/httpd/error_thomas.fr_log \ No newline at end of file diff --git a/17.2_variable/host_vars/cible2 b/17.2_variable/host_vars/cible2 new file mode 100644 index 0000000..213ca4e --- /dev/null +++ b/17.2_variable/host_vars/cible2 @@ -0,0 +1,11 @@ +apache_vhosts: +- servername: foobar.com + serveralias: www.foobar.com + documentroot: /var/www/html/foobar.com + accesslog: /var/log/httpd/access_foobar.com_log + errorlog: /var/log/httpd/error_foobar.com_log +- servername: AllYourBaseAreBelong2.us + serveralias: www.AllYourBaseAreBelong2.us + documentroot: /var/www/html/AllYourBaseAreBelong2.us + accesslog: /var/log/httpd/access_AllYourBaseAreBelong2.us_log + errorlog: /var/log/httpd/error_AllYourBaseAreBelong2.us_log \ No newline at end of file diff --git a/17.2_variable/myapache2/README.md b/17.2_variable/myapache2/README.md index 4b2f3e0..b171bb4 100644 --- a/17.2_variable/myapache2/README.md +++ b/17.2_variable/myapache2/README.md @@ -3,7 +3,7 @@ Role Name RĂ´le de deploiement apache sur une centos. -1 seul vhost +more than 1 vhost per host Requirements ------------ @@ -14,11 +14,15 @@ Role Variables -------------- http_port: 80 -servername: orsys.fr -serveralias: "www.{{ servername }}" -documentroot: /var/www/html/orsys.fr -accesslog: /var/log/httpd/access_orsys.fr_log -errorlog: /var/log/httpd/error_orsys.fr_log + +Hosts variables +-------------- +apache_vhosts: +- servername: orsys.fr + serveralias: "www.{{ servername }}" + documentroot: /var/www/html/orsys.fr + accesslog: /var/log/httpd/access_orsys.fr_log + errorlog: /var/log/httpd/error_orsys.fr_log Dependencies ------------ diff --git a/17.2_variable/myapache2/tasks/main.yml b/17.2_variable/myapache2/tasks/main.yml index b8b67b2..75f4ca5 100644 --- a/17.2_variable/myapache2/tasks/main.yml +++ b/17.2_variable/myapache2/tasks/main.yml @@ -29,7 +29,7 @@ - name: create documentroot file: - name: "/var/www/html/{{ item.documentroot }}" + name: "{{ item.documentroot }}" state: directory with_items: - "{{ apache_vhosts }}" @@ -37,7 +37,7 @@ - name: create index file copy: src: index.html - dest: "/var/www/html/{{ item.documentroot }}/index.html" + dest: "{{ item.documentroot }}/index.html" mode: 0644 with_items: - - "{{ apache_vhosts }}" \ No newline at end of file + - "{{ apache_vhosts }}" diff --git a/17.2_variable/myapache2/vars/main.yml b/17.2_variable/myapache2/vars/main.yml index 264638c..8c4b0a1 100644 --- a/17.2_variable/myapache2/vars/main.yml +++ b/17.2_variable/myapache2/vars/main.yml @@ -1,14 +1,3 @@ --- # vars file for myapache -http_port: 80 -apache_vhosts: -- servername: orsys.fr - serveralias: www.orsys.fr - documentroot: /var/www/html/orsys.fr - accesslog: /var/log/httpd/access_orsys.fr_log - errorlog: /var/log/httpd/error_orsys.fr_log -- servername: thomas.fr - serveralias: www.thomas.fr - documentroot: /var/www/html/thomas.fr - accesslog: /var/log/httpd/access_thomas.fr_log - errorlog: /var/log/httpd/error_thomas.fr_log \ No newline at end of file +http_port: 80 \ No newline at end of file