Deploy custom facts with nginx_vhosts

pull/27/head
Emilien Mantel 2016-11-29 14:32:27 +01:00
parent 4a3aed6974
commit 8caddedc68
5 changed files with 25 additions and 1 deletions

View File

@ -14,6 +14,7 @@ Features:
- Preconfigured vhost templates (should work on many app) - Preconfigured vhost templates (should work on many app)
- Auto-configure HTTP2 on SSL/TLS vhosts - Auto-configure HTTP2 on SSL/TLS vhosts
- Manage dynamic modules (install and loading) - Manage dynamic modules (install and loading)
- Deploy custom facts.d with sites config
Requirements Requirements
------------ ------------

View File

@ -22,3 +22,5 @@
file: dest="{{ item.dir }}" owner="{{ item.owner }}" mode="{{ item.mode }}" state=directory file: dest="{{ item.dir }}" owner="{{ item.owner }}" mode="{{ item.mode }}" state=directory
with_items: "{{ nginx_dirs }}" with_items: "{{ nginx_dirs }}"
- name: FILE | Create ansible facts dir
file: path=/etc/ansible/facts.d state=directory

View File

@ -77,3 +77,14 @@
state=link state=link
notify: ['reload nginx', 'restart nginx freebsd'] notify: ['reload nginx', 'restart nginx freebsd']
when: nginx_default_vhost is none when: nginx_default_vhost is none
- name: TEMPLATE | Deploy facts
template:
src=etc/ansible/facts.d/nginx.fact.j2
dest=/etc/ansible/facts.d/nginx.fact
mode=0644
register: fact
- name: SETUP
action: setup
when: fact.changed

View File

@ -0,0 +1,4 @@
{
"fact_nginx_vhosts":
{{ nginx_vhosts | to_nice_json(indent=8) }}
}

View File

@ -235,6 +235,12 @@
- name: -- Add HTML file hello -- - name: -- Add HTML file hello --
copy: dest="{{ nginx_root }}/test-htpasswd.local/public/hello/index.html" content="hello\n" copy: dest="{{ nginx_root }}/test-htpasswd.local/public/hello/index.html" content="hello\n"
# -------------------------------- # --------------------------------
# Test custom facts
# --------------------------------
- name: -- CHECK FACTS --
assert:
that: "'{{ ansible_local.nginx.fact_nginx_vhosts[0].name[0] }}' == 'test.local'"
# --------------------------------
# Simple vhosts tests # Simple vhosts tests
# -------------------------------- # --------------------------------
- name: -- VERIFY VHOSTS -- - name: -- VERIFY VHOSTS --