diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..691037e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.venv/* diff --git a/README.md b/README.md index e69de29..006da26 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/inventory b/inventory new file mode 100644 index 0000000..1fe0b5f --- /dev/null +++ b/inventory @@ -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 diff --git a/main.yml b/main.yml new file mode 100644 index 0000000..d8e653e --- /dev/null +++ b/main.yml @@ -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 diff --git a/playbooks/00-install-system-packages.yml b/playbooks/00-install-system-packages.yml new file mode 100644 index 0000000..e69de29 diff --git a/playbooks/10-install-docker.yml b/playbooks/10-install-docker.yml new file mode 100644 index 0000000..9e9f6cf --- /dev/null +++ b/playbooks/10-install-docker.yml @@ -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 diff --git a/playbooks/20-install-wireguard.yml b/playbooks/20-install-wireguard.yml new file mode 100644 index 0000000..79bfaf5 --- /dev/null +++ b/playbooks/20-install-wireguard.yml @@ -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 }}" diff --git a/playbooks/files/wireguard/.gitignore b/playbooks/files/wireguard/.gitignore new file mode 100644 index 0000000..613f4b4 --- /dev/null +++ b/playbooks/files/wireguard/.gitignore @@ -0,0 +1 @@ +de.conf diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..e69de29