Add docker and wireguard

main
Gašper Spagnolo 2023-04-16 21:42:35 +02:00
parent dc46810b58
commit 37960f82ec
9 changed files with 125 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.venv/*

View File

@ -0,0 +1,24 @@
# Ddvic server playbooks
## Dependencies:
System:
```bash
# apt install python3 python3-pip python3-venv
```
Python:
```bash
python3 -m venv .venv
source ./.venv/bin/activate
pip install -r requirements.txt
```
Ansible:
```bash
ansible-galaxy install -r requirements.yml
```
## Start
You shuold firstly specify server in the `invenvtory` file. Then start the root of repo and execute ` ansible-playbook -i inventory deploy_forcad.yml` command.

2
inventory Normal file
View File

@ -0,0 +1,2 @@
[ddvic]
192.168.1.182 ansible_connection=ssh ansible_ssh_private_key_file=~/.ssh/keys/id_ed25519_ddvic_server ansible_user=root

10
main.yml Normal file
View File

@ -0,0 +1,10 @@
---
- name: Setup ddvic server
hosts: ddvic
become: true
gather_facts: true
- name: Setup docker
ansible.builtin.import_playbook: playbooks/10-install-docker.yml
- name: Setup wireguard
ansible.builtin.import_playbook: playbooks/20-install-wireguard.yml

View File

View File

@ -0,0 +1,49 @@
---
- name: Install docker
hosts: all
become: true
strategy: free
gather_facts: true
become_method: sudo
tasks:
- name: Install required system packages
apt:
pkg:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- python3-pip
- virtualenv
- python3-setuptools
state: latest
update_cache: true
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu jammy stable
state: present
- name: Update apt and install docker-ce
apt:
pkg:
- docker-ce
- docker-compose-plugin
state: latest
update_cache: true
- name: Install Docker Module for Python
pip:
name: docker
- name: Ensure Docker is enabled and running
ansible.builtin.systemd:
name: docker
state: started
enabled: yes

View File

@ -0,0 +1,38 @@
---
- name: Install wireguard
hosts: all
become: true
strategy: free
gather_facts: true
become_method: sudo
tasks:
- name: Install required packages
apt:
pkg:
- wireguard
- openresolv
state: latest
update_cache: true
- name: Copy wireguard config
copy:
src: files/wireguard/de.conf
dest: /etc/wireguard/de.conf
owner: root
group: root
mode: 0600
- name: Enable wireguard service
systemd:
name: wg-quick@de
enabled: yes
state: started
- name: Grab the ip address
shell: ip addr show dev de | grep -Po 'inet \K[\d.]+'
register: ip
- name: Print the ip address
debug:
msg: "The ip address is {{ ip.stdout }}"

1
playbooks/files/wireguard/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
de.conf

0
vars/main.yml Normal file
View File