VPN setting

This commit is contained in:
git
2024-04-04 08:46:10 +02:00
parent 55167e20fc
commit b8369d0b28
17 changed files with 308 additions and 81 deletions

View File

@@ -1,4 +1,5 @@
ansible-playbook --ask-become-pass -i ~/.ansible/inventory playbook.yml
ansible-galaxy role init {role-to-create}
ansible-vault edit vault.yml
mkpasswd --method=sha-512

View File

@@ -6,7 +6,7 @@
restart_policy: unless-stopped
ports:
- '80:80'
- "{{ ip_admin }}:81:81"
#- "{{ ip_admin }}:81:81"
- '443:443'
volumes:
- "{{ docker_homepath }}/data:/data"

View File

@@ -0,0 +1,29 @@
---
language: python
python: "2.7"
# Use the new container infrastructure
sudo: false
# Install ansible
addons:
apt:
packages:
- python-pip
install:
# Install ansible
- pip install ansible
# Check ansible version
- ansible --version
# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@@ -0,0 +1,2 @@
---
# defaults file for wireguard-server

View File

@@ -0,0 +1,6 @@
---
# handlers file for wireguard-server
- name: wireguard-server restart
ansible.builtin.service:
name: wg-quick@wireguardserver
state: restarted

View File

@@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

View File

@@ -0,0 +1,15 @@
---
- name: Copy config
template:
src: ../templates/wireguardserver.conf
dest: /etc/wireguard/wireguardserver.conf
owner: root
group: root
mode: '0644'
notify: wireguard-server restart
- name: Start and enabled
ansible.builtin.service:
name: wg-quick@wireguardserver
state: started
enabled: true

View File

@@ -0,0 +1,13 @@
[Interface]
Address = {{ IP }}/24
DNS = 192.168.5.5
#PostUP = wifi-wireguard -e
#PostDOWN = wifi-wireguard -d
SaveConfig = false
ListenPort = 40041
PrivateKey = {{ priv }}
[Peer]
PublicKey = {{ wireguard_server_pub }}
AllowedIPs = 10.0.0.0/24, 192.168.5.0/24, 192.168.6.0/24
Endpoint = 185.61.86.153:51820

View File

@@ -0,0 +1,18 @@
[Interface]
PrivateKey = {{ wireguard_server_key }}
Address=10.0.0.1/24
PostUp=iptables -A FORWARD -i wireguardserver -o ens18 -j ACCEPT; iptables -A FORWARD -i ens18 -o wireguardserver -j ACCEPT; iptables -t nat -A POSTROUTING -o ens18 -j MASQUERADE;
PostDown=iptables -D FORWARD -i wireguardserver -o ens18 -j ACCEPT; iptables -D FORWARD -i ens18 -o wireguardserver -j ACCEPT; iptables -t nat -D POSTROUTING -o ens18 -j MASQUERADE;
ListenPort=51820
[Peer]
PublicKey = {{ wireguard_ntb_pub }}
AllowedIPs = 10.0.0.2/32
[Peer]
PublicKey = {{ wireguard_kate_pub }}
AllowedIPs = 10.0.0.3/32
[Peer]
PublicKey = {{ wireguard_tata_pub }}
AllowedIPs = 10.0.0.4/32

View File

@@ -0,0 +1,2 @@
localhost

View File

@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- wireguard-server

View File

@@ -0,0 +1,2 @@
---
# vars file for wireguard-server

View File

@@ -1,30 +1,56 @@
$ANSIBLE_VAULT;1.1;AES256
35613836323530633636393530383362636264653266353364373563333338626139323063343961
3664663931393161616231316236313738663461633934350a643535333363376265653464393831
66333763636239323835333630623335643232653932626463616130376661353538306530353739
3731636635363264350a636533633036623033353234353233306261323736373636616132366339
62646131313463313639333931653131306636633239656235623330633137663031656566333463
32353964376161383864336130346336643838333566383464373961646430643538636537313132
37376634373562633930323930306464613838366231363839356234343830333763643530656665
32643730356565653465326537373564386337663330396139396166396163333865633130643664
61616437353561653564616139346561343939663663316330303636366664383230633539353133
63633637353961383937393438343032303230633531613333353036643031323266336162366663
65383530383639323063333665393334316133623564346164653764613830643263643838353037
38643461613234346131306636353834636634363935633365633661353736633361383666396261
33636263633431623631326266623664633238393338643664343739386530363032366537323532
62396562633465363338663939363836396234656139633136623438613739383839313534356630
66663763313132646362363162396230666633303336343262386333643138356432613161336163
65653861363565633630316161613634386634666564366465353931353361313837373437303531
66613337323464353734346537353737646335383539646161333039653037383963343463366462
64303064623434356138646466373261666564396332396631336532316436363936623137386437
62326165386438376139346131623832323561303364373034393232306133386633393933366361
61303630356363636236643731653630323264303939643161633631323034633166373633303133
31383531646330353661613266396330396266643835363236383638623634356465373734383433
32623863366539656536346436343232613163353230303763396536653162393264643266663831
65343562373164316439613961356335373633663931313538326136666463663930346331373536
39353763383837373761653332643734363764656131356462313361396335613463303630396432
65366361623265323339323238636537663634373361653639383432363138396433626236393966
39633333313830333665343930323630333933373731656635643836663234663738343830643434
63663164393137643861326566383763656166343865393737346539386234333137613333633965
39636339303263616263646438626437396337306466386162306333363037663736623862343465
31623263326131643134353166356465323934323965393837656132393630626630
37333266343937363566636233393166306662653739643263343863653238393831666265313634
6533313731613065323865366332373266656337376161390a643265663061343135376266333732
38373434343133656233316532396663303963353765663537343135613165333130396362623335
3534646232306162610a336237643537303534343866636539653161316661643638313636306464
31663063303933353063366438383233633134393838343435626632366632326663633235336663
66373830306561333232363964386234373330663061393030346165646438383866356438376238
33663261393761616131373864356638663336336334666331633432616534623563333434623865
30343838656563313862323638666538383638663836386330383563626136363665326364356536
31646439326266333837666663353365613532616431313130366164303332636630383035303236
37656537373139623061623534646530636233366363373335306562613633346566396364346665
64373962643465363034353332343064366130646537303431356635613836393961663738643561
33623461646534646237356362646439313166366662613136393630633138636531373731336333
39613239343831313261323562303862636632323035363765386136313462343166373837636631
38346161346337653663323532663261373634373130306461643461376563326335373630326136
62306565353431366663326438376430303036396363383964306466326262393032653630353736
38663230383061653732653739333934633839646235666164333663383063366239653133373934
36306231393863303439373834666364633464646632616234613662326364613932656462356636
38653236356365346535653339343564323038616232366264333037666163613663366161653931
35643134356636373236383439373731616462326639653766383563646264313364336432383165
30333831373635363262646531373538346537343461353534656139646566653035383938633064
34303564393766366133633433656536353336316533663933613734373431333236393234343063
39336236393965643235653136383264376134626662303732343962376435353039623562323661
34663363353732663437323663633465656362663664643162326634373336633861353761653433
34303537306530346131323135386464636363363039626234363131663037366437346262643366
61373236383831623237396137636565346132346338316534343064613232396663373765646337
30633664313166656332376161643536306335626238646361656330373164653763313930633963
30316332623838386533613337346566333263646633386462656464353561326561626636346665
61623263663632626131613034393237363733393866303165366161656235333666343363656136
38396466373032653261353261356262623331376165636139623532356164326363646132663965
65313835643163316535653235653661626436313730313864623964613336646565356339363162
34396662353730353332383765386531306636353536653136386630623037633833323166383236
37666134346466303238333162313630333938613136613538313362393137636362343362336132
38636439666134306663343162306239353635613238663833623663356139336166356633363362
63396639366334356131636664393736623363393864306132626639303137633631373833326566
33326632636336616336386537623862396435346632366638316466373861663137633738663133
33303562663465633236386633353565353834653931353935306663653062383939393732613639
37613333373232333133333666316234383763306634353166306339613134633235383165306262
35326530643738336237376132346662396435353430343137613633383561316135636537343532
62663566376233386133343132343731303164643136306535646635303232353739613930626131
34303637626138356336646263386632386563376265626362643831333232353331353836376534
36666465613064393238343936636363393439663766383830366262636131336431373236636239
61646464633436623166303565623237333833653563336231363431643635616338353339633730
38656265383338663264353236393763323031396437663331633835663364383232663661616337
66663631313832396265666336336466663261613964386338613831316339613035383234653165
33343664363366306338333534353766633664633261633661336634366563646630643139633732
34383333343564323132663833373035343737346334386632343135373162333464306464346435
66636336653239323862643131663330623838303433353837363235393166363438373732333763
33343761396364386663323862663333386630633736616465343165633433643863653333333263
63306232656364623061333164653066353835363063663539623938346531383331386537653037
32383439666162393138303539383461326464616233663438303066343663326233326631663936
39623331623965366234343264396434663364633732306235643663613236386432376165386466
64323436363238653831343862353361393337613432393338623831633731643566633536613935
30626336396132333962303839626262313939623933356435346161313039636463616665333231
61613537303135313361323334633466363834666639363338316162396363363433306366366463
643261643466643031376538366635353264

23
wireguad-client-gen.yml Normal file
View File

@@ -0,0 +1,23 @@
- name: wireguard-client-gen
hosts: localhost
connection: local
vars_files:
- vault.yml
- zeus-vars.yml
vars:
user: ntb
IP_name: 'wireguard_{{ user }}_ip'
IP: "{{ lookup('vars', IP_name) }}"
priv_name: 'wireguard_{{ user }}_key'
priv: "{{ lookup('vars', priv_name) }}"
tasks:
- name: Copy from template
template:
src: roles/wireguard-server/templates/wireguardclient.conf
dest: ~/{{ user }}.conf
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_id }}"
mode: '0644'

View File

@@ -1,4 +1,8 @@
zfs_pool_name: bigpool
ip: 192.168.5.7
ip_admin: 192.168.6.7
mysql_host: "{{ ip_admin }}"
mysql_host: "{{ ip_admin }}"
wireguard_ntb_ip: 10.0.0.2
wireguard_tata_ip: 10.0.0.3
wireguard_kate_ip: 10.0.0.4

View File

@@ -76,21 +76,21 @@
# #- role: create_zfs_dataset
# - role: mariaDB_install
#- name: nginx
# hosts: zeus-public
# become: true
# vars_files:
# - zeus-vars.yml
# vars:
# docker_name: nginx
# zfs_dataset_name: "{{ docker_name }}"
# zfs_dataset_user: root
# zfs_dataset_group: root
# zfs_dataset_size: 100M
# docker_compose_file: nginx.yml
# roles:
# - role: create_zfs_dataset
# - role: docker_spin_up
- name: nginx
hosts: zeus-public
become: true
vars_files:
- zeus-vars.yml
vars:
docker_name: nginx
zfs_dataset_name: "{{ docker_name }}"
zfs_dataset_user: root
zfs_dataset_group: root
zfs_dataset_size: 100M
docker_compose_file: nginx.yml
roles:
- role: create_zfs_dataset
- role: docker_spin_up
#- name: email
@@ -133,25 +133,6 @@
# - role: create_zfs_dataset
# - role: docker_spin_up
#- name: Pi-hole
# hosts: zeus-public
# become: true
# vars_files:
# - vault.yml
# - zeus-vars.yml
# vars:
# docker_name: pi-hole
# password: "{{ warezjoe_password_un }}"
# zfs_dataset_name: "{{ docker_name }}"
# zfs_dataset_user: root
# zfs_dataset_group: root
# zfs_dataset_size: 1G
# docker_compose_file: pi-hole.yml
# roles:
# - role: create_zfs_dataset
# - role: docker_spin_up
#- name: Pi-hole
# hosts: zeus-public
# become: true
@@ -204,19 +185,29 @@
# - role: create_zfs_dataset
# - role: docker_spin_up
- name: dashboard-my-public
hosts: zeus-public
become: true
vars_files:
- vault.yml
- zeus-vars.yml
vars:
docker_name: dashboard_my_public
zfs_dataset_name: "{{ docker_name }}"
zfs_dataset_user: root
zfs_dataset_group: root
zfs_dataset_size: 100M
docker_compose_file: "{{ docker_name }}.yml"
roles:
- role: create_zfs_dataset
- role: docker_spin_up
#- name: dashboard-my-public
# hosts: zeus-public
# become: true
# vars_files:
# - vault.yml
# - zeus-vars.yml
# vars:
# docker_name: dashboard_my_public
# zfs_dataset_name: "{{ docker_name }}"
# zfs_dataset_user: root
# zfs_dataset_group: root
# zfs_dataset_size: 100M
# docker_compose_file: "{{ docker_name }}.yml"
# roles:
# - role: create_zfs_dataset
# - role: docker_spin_up
#- name: wireguard-server
# hosts: zeus-public
# become: true
# vars_files:
# - vault.yml
# - zeus-vars.yml
# roles:
# - role: wireguard-server