41 lines
1.2 KiB
YAML
41 lines
1.2 KiB
YAML
- hosts: localhost
|
|
vars:
|
|
external_host: "audiobookshelf.rescla.me"
|
|
internal_url: "192.168.2.146"
|
|
tmp_path: ".tmp"
|
|
ftp_server: "192.168.2.64"
|
|
ftp_username: "ansible"
|
|
ftp_password: "3YffU5iTGQMyx87Vesu"
|
|
remote_file_path: "/appdata/nginx-lb/user_conf.d/{{ external_host }}.conf"
|
|
|
|
tasks:
|
|
- name: Ensures the {{ tmp_path }} folder exists
|
|
file:
|
|
path: "{{ tmp_path }}"
|
|
state: directory
|
|
|
|
- name: Generate nginx configuration from template
|
|
template:
|
|
src: templates/nginx-site.conf.j2
|
|
dest: "{{ tmp_path }}/nginx.conf"
|
|
|
|
- name: Upload nginx config file via FTP
|
|
ansible.builtin.command:
|
|
cmd: curl -k -T "{{ tmp_path }}/nginx.conf" "ftp://{{ ftp_username }}:{{ ftp_password }}@{{ ftp_server }}{{ remote_file_path }}"
|
|
|
|
- name: Clean up generated config
|
|
file:
|
|
path: "{{ tmp_path }}/nginx.conf"
|
|
state: absent
|
|
|
|
- name: Reload nginx config
|
|
ansible.builtin.command:
|
|
argv:
|
|
- docker
|
|
- --tlsverify
|
|
- -H=192.168.2.64:2376
|
|
- --tlscacert=.docker\ca.pem
|
|
- --tlscert=.docker\cert.pem
|
|
- --tlskey=.docker\key.pem
|
|
- kill --signal=HUP nginx-lb
|