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

View File

@ -6,4 +6,5 @@
systemd:
name: 'stcp_{{ stcp_instance_name }}'
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 }}
{% endfor %}
{% if en_tap_iface == true %}
{% if stcp_mode == "tap" %}
tap {{ tap_iface_name }} {{ tap_iface_ip_addr }} {{ tap_iface_ip_mask }}
{% 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 }}
{% endif %}

View File

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