abyayala/tasks/rap.yml
Bet@ 8c1a6e13e4 repositorio inicial de proxy reverso, basado en Latina.Red
es una version jibarizada, que solo incluye los roles principales:
- althost que orquesta todo
- proxy reverso Nginx dockerizado
- certbot maneja SSL de este
- dns es un servidor DNS bind9
- rap es la VPN
- users gestiona usuarixs linux
2024-08-22 14:15:39 -04:00

73 lines
1.9 KiB
YAML

# ansible-playbook rap.yml -e "host=hetzner"
---
- hosts: "{{ host }}"
vars:
rap:
port: 65000
rap_dir: "{{ directory | default('/root') }}"
environment:
PATH: "/usr/sbin:{{ ansible_env.PATH }}"
tasks:
- name: install dependencies
package:
name: "{{ item }}"
state: present
loop:
- rsync
- git
- tinc
become: yes
- name: iptables
iptables:
action: append
chain: INPUT
table: filter
destination_port: "{{ rap.port }}"
protocol: "{{ item }}"
jump: ACCEPT
loop:
- tcp
- udp
become: yes
- name: install rap
git:
repo: "https://0xacab.org/pip/rap.git"
dest: "{{ rap_dir }}/rap"
- set_fact:
hostname: "{% if '{{ host }} != localhost' %} {{ ansible_hostname }} {% else %} {{ inventory_hostname }} {% endif %}"
# inventory_hostname=> localhost/IP | ansible_hostname=>infra
- name: node name
shell: 'echo {{ hostname }} | tr -cd "[:alnum:]" | tr "[:upper:]" "[:lower:]"'
register: node_name
changed_when: false
- stat:
path: "{{ rap_dir }}/rap/hosts/{{ node_name.stdout }}"
register: node_exists
- name: init node
when: "node_exists.stat.exists == False"
shell: "cd {{ rap_dir }}/rap && ./rap init -f -a {{ hostname }} -p {{ rap.port }}"
- name: fetch hosts files
fetch:
flat: true
src: "{{ rap_dir }}/rap/hosts/{{ node_name.stdout }}"
dest: "./rap/hosts/{{ node_name.stdout }}"
- name: copy hosts files
copy:
src: "./rap/hosts/"
dest: "{{ rap_dir }}/rap/hosts/"
- name: connectto
shell: 'cd {{ rap_dir }}/rap && for host in ./hosts/*; do test "./hosts/{{ node_name.stdout }}" = "${host}" && continue ; basename "${host}" | xargs -r ./rap connectto "{{ node_name.stdout }}"; done'
- name: install node
shell: "cd {{ rap_dir }}/rap && ./rap install {{ node_name.stdout }}"