Deploy custom facts with nginx_vhosts
parent
4a3aed6974
commit
8caddedc68
|
@ -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
|
||||||
------------
|
------------
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
file: path={{ nginx_etc_dir}}/sites-enabled/{{ item.filename | default(item.name if item.name is string else item.name[0]) }} state=absent
|
file: path={{ nginx_etc_dir}}/sites-enabled/{{ item.filename | default(item.name if item.name is string else item.name[0]) }} state=absent
|
||||||
with_items: "{{ nginx_vhosts }}"
|
with_items: "{{ nginx_vhosts }}"
|
||||||
notify: ['reload nginx', 'restart nginx freebsd']
|
notify: ['reload nginx', 'restart nginx freebsd']
|
||||||
when: item.state is defined and item.state == 'disabled'
|
when: item.state is defined and item.state == 'disabled'
|
||||||
|
|
||||||
- name: FILE | Delete default vhost when explicitely defined
|
- name: FILE | Delete default vhost when explicitely defined
|
||||||
file: >
|
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
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"fact_nginx_vhosts":
|
||||||
|
{{ nginx_vhosts | to_nice_json(indent=8) }}
|
||||||
|
}
|
|
@ -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 --
|
||||||
|
|
Loading…
Reference in New Issue