switch to correct way of templating server.ini

This commit is contained in:
kashapovd 2021-09-30 16:24:28 +07:00
parent 7d9b29bcd9
commit 7c48f59247
4 changed files with 22 additions and 42 deletions

View File

@ -8,6 +8,7 @@ loop_script_path: '{{stcp_base_dir}}/loop'
init_scripts_dir: /etc/init.d
clients_log_file_path: '{{ stcp_instance_dir }}/logc'
users_file_path: '{{ stcp_instance_dir }}/users.ini'
internal_links_name: stcp-{{ server_port }}-
# default stcp conf settings
stcp_mtu_size: 1500

View File

@ -43,42 +43,7 @@
when: use_auth == true
- name: Templating STCP server config
block:
- name: Templating config
template:
src: server.ini.j2
dest: '{{ stcp_instance_dir }}/server.ini'
mode: '0600'
- name: Creating STCP links
lineinfile:
path: '{{ stcp_instance_dir }}/server.ini'
line: 'link {{ internal_links_name }}{{ item }} {{ start_ip_addr.split(".")[0] }}.{{ start_ip_addr.split(".")[1] }}.{{ start_ip_addr.split(".")[2] }}.{{ (start_ip_addr.split(".")[-1])|int+4*(item-1) }} 255.255.255.252'
insertbefore: BOF
loop: '{{ range(links_number, 0, -1) |list }}'
- name: Enabling TUN
lineinfile:
path: '{{ stcp_instance_dir }}/server.ini'
line: 'tun {{ tun_iface_name }} {{ tun_iface_ip_addr }} {{ tun_iface_ip_mask }}'
insertafter: '^# stcp ifaces:'
when: en_tun_iface == true
- name: Enabling TAP
lineinfile:
path: '{{ stcp_instance_dir }}/server.ini'
line: 'tap {{ tap_iface_name }} {{ tap_iface_ip_addr }} {{ tap_iface_ip_mask }}'
insertafter: '^# stcp ifaces:'
when: en_tap_iface == true
- name: Enabling clients logging
lineinfile:
path: '{{ stcp_instance_dir }}/server.ini'
line: 'clients_log_fname {{ clients_log_file_path }}'
when: use_client_logging == true
- name: Enabling users auth
lineinfile:
path: '{{ stcp_instance_dir }}/server.ini'
line: 'users {{ users_file_path }}'
when: use_auth == true
template:
src: server.ini.j2
dest: '{{ stcp_instance_dir }}/server.ini'
mode: '0600'

View File

@ -1,5 +1,13 @@
{% for i in range(links_number) %}
link {{ internal_links_name }}{{ i+1 }} {{ link_start_ip_addr | ipmath(4*i) }} {{ link_ip_mask }}
{% endfor %}
# stcp ifaces:
{% if en_tap_iface == true %}
tap {{ tap_iface_name }} {{ tap_iface_ip_addr }} {{ tap_iface_ip_mask }}
{% endif %}
{% if en_tun_iface == true %}
tun {{ tun_iface_name }} {{ tun_iface_ip_addr }} {{ tun_iface_ip_mask }}
{% endif %}
SPLIT_TCP_SESSIONS {{ split_tcp_sessions }}
print_info {{ en_print_info }}
@ -11,3 +19,9 @@ FLUSH_SORT_ADD_TIME {{ flush_sort_add_time }}
server_http {{ stcp_http_srv_addr }} {{ stcp_http_srv_port }}
enable_peer_to_peer {{ en_peer_to_peer }}
INTERFACE_MTU {{ stcp_mtu_size }}
{% if use_auth == true %}
users {{ users_file_path }}
{% endif %}
{% if use_client_logging == true %}
clients_log_fname {{ clients_log_file_path }}
{% endif %}

View File

@ -3,8 +3,8 @@
server_port: 5006
links_number: 8
start_ip_addr: 192.168.56.2
internal_links_name: stcp # pattern
link_start_ip_addr: 192.168.56.2
link_ip_mask: 255.255.255.252
ext_iface: eth0
stcp_mode: tun
stcp_runas: root