fixed tun/tap ifaces manage

This commit is contained in:
kashapovd 2021-10-29 07:47:39 +00:00
parent 79d547fcf9
commit 80076aa469
4 changed files with 34 additions and 24 deletions

View File

@ -1,9 +1,8 @@
--- ---
- name: Copying the STCP binary file - block:
block:
- name: Creating "{{ stcp_base_dir }}" directory - name: Creating "{{ stcp_base_dir }}" directory
file: path="{{ stcp_base_dir }}" state=directory file: path="{{ stcp_base_dir }}" state=directory
- name: Copying binary - name: Copying the STCP binary file
copy: copy:
src: multi_srv_raw src: multi_srv_raw
dest: '{{ stcp_binary_path }}' dest: '{{ stcp_binary_path }}'
@ -15,32 +14,39 @@
dest: '{{ loop_script_path }}' dest: '{{ loop_script_path }}'
mode: '0700' mode: '0700'
- name: Creating symlink to the STCP binary file - block:
block:
- name: Creating STCP instance directory - name: Creating STCP instance directory
file: file:
path: '{{ stcp_instance_dir }}' path: '{{ stcp_instance_dir }}'
state: directory state: directory
mode: '0600' mode: '0600'
- name: Creating symlink - name: Creating symlink to the STCP binary file
file: file:
src: '{{ stcp_binary_path }}' src: '{{ stcp_binary_path }}'
dest: '{{ stcp_instance_dir }}/multi_srv_raw' dest: '{{ stcp_instance_dir }}/multi_srv_raw'
state: link state: link
- block:
- stat:
path: '{{ clients_log_file_path }}'
register: file
- name: Creating STCP logging file - name: Creating STCP logging file
file: file:
path: '{{ clients_log_file_path }}' path: '{{ clients_log_file_path }}'
state: touch state: touch
mode: '0600' mode: '0600'
when: use_client_logging == true when: use_client_logging == true and not file.stat.exists
- block:
- stat:
path: '{{ users_file_path }}'
register: file
- name: Creating STCP users file - name: Creating STCP users file
file: file:
path: '{{ users_file_path }}' path: '{{ users_file_path }}'
state: touch state: touch
mode: '0600' mode: '0600'
when: use_auth == true when: use_auth == true and not file.stat.exsits
- name: Templating STCP server config - name: Templating STCP server config
template: template:

View File

@ -7,3 +7,4 @@
name: 'stcp_{{ stcp_instance_name }}' name: 'stcp_{{ stcp_instance_name }}'
state: restarted state: restarted
enabled: yes enabled: yes
when: run_stcp == true

View File

@ -2,10 +2,14 @@
link {{ internal_links_name }}{{ server_port + i }} {{ link_start_ip_addr | ipmath(4*i) }} {{ link_ip_mask }} link {{ internal_links_name }}{{ server_port + i }} {{ link_start_ip_addr | ipmath(4*i) }} {{ link_ip_mask }}
{% endfor %} {% endfor %}
{% if en_tap_iface == true %} {% if stcp_mode == "tap" %}
tap {{ tap_iface_name }} {{ tap_iface_ip_addr }} {{ tap_iface_ip_mask }} tap {{ tap_iface_name }} {{ tap_iface_ip_addr }} {{ tap_iface_ip_mask }}
{% endif %} {% endif %}
{% if en_tun_iface == true %} {% if stcp_mode == "tun" %}
tun {{ tun_iface_name }} {{ tun_iface_ip_addr }} {{ tun_iface_ip_mask }}
{% endif %}
{% if stcp_mode == "tuntap" or stcp_mode == "taptun" %}
tap {{ tap_iface_name }} {{ tap_iface_ip_addr }} {{ tap_iface_ip_mask }}
tun {{ tun_iface_name }} {{ tun_iface_ip_addr }} {{ tun_iface_ip_mask }} tun {{ tun_iface_name }} {{ tun_iface_ip_addr }} {{ tun_iface_ip_mask }}
{% endif %} {% endif %}

View File

@ -6,18 +6,17 @@ links_number: 8
link_start_ip_addr: 192.168.56.2 link_start_ip_addr: 192.168.56.2
link_ip_mask: 255.255.255.252 link_ip_mask: 255.255.255.252
ext_iface: eth0 ext_iface: eth0
stcp_mode: tun
stcp_runas: root stcp_runas: root
use_auth: no use_auth: no
use_client_logging: yes use_client_logging: yes
run_stcp: yes
stcp_mode: tuntap
#stcp_tuntaps #stcp_tuntaps
en_tap_iface: no
tap_iface_name: 'tap_{{ stcp_instance_name }}' tap_iface_name: 'tap_{{ stcp_instance_name }}'
tap_iface_ip_addr: 10.10.1.1 tap_iface_ip_addr: 10.10.1.1
tap_iface_ip_mask: 255.255.255.0 tap_iface_ip_mask: 255.255.255.0
en_tun_iface: yes
tun_iface_name: 'tun_{{ stcp_instance_name }}' tun_iface_name: 'tun_{{ stcp_instance_name }}'
tun_iface_ip_addr: 10.11.1.1 tun_iface_ip_addr: 10.11.1.1
tun_iface_ip_mask: 255.255.255.0 tun_iface_ip_mask: 255.255.255.0