Skip to content

Commit dbba00c

Browse files
authored
improved conditional netbox; added restart/reload of nginx after installation / vhost changes
1 parent 0180c17 commit dbba00c

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

Diff for: handlers/main.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
---
2+
- name: "Restart nginx"
3+
ansible.builtin.systemd:
4+
name: nginx
5+
state: restarted
6+
become: true
7+
28
- name: "Reload nginx"
39
ansible.builtin.systemd:
410
name: nginx

Diff for: tasks/add_ipv6_address.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@
3131
# state: present
3232
# delegate_to: localhost
3333
# when:
34-
# - netbox_url
35-
# - netbox_token
34+
# - "netbox_url is defined"
35+
# - "netbox_token is defined"
36+
# - "netbox_url is not none"
37+
# - "netbox_token is not none"

Diff for: tasks/create-vhost.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
src: "vhost.conf.j2"
55
dest: "/etc/nginx/{{ (ansible_distribution in ['Ubuntu', 'Debian']) | ternary('sites-available/' + vhost.domain, 'conf.d/' + vhost.domain + '.conf') }}"
66
mode: "0644"
7+
notify:
8+
- "Reload nginx"
79
when:
810
- "not nginx_vhost.stat.exists"
911
become: true

Diff for: tasks/install-nginx.yaml

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
name: nginx
55
state: present
66
become: true
7+
notify:
8+
- "Restart nginx"
79

810
- name: "Adjust NetBox documentation: Create http service"
911
netbox.netbox.netbox_service:
@@ -17,8 +19,10 @@
1719
state: present
1820
delegate_to: localhost
1921
when:
20-
- netbox_url
21-
- netbox_token
22+
- "netbox_url is defined"
23+
- "netbox_token is defined"
24+
- "netbox_url is not none"
25+
- "netbox_token is not none"
2226

2327
- name: "Adjust NetBox documentation: Create https service"
2428
netbox.netbox.netbox_service:
@@ -32,8 +36,10 @@
3236
state: present
3337
delegate_to: localhost
3438
when:
35-
- netbox_url
36-
- netbox_token
39+
- "netbox_url is defined"
40+
- "netbox_token is defined"
41+
- "netbox_url is not none"
42+
- "netbox_token is not none"
3743

3844
- name: "Check if default vhost is enabled"
3945
ansible.builtin.stat:

0 commit comments

Comments
 (0)