I\'m trying to make nginx load configurations from /vagrant
mounted by vagrant automatically.
So I edited nginx.service to make
Summarization previous answers and comments in terms of Ansible (if used for provision):
- name: Copy Nginx Systemd unit to /etc/
copy:
src: /lib/systemd/system/nginx.service
dest: /etc/systemd/system/nginx.service
remote_src: yes
- name: Change Nginx Systemd unit
lineinfile:
path: /etc/systemd/system/nginx.service
regexp: '^WantedBy='
line: 'WantedBy={{ vagrant_mount_unit }}'
state: present
- name: Systemd daemon reload
systemd:
daemon_reload: yes
- name: Disable Nginx
service:
name: nginx
enabled: no
- name: Enable Nginx
service:
name: nginx
enabled: yes
Replace {{ vagrant_mount_unit }}
by Vagrant mount unit name. It depends from mount point, e.g. if mount point is /home/vagrant/app
, unit name would be home-vagrant-app.mount
.