Trigger service restart on change

This commit is contained in:
Andrew Ying 2023-11-19 22:48:05 +00:00
parent e548f85da3
commit a910018c0b
2 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1,10 @@
---
- name: "Restart netbox service"
ansible.builtin.systemd_service:
name: netbox
state: restarted
- name: "Restart netbox-rq service"
ansible.builtin.systemd_service:
name: netbox-rq
state: restarted

View file

@ -37,6 +37,9 @@
dest: "/opt" dest: "/opt"
remote_src: true remote_src: true
when: netbox_install when: netbox_install
notify:
- "Restart netbox service"
- "Restart netbox-rq service"
- name: "Create symbolic link" - name: "Create symbolic link"
ansible.builtin.file: ansible.builtin.file:
@ -96,11 +99,17 @@
group: "{{ netbox_group }}" group: "{{ netbox_group }}"
mode: '640' mode: '640'
register: netbox_config register: netbox_config
notify:
- "Restart netbox service"
- "Restart netbox-rq service"
- name: "Run Netbox installation/upgrade script" - name: "Run Netbox installation/upgrade script"
ansible.builtin.shell: ansible.builtin.shell:
cmd: /opt/netbox/upgrade.sh cmd: /opt/netbox/upgrade.sh
when: netbox_install or netbox_config.changed when: netbox_install or netbox_config.changed
notify:
- "Restart netbox service"
- "Restart netbox-rq service"
- name: "Record installed Netbox version" - name: "Record installed Netbox version"
community.general.ini_file: community.general.ini_file:
@ -119,6 +128,8 @@
owner: "{{ netbox_user }}" owner: "{{ netbox_user }}"
group: "{{ netbox_group }}" group: "{{ netbox_group }}"
mode: '755' mode: '755'
notify:
- "Restart netbox service"
- name: "Create /etc/systemd/system/{{ item }} file" - name: "Create /etc/systemd/system/{{ item }} file"
ansible.builtin.template: ansible.builtin.template: