Skip to content
Snippets Groups Projects
Commit 03597f50 authored by florent.didion's avatar florent.didion
Browse files

ended

parent d0447a8e
No related branches found
No related tags found
No related merge requests found
Showing
with 245 additions and 96 deletions
2Nutvad/4Q5WdfiAO7wSsTud29O/Ke2dEbLkJkYQ+Uw=
/enZJcQ/tPK5TKu/KR1Y7nS4MYSgeuEz4vyQ72ahzRE=
ONWzI8XovnXfY4uodgHBVPrd1LAP40jPizQEbSlQPX4=
pP8tgE8LBRk+UnZMkg9dbQC5fgWJUrqqZbKi4yjjI2Y=
# ansible
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitedu.hesge.ch/florent.didion/ansible.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitedu.hesge.ch/florent.didion/ansible/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
$ANSIBLE_VAULT;1.1;AES256
38613662396333333839376231356231326337333639353363636663633935613065383236386232
6633333738663765373562366639626630363162656263340a383637336339613239646662636662
64363363656461666633623836363663343039626639616130313637376137653164386231363861
3439306565333430610a366363363263363135623230613031353730646461636564343861623565
63663630653662343264613732323463393663636430666464383036303839663730363337643930
3665636535383133353061383361303532383765333865626564
$ANSIBLE_VAULT;1.1;AES256
31646139363336636532353138396230393333616262323637393336653233643438653866303863
6439653063653038313961663662363536393264643965380a623365323266343664313063343239
32356137353662383630306361373136396330633963653439393238623131356662396663336564
3532666132646463630a383332666264366164646639393165376235303531633639353633303030
39663730383535666230346465616237663035393962313133393466666239326264663463653662
6365616461396635363538643462623938636561313136353862
......@@ -2,7 +2,23 @@
hostname: H1
interface:
- name: eth0
address: 1.0.0.10/24
address: 1.0.0.3/24
network:
- address: default
nexthop: 1.0.0.1
tunnel:
name: wg0
pubKey: /enZJcQ/tPK5TKu/KR1Y7nS4MYSgeuEz4vyQ72ahzRE=
address: 10.0.0.1/24
port: 51821
peerkey: pP8tgE8LBRk+UnZMkg9dbQC5fgWJUrqqZbKi4yjjI2Y=
peerendpoint: 3.0.0.3:51822
peeraddress: 10.0.0.2/32
pvtkey: !vault |
$ANSIBLE_VAULT;1.1;AES256
62616435323232616561316664306533313762653765323864383561366137656136336164623663
3034353165623066646134653363336262313336306137310a623061323539613739356565363931
37643865353739366562356235346463306166633237316331653937376363616637343162363262
3762653433333138630a333339616264316364393738663830363731303234666661376366383934
33663732663231343662393263333062333939626231633464363661336137373065633134343836
3931356565633065383739616231386131383437353665623763
\ No newline at end of file
......@@ -2,7 +2,23 @@
hostname: H2
interface:
- name: eth0
address: 3.0.0.20/24
address: 3.0.0.3/24
network:
- address: default
nexthop: 3.0.0.2
tunnel:
name: wg0
pubKey: pP8tgE8LBRk+UnZMkg9dbQC5fgWJUrqqZbKi4yjjI2Y=
address: 10.0.0.2/24
port: 51822
peerkey: /enZJcQ/tPK5TKu/KR1Y7nS4MYSgeuEz4vyQ72ahzRE=
peerendpoint: 1.0.0.3:51821
peeraddress: 10.0.0.1/32
pvtkey: !vault |
$ANSIBLE_VAULT;1.1;AES256
31356464383332383232306431353561303933346337393835653063313836653931653835386235
6164623661626235383464623265393033326632663562340a346237366163633939646333353562
32666536313333316631303932663333663838353234636434323462373232353433316462313931
3333383462313164660a363935623162383833633564383162373232346437626631353931373438
36623938653438616462383963366333623564333062616263363162313762646462343234356135
3333653738393038383064376631366532363665646331313233
\ No newline at end of file
......@@ -22,6 +22,6 @@
tasks:
- name: ping H2 from H1
shell:
cmd: ping 3.0.0.20 -c 3
register: cat
- debug: var=cat.stdout_lines
cmd: ping 3.0.0.3 -c 3
register: res
- debug: var=res.stdout_lines
<!DOCTYPE html>
<html>
<head>
<title>Welcome Hello</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome Hello!</h1>
<p>{{ tunnel.address }}.</p>
<p><em>Thank you for using jinja2.</em></p>
</body>
</html>
\ No newline at end of file
# ANSIBLE MANAGED
#
server {
listen 10.0.0.2:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
\ No newline at end of file
# ansible_managed /etc/wireguard/wg0.conf
# local settings for Host
[Interface]
PrivateKey = {{ tunnel.pvtkey }}
Address = {{ tunnel.address }}
ListenPort = {{ tunnel.port }}
[Peer]
PublicKey = {{ tunnel.peerkey }}
Endpoint = {{ tunnel.peerendpoint }}
AllowedIPs = {{ tunnel.peeraddress }}
# ansible_managed /etc/wireguard/wg0.conf
# local settings for Host
[Interface]
PrivateKey = {{ pvtkey }}
Address = {{ tunnel.address }}
ListenPort = {{ tunnel.port }}
[Peer]
PublicKey = {{ tunnel.peerkey }}
Endpoint = {{ tunnel.peerendpoint }}
AllowedIPs = {{ tunnel.peeraddress }}
---
- name: install wireguard
hosts: hosts
tasks:
- name: install wireguard
apt:
name: wireguard
update_cache: yes
- name: install curl
apt:
name: curl
update_cache: yes
- name: install nginx
hosts: H2
tasks:
- name: install nginx
apt:
name: nginx
---
- name: Configure wireguard
hosts: hosts
tasks:
- name: Create config file
ansible.builtin.template:
src: wg.j2
dest: /etc/wireguard/wg0.conf
mode: 0600
notify: Restart wireguard
- name: start wireguard and enable on boot
systemd:
name: wg-quick@wg0
enabled: yes
state: started
handlers:
- name: Restart wireguard
systemd:
name: wg-quick@wg0
state: restarted
- name: config nginx
hosts: H2
tasks:
- name: Create html file
ansible.builtin.template:
src: nginx.j2
dest: /var/www/html/index.nginx-debian.html
- name: Create config file to expose page on 10.0.0.2
ansible.builtin.template:
src: nginx_config.j2
dest: /etc/nginx/sites-available/default
notify: restart nginx
handlers:
- name: restart nginx
systemd:
name: nginx
state: restarted
- name: Verify conf
hosts: H1
tasks:
- name: Curl content
shell:
cmd: curl 10.0.0.2
register: res
- debug: var=res.stdout_lines
\ No newline at end of file
---
- name: install wireguard and configure wireguard
hosts: hosts
vars_files: "{{ inventory_hostname }}"
tasks:
- name: Create config file
ansible.builtin.template:
src: wg_vault.j2
dest: /etc/wireguard/wg0.conf
mode: 0600
notify: Restart networking
- name: start wireguard and enable on boot
systemd:
name: wg-quick@wg0
enabled: yes
state: started
handlers:
- name: Restart networking
systemd:
name: wg-quick@wg0
state: restarted
- name: config nginx
hosts: H2
tasks:
- name: Create file
ansible.builtin.template:
src: nginx.j2
dest: /var/www/html/index.nginx-debian.html
- name: Verify conf
hosts: H1
tasks:
- name: Curl content
shell:
cmd: curl 10.0.0.2
register: res
- debug: var=res.stdout_lines
\ No newline at end of file
ssh H1 ip r d default
ssh H1 ip r a default via 1.0.0.1
ssh H2 ip r d default
ssh H2 ip r a default via 3.0.0.2
\ No newline at end of file
ssh H1 ip r d default
ssh H2 ip r d default
ssh H1 dhclient -v mgmt0
ssh H2 dhclient -v mgmt0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment