|
| 1 | +--- |
| 2 | +# these are pretty hacky, but it should work |
| 3 | +# Get port information from the hosted service |
| 4 | +- name: get eru ports |
| 5 | + when: name == "eru" |
| 6 | + tags: [ configure_proxy, deploy ] |
| 7 | + become: true |
| 8 | + shell: | |
| 9 | + for c in $(docker ps | awk '/eru/{ print $1 }'); do |
| 10 | + docker port $c 5501 | cut -d ':' -f 2 |
| 11 | + docker port $c 5502 | cut -d ':' -f 2 |
| 12 | + done |
| 13 | + args: |
| 14 | + executable: /bin/bash |
| 15 | + register: eru_target_ports |
| 16 | + |
| 17 | +- name: get socket server ports |
| 18 | + when: name == "api-socket-server" |
| 19 | + tags: [ configure_proxy, deploy ] |
| 20 | + become: true |
| 21 | + shell: | |
| 22 | + for c in $(docker ps | awk '/api-socket-server/{ print $1 }'); do |
| 23 | + docker port $c 80 | cut -d ':' -f 2 |
| 24 | + done |
| 25 | + args: |
| 26 | + executable: /bin/bash |
| 27 | + register: socket_target_ports |
| 28 | + |
| 29 | +# everything from this point on is deligated to the nginx host |
| 30 | + |
| 31 | +- name: print target ports |
| 32 | + delegate_to: "{{ nginx_host }}" |
| 33 | + tags: [ configure_proxy, deploy ] |
| 34 | + debug: |
| 35 | + msg: | |
| 36 | + eru ports -- {{ eru_target_ports }} |
| 37 | + socket ports -- {{ socket_target_ports }} |
| 38 | +
|
| 39 | +- name: print target IP address |
| 40 | + delegate_to: "{{ nginx_host }}" |
| 41 | + tags: [ configure_proxy, deploy ] |
| 42 | + debug: |
| 43 | + msg: ip -- {{ target_ip_address }} |
| 44 | + |
| 45 | +- name: assert nginx config directory |
| 46 | + delegate_to: "{{ nginx_host }}" |
| 47 | + tags: [ configure_proxy, deploy ] |
| 48 | + become: yes |
| 49 | + file: |
| 50 | + state: directory |
| 51 | + dest: /etc/nginx |
| 52 | + |
| 53 | +- name: assert nginx sites-available directory |
| 54 | + delegate_to: "{{ nginx_host }}" |
| 55 | + tags: [ configure_proxy, deploy ] |
| 56 | + become: yes |
| 57 | + file: |
| 58 | + state: directory |
| 59 | + dest: /etc/nginx/sites-available |
| 60 | + |
| 61 | +- name: assert nginx sites-enable directory |
| 62 | + delegate_to: "{{ nginx_host }}" |
| 63 | + tags: [ configure_proxy, deploy ] |
| 64 | + become: yes |
| 65 | + file: |
| 66 | + state: directory |
| 67 | + dest: /etc/nginx/sites-enable |
| 68 | + |
| 69 | +- name: put configuration in place |
| 70 | + delegate_to: "{{ nginx_host }}" |
| 71 | + tags: [ configure_proxy, deploy ] |
| 72 | + become: yes |
| 73 | + template: |
| 74 | + src: "{{ item }}" |
| 75 | + dest: /etc/nginx/sites-available/{{ item }} |
| 76 | + with_items: "{{ templates }}" |
| 77 | + |
| 78 | +- name: link configuration to enable |
| 79 | + delegate_to: "{{ nginx_host }}" |
| 80 | + tags: [ configure_proxy, deploy ] |
| 81 | + become: yes |
| 82 | + file: |
| 83 | + state: link |
| 84 | + dest: /etc/nginx/sites-enabled/{{ item }} |
| 85 | + src: /etc/nginx/sites-available/{{ item }} |
| 86 | + with_items: "{{ templates }}" |
| 87 | + |
| 88 | +- name: reload nginx |
| 89 | + delegate_to: "{{ nginx_host }}" |
| 90 | + tags: [ configure_proxy, deploy ] |
| 91 | + become: yes |
| 92 | + shell: > |
| 93 | + docker ps | |
| 94 | + awk '/nginx/{ print $1 }' | |
| 95 | + xargs -n 1 docker kill --signal SIGHUP |
| 96 | + args: |
| 97 | + executable: /bin/bash |
0 commit comments