4 changed files with 79 additions and 80 deletions
@ -1,77 +0,0 @@ |
|||||||
--- |
|
||||||
# TODO: use template for lxd-init --preseed |
|
||||||
- name: copy ssh pubkey from controller to lxd host |
|
||||||
copy: |
|
||||||
src: "{{ lookup('env', 'HOME') + '/.ssh/id_rsa.pub' }}" |
|
||||||
dest: "{{ tmp_pubkey }}" |
|
||||||
|
|
||||||
# TODO: might make sense to add a cache redirect for alpine packages |
|
||||||
- include_tasks: tasks/container_install.yml |
|
||||||
tags: container_install |
|
||||||
vars: |
|
||||||
container_name: "{{ item }}" |
|
||||||
container_sshd_port: "{{ hostvars[item]['ansible_port'] }}" |
|
||||||
container_ip: "{{ hostvars[item]['internal_ip'] }}" |
|
||||||
tmp_sshd_config: "/tmp/sshd_config_{{ item }}" |
|
||||||
with_items: "{{ groups['containers'] }}" |
|
||||||
|
|
||||||
- name: install iptables and iptables-persistent |
|
||||||
tags: routing |
|
||||||
become: yes |
|
||||||
apt: |
|
||||||
name: [iptables, iptables-persistent] |
|
||||||
state: present |
|
||||||
when: do_routing |
|
||||||
|
|
||||||
- name: add DNAT rules for containers |
|
||||||
tags: routing |
|
||||||
iptables: |
|
||||||
table: nat |
|
||||||
chain: PREROUTING |
|
||||||
in_interface: "{{ host_iface }}" |
|
||||||
protocol: tcp |
|
||||||
match: tcp |
|
||||||
source: "{{ host_cidr }}" |
|
||||||
jump: DNAT |
|
||||||
destination_port: "{{ hostvars[item]['ansible_port'] }}" |
|
||||||
to_destination: "{{ hostvars[item]['internal_ip'] }}" |
|
||||||
become: yes |
|
||||||
with_items: "{{ groups['containers'] }}" |
|
||||||
when: do_routing |
|
||||||
|
|
||||||
- name: save DNAT rules on lxd host |
|
||||||
tags: routing |
|
||||||
become: yes |
|
||||||
community.general.iptables_state: |
|
||||||
table: nat |
|
||||||
state: saved |
|
||||||
path: /etc/iptables/rules.v4 |
|
||||||
when: do_routing |
|
||||||
|
|
||||||
# TODO: add other dnat ports in above loop? |
|
||||||
#- name: add dokuwiki DNAT routing |
|
||||||
# iptables: |
|
||||||
# table: nat |
|
||||||
# chain: PREROUTING |
|
||||||
# in_interface: "{{ host_iface }}" |
|
||||||
# protocol: tcp |
|
||||||
# match: tcp |
|
||||||
# source: "{{ host_cidr }}" |
|
||||||
# jump: DNAT |
|
||||||
# destination_port: "{{ hostvars['dokuwiki']['dnat_dest_port'] }}" |
|
||||||
# to_destination: "{{ hostvars['dokuwiki']['internal_ip'] }}" |
|
||||||
# become: yes |
|
||||||
# |
|
||||||
#- name: add freshrss DNAT routing |
|
||||||
# iptables: |
|
||||||
# table: nat |
|
||||||
# chain: PREROUTING |
|
||||||
# in_interface: "{{ host_iface }}" |
|
||||||
# protocol: tcp |
|
||||||
# match: tcp |
|
||||||
# source: "{{ host_cidr }}" |
|
||||||
# jump: DNAT |
|
||||||
# destination_port: "{{ hostvars['freshrss']['dnat_dest_port'] }}" |
|
||||||
# to_destination: "{{ hostvars['freshrss']['internal_ip'] }}" |
|
||||||
# become: yes |
|
||||||
|
|
||||||
Loading…
Reference in new issue