diff options
author | Aaron LI <aly@aaronly.me> | 2018-06-24 17:08:54 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-06-24 17:08:54 +0800 |
commit | b8f4a6b806ecaf157cb5e4f822c7a5c2d34bdf09 (patch) | |
tree | 421cf54a759ef77cdb459279a5f1f8815d26ccff /roles/shadowsocks/tasks/main.yml | |
parent | 23e763e7f75093c3a2ad21c40ce3644984df0098 (diff) | |
download | ansible-dfly-vps-b8f4a6b806ecaf157cb5e4f822c7a5c2d34bdf09.tar.bz2 |
shadowsocks: Support multiple instances (share with others)
Add the "shadowsocks" rc script that allows multiple instances (based
on the uwsgi rc script).
Update the role and vars to setup two shadowsocks instances.
Diffstat (limited to 'roles/shadowsocks/tasks/main.yml')
-rw-r--r-- | roles/shadowsocks/tasks/main.yml | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/roles/shadowsocks/tasks/main.yml b/roles/shadowsocks/tasks/main.yml index 414ddee..26059fa 100644 --- a/roles/shadowsocks/tasks/main.yml +++ b/roles/shadowsocks/tasks/main.yml @@ -4,29 +4,48 @@ name: shadowsocks-libev state: present +- name: copy rc script + copy: + src: shadowsocks + dest: /usr/local/etc/rc.d/shadowsocks + mode: 0555 + - name: setup configuration file + vars: + profile: "{{ item }}" template: src: config.json.j2 - dest: /usr/local/etc/shadowsocks-libev/config.json + dest: /usr/local/etc/shadowsocks-libev/{{ profile.name }}.json mode: 0640 + with_items: "{{ shadowsocks.profiles }}" + +- name: setup rc.conf + lineinfile: + path: /etc/rc.conf + regexp: '^shadowsocks_profiles=.*\b{{ item.name }}\b' + line: 'shadowsocks_profiles="${shadowsocks_profiles} {{ item.name }}"' + with_items: "{{ shadowsocks.profiles }}" + +- name: enable service + lineinfile: + path: /etc/rc.conf + regexp: '^shadowsocks_enable=' + line: 'shadowsocks_enable="YES"' notify: restart-shadowsocks -- name: enable and start service - command: rcenable shadowsocks-libev +- name: start service + command: service shadowsocks start - name: show client-side config vars: config: | "{" - "server": "{{ ansible_ssh_host }}", - "server_port": {{ shadowsocks.port }}, "local_port": 1080, - "password": "{{ shadowsocks.password }}", - "method": "{{ shadowsocks.method }}", - "timeout": 600, - "fast_open": true, - "reuse_port": true, - "no_delay": true + "server": "{{ ansible_ssh_host }}", + "server_port": {{ item.port }}, + "password": "{{ item.password }}", + "method": "{{ shadowsocks.method }}" "}" debug: - msg: "{{ config.split('\n') }}" + msg: "profile<{{ item.name }}>: {{ config.split('\n') }}" + with_items: "{{ shadowsocks.profiles }}" |