Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change wireguard config setup #33

Merged
merged 9 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 42 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,57 +13,79 @@ As the login is done via ssh make sure that the ssh key is registered at your id
That way Ansible will be able to automatically detect the right ssh key and connect to the server.

## hosts
If you want to deploy to a new gateway you need to add it to the `hosts` file in the repo, just compare it to brunsbach and add your own details.
If you want to deploy to a new gateway you need to add it to the `hosts.yml` file in the repo, just compare it to brunsbach and add your own details.

If you set enable_wireguard_exit to true ansible will deploy wireguard and attempt to generate a mullvad config.

## Mullvad
This ansible script uses [wg-conf-gen](https://github.com/ffsh/wg-conf-gen) to generate a Mullvad wireguard configurration.

The python script will call the Mullvad API with the details you provide in host_vars (see below).

It will select a random gateway based on country and city.

### host_vars/$gatewayname.yml
You also need to supply your fastd secret as an encrypted secret, you get the password via the NOC Team.

To create a new fastd secret, execute the following, this will ask you for a password and open an editor.
```
```bash
ansible-vault create --vault-id fastd_key@prompt host_vars/$gatewayname.yml
```
Enter
```
fastd_secret: $yourkey
# If you want to use a wireguard exit
wireguard_interface: |-
[Interface]
...
wireguard_peer: |
[Peer]
...

The config has the following options.

| option | comment |
|:-------------|:-----------------------------------------------------------------------------|
| fastd_secret | fastd secret key |
| wg_device | Optional but you can put the name here that was generated by mullvad |
| wg_pk | Wireguard private key provided by mullvad |
| wg_address | ipV4 and ipV6 address provided by mullvad |
| wg_country | Country supported by mullvad |
| wg_city | A City that mullvad has in your selected country |
| ffshmon_mail | The email that should be used to send alerts if the wireguard tunnel is down |
| ffshmon_pw | The password for the email |

For available country and city check here: https://mullvad.net/de/servers

Example config:

```yaml
fastd_secret: 1234df132fssd...
wg_device: Mellow Pony
wg_pk: aDfkfdsgnn1232345...
wg_address: 1.2.3.4/32,fxx...../128
wg_country: Netherlands
wg_city: Amsterdam
ffshmon_mail: wg-mon@freifunk-suedholstein.de
# Check KeePass
ffshmon_pw: ...
ffshmon_pw: secretpassword
```
save and close the editor, done you added your secret :)

You can change the content any time by
```
```bash
ansible-vault edit --vault-id fastd_key@prompt host_vars/$gatewayname.yml
```

## Usage

Run playbook on all gateways listed in `hosts`:

```
```bash
ansible-playbook --vault-id=fastd_key@prompt setup.yml
```

Run playbook on one host
```
```bash
ansible-playbook --vault-id=fastd_key@prompt setup.yml --limit $hostname
```

Run only the roles with the specific tag, to see which role is attached to which tag open `setup.yaml`:

```
```bash
ansible-playbook --vault-id=fastd_key@prompt setup.yml --tags "ssh keys"
```

These can also be combined:

```
```bash
ansible-playbook --vault-id=fastd_key@prompt setup.yml --limit $hostname --tags "oh-my-zsh"
```
50 changes: 21 additions & 29 deletions host_vars/barnitz.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
$ANSIBLE_VAULT;1.2;AES256;fastd_key
31636363336361613566666436383339666237316662366637313866643938333862616332393237
6530626264633232393437623839316263626630646138620a323663653433616135653665373633
33383738613031383664363564656464393436626537666630613761346464376538386561643731
3963643339633361320a636436643463336636366363353533333662336236633433393835656131
34313439323939353366336438343263303734633138393263636465383131306134626638393837
63653130396232656261313936666538663262346237653839303166323438343937363461366632
61393961613438306566616436643565323030306536363132383937303563326531326263646463
65386236323539326331353937333035663737393031613661323062356434373333666263393633
39393432353862626138373134316662643231316265323635613735353035306131363034356465
39303066393033393433666338613236643563616338636461626235626138613535623733373933
32303336633366363664343438643237363935616661373038303065363235643063353661303637
63343261323833653865653137623330653139323137333030326263343232363034653731613230
38656234663532396364316532393737366235636236636463643863643965303861636135643938
36666538396239653031353732623666386637323432346264656233306237353261326337373236
66326634626537616431323866323266613261623533636130633339373039333238623462326133
30316138303936666163373631616439303165616434333334623461393832636366383862366638
35353736646265386561633961346437383737616661333165343335386631633238353763336663
64363663633838356135306335613237383733313962313936343066616334393530643233363432
66663565383637643562373139303633373930353133346637343165313838336363323039396632
32643265653535386537376263383165643864346366643665383164616632326339666535666362
35663837656462303866643939373862633635323731376630633032323539323465326530353030
39373264623232636639666562313738376335393635383036366665356436313164653364623832
62373765393835393438383038653836356433343838343935363061343631303161323265666665
65396331363366303266306636313333636138656534633765393632396366333466316464396263
63396236636163383638323064333866666531346662626536313231343638383363623333663762
35326433356564663666666235646564633933643036646531313335666236353465376439383134
37326365396464363330333263353735353862646130303332653133393365643730313133353037
35326530313637663131326332333536393732383538383233623638646261313938353937383961
6365
30353165366633313837613634396638336534353663626566626536623931336236303662646439
6335623633623064393034303336336566366234623039360a316136323963383862656431653534
64623431383731313062633561326637393535316139616537313963633836623466383735326635
6263303634393430340a656262363665303564663963343837633031373765646666316265326232
35303265653635663834393038626334616565633636646436363233656631373932643764383761
35313739666662316333626433653462333934613635316136346261663161303161303832326633
64656463633439376331656130393932626364353664383736323333306162323335303062623738
62366231383662316663616662623764653336313737396263643833663431663239616432633565
66653239346638396464666161393436303964653465343334316131633939366463633764613237
64323163323332396437316234353735323232626238353336386131343335366630383862366139
62383037343864613338383039396237343439646336386164316137646539643834663836303637
32646235346562306331303263346534333965643662663561343763653636356531626263323330
33616531336538303539666530663932646463343238376564303430633137343431623632653238
61653163623130653063386538353431643063383062623237623433326435363835636633326333
66333731663866353238323234623135643065306365393839303338363663393930396231356564
64366231336563643662383164303933623933613731326366356339306230643033343564376563
35643036323036313338396131393437393063613234313363393062316163316463356437326665
63396339303032303435376661626661643337633038653461333563343261393065333163646632
33396530313031643435653261333039386566323235623664653838376232623763396462306331
34316366636564303732373532386232633362396337323862623762333732323639333631353532
3061
50 changes: 21 additions & 29 deletions host_vars/beste.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
$ANSIBLE_VAULT;1.2;AES256;fastd_key
62646264366537343736363033373239373961316138343265313836313738626539343238326534
3634376262376435366139396536623632383834373233340a336431356261623966313665626230
61343762373866633761336566663462353437353363383461353136653466383863383433336338
3232666562636534300a376633636632346532616635306435333763373064636636663937343961
36363963633635353632376162393733346563306139383832666436646232653030646130633064
38336436626632353165306162323730643631306662393633373066343561396661386534633362
31383665643063326236643935616133323432656362653664643062363238643063393630636463
65376164346561636663396163373165613239366230343565656232323038356663386666303332
33333031356333323137663433383535396663383632666230333763313264323034316633316262
34336461343338383636336330313461653963616565333061636262376161383335316533643066
39356663626435326335363134616132396433303437386464666235316163643565623133376566
65363063643962336166363633636137643663336365663838313538353039336230363465343431
37643561396265653531613032663033613337343731386136343939343537363339363964613035
36376131323166626365353536623162396665323230333764306438383436343534633961613631
36373138306638616365303530653032336263636136366165663430376437633765343566316432
39636639306633613432636464326161653636306664323338333562643530653538326433353038
63343835326665663139393239346530336361343734373534616164343938323364383539636530
63306666343431633533356564663239663837303432616663626463653731656433643130636165
39623733386537376232343737303131663163616630303466613333323130346361343463393563
61646239363530326565643137353261613935313333323838353561636635323962613430656531
65316239643464616237346165393536653961646463663937663962346165393339366339393030
37653430346439633063386465653263343833366134616266343933663364623564303438633362
33303462333130323166376639303631333766366332346435306331386636333134306462346532
66366333373039396536616261666339343566353765623738626530323537616133383464363230
34386536366334356634376138656130333339376632333762353461363730316362613034346338
33386637613530653464636433383666363530663439343666386566383339343935613162363761
36633365353534636364313162633635366566346565626639333033303765366661656161356663
39666533323030393736353664616432303066343330613933343562616239396461653965636430
37323033663466386161663639616530376465626561333265626462663266383034
62623333663332646538666139616464333839373239623132366531333831666366306564313432
6132623336336462303532393064353763313934383566380a313732613130653838613966356534
36393535306566326539333231366238316338393039353164343337366535636539633466373563
3762303832613138370a633062336535383638373362326264323838623166333861343065333231
64343231306539653366396536313766653962616462653064646663636439613334343563636239
35653539323233303339623030613061663136373032313031373833356431643730396662646138
63376331363531373534623264393636646261623661326230616465396164343032613762393164
33373861393134303237393839383837343634383561666537623062396664616163346636656233
32383634393230386437356539643137393037313638626466373333303833623264333561353362
39383232336530373137613432333330623230633931376461343062333566373738646133636339
35663064636131633262303736393035633664646464373065343739356361373561383933333263
64623238313535303632383930363239663161653139623164346338353035313665326231646565
37346139353733633262663461656165343361386335366665616536623266366236643635333764
33376165373935646138333731386165376234306464323835376664633438656166636263343433
32336238663261376337663637316232623631363036323938386235643862663862303531376563
38383434663632656634656166363565363031633636393931653265343832623137333230366637
37613237656432643631366562313462383335333236376537313363376265333136333632653666
64633137643038313035333865656135386136303366393164306637303734313539323461383637
38336161633863366336316666616234373066333065653061363161326165346137636535663664
64646533306431623964303736653331633230636661623136646237323136663866623666303463
30376563613962613135626461343835393138386337333130303131363663323366
50 changes: 21 additions & 29 deletions host_vars/bille.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
$ANSIBLE_VAULT;1.2;AES256;fastd_key
37346636306463633933323336353338366330303164363130346633316162643831353565623432
3166353935323332633661313262343530323066323735660a303734653264363233353533303630
61366138376338663033373361666130313230353238353761353533636533376631353664316462
3032353465333562640a366339346634646237326132643335383938323835643331353265386439
39613234326430356134393936623031623664316431616230313066343165373835326534653663
63363263646231396531303863616666383463616238323238313664396430313037663463306465
30316536643863343735616232626566636461323163303935363363306131653832373965393334
38376362646431663934616132303137306237346333646665303831656431623331346436333137
38336563646433383335663364383961313030636131343132383835393630643561386239663263
36636561356366613166663665663131666461313636626639636132316166356434666438333538
61343632316535393062333037616464623138393533383939303862306361653135303861646432
35376363666265346562316138366333333064336439353537656633616337306239656334356134
62653439353034383933346638383663646362333761636163653739326165626362336231613339
62343032353936386530376438396139316334323262343735646461346361333266396661353430
30653430373563383262623132313432323761333063656133393462373932633137653032326131
62316630636562623135656361343430623238633162636165663630333862663562393636326233
37386462666664613165656435363530623738666432366431316663353439643363336132643931
61303238343136346537316266633134393436386239653431613961313435333831396336626236
31386566303331616630633438353061666334623035656539646364326663323338313535643035
31386334653432363439396633663366666332626235343835633664633865653335396638333233
34393933326237373561383039396631353335343266633263666662643662363839633339663734
37323964396534326134613633346662396534383332643237396262626232613863323238646537
61303134643161346564336634393938373032383862313766393331656465386337353035656230
30363661386431383738646335643837616635313536613738613235643466393237363466303161
31646435613963316430363638656330666537653834303133333537373234333834373037363835
36373036396134663966623562616263656264353835356163366364623831346262333133326461
63356537623565313834613134616132383738633234613861613261333366313439383735326337
65363338316533363834656362373462366631323062666636363430303830636132396634663733
3635
36636439333831343465626631323737613065346238306165386661663539666665623432336439
6164653730346661646364343037373538666463666638660a386534306135363134623431666233
35346332636235333932643965303033336236656531326435626632346531343730666666313534
3666306138633136660a313234343964356161616562356263656562323862303037383834636633
61306333336432313634666366643338633065313531383164636335393339313935613662646265
32363434373462616161633433613231303532633837373233656234353333616266323361316664
37653337323030663531356134356633353839313564666636323738343862643236306664656563
61313837363438353531333437616462643764363162666536313137613565353232363430646666
31353566396238613537316666653437313639363133316166616134643765383435396630373935
35646634373638343631626139363363323065626538383732373735386139336364633563636633
66663931653033646464346139333738313232303635306133393364363961336637616262303833
63313736373562396338666662386163386361313030316539326232383038333134353564666131
63373862306236353761333261623634613064393835633565313836353935306438633035383832
64313530613937626564303766353036636138663365633436353839636433303830373937346439
65626363323966323066363866363663386433383961663939656262396463663632363533303563
66623135323537613761616131353835373333653830313430613734303562653861636232643332
62363363363231316661656365383937366466393337353365623534373332303932656630376334
65303865386161323238306663383961623534613063383636393261313061343738633430346163
33383837396661346433373366396262633761346165343130306233303035396432643536313766
33633532363866396136616338303139343464653135633866313632636637383762356135656264
3138
50 changes: 21 additions & 29 deletions host_vars/brunsbach.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
$ANSIBLE_VAULT;1.2;AES256;fastd_key
37653666643834343266376334633065303734653235313165663536383933383635616331653264
6163366238366366663033623636643666333236663831360a656535626162643633326237633036
35376638633039626265623565363231323432333966306562333738386131636362323133383739
3335336665666664660a636166356239393631633465613061333066303033656232636363393232
39323634613362356332343964646335353835363530303539656630653065313739316534613062
35656465353732373865393439356638373431363566376338653561656236353264313036313934
63356564333436336437323664653533646537303265376337373261373731646630393562313833
37613465323963353061343363656436366264353265343839303732323135323831636538643038
63646163313431363332326463393964396538383131306539363433663432366562636332666665
61633831636536313065316661663931396665386363653630373638643534653033306535316234
61656636666562653563613831376363313233626561333465643862393832343432366235623963
31383961376265373835633066656339643065393462636561616236633438333564353061656439
35613633393264343630343361356265653832636635383936343237323332336333393536313862
38306633663435323230653930363664333264336263653239633838333962356266633231656634
34613438633065353234646435353735653936656530323166623430393864353261353936636435
38663534313935313036346462366664366361613233396166616563373265396161626465393139
35376464393432343262633962636663643938323932303639333437346265386435346166313732
31626666333030653734323334656339373264346463666530323835613839316563313939316162
39656665316134613537353664356339616634633931663634346164353161613434356164303533
66343630393238643633373763623134333135363736653231373832316133343032383066393731
66333235393662313735636235346635623939636235643536343538313038636233356666663631
65633063306233616231313561323930626131333339636438646635373062306138363938303830
66663630646432653832623937656238303465323066616233623932336430373164633766323662
32396337643630343730323435383166333335613666613230636532343661393161363766353566
35373031343065383536383537353835373863396531643931353939656166343663353732343564
38356565653766373963376638386138613261626637313166353162376632326538623038396139
38643132373865366139303034623731383538376132346432616135653465313961613263633938
33626630646237336463623666303931613566343339333132323362613136323435393362653763
34636536386366653066336237636233613339303265383939616335313639373830
32353932343362303661303631326539333861353564373065393430353036366630316237383862
3634376239393138336135343961376430393730346465320a333233306639303662633439353264
64316563373134666433633763643239373863346635663063343336643166373865376363393931
3862663630333634650a646534363031326261376561633266616434376334386563623961653666
34343565353630613834393566373835343331616331643437336363306138303437343731373332
37373262333030346436663030643132336265303864653464376266636465386131356239356466
33373766663836333938393938323132613230316338643962643137396665356565393761653831
66623263646263316261663638383837663835666163666434373436353038343064313964613437
64396639626162313465303361373938333762316232343065376562316238363765333466393033
65393531663963643338666133653438393737653632646434356138653565313165623335396530
30653931653965373334663431363435306164616162616333376634356633393365346137396432
62646337343365366562663433356536303335333832623565386235326532393261663136653163
33306632643232643732353533623438323539363361626138313337623833616164343638356265
62306636646234613362396236643039336331353533626565313535326635646330343838393862
39383065373134386164363035363538303935653062653334323037636133666564636534366565
66363436646636613038356437393063323865303064663033346431633031633331366333363537
35316533376332376262636466386165343230373365343731393463356162626163333864323439
61666566653739306563623364646337363530396439393061396239303366666330616130336364
38616232353630376431643665326630333433383832316230306264353162653932663035343439
63353664393235373662346562303461303963393537393439663132623338653838316639343635
61633433623237636463373137343265646130653964613139373466393633306666
Loading
Loading