aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/lxc-host/tasks
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-03-09 16:55:02 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-03-09 16:55:02 +0100
commitedbe2bfb1b4845f853a1634565fbf264d1591628 (patch)
tree05b0451f42d2cb927719f52f93fac7358bd15d39 /ansible/roles/lxc-host/tasks
parentd4de905ae685c750fa7f0b8f65db579d4aeec193 (diff)
downloadinfra-edbe2bfb1b4845f853a1634565fbf264d1591628.tar.gz
infra-edbe2bfb1b4845f853a1634565fbf264d1591628.tar.bz2
infra-edbe2bfb1b4845f853a1634565fbf264d1591628.tar.xz
infra-edbe2bfb1b4845f853a1634565fbf264d1591628.zip
lxc-host:
o Correcting ordering of networkd files. packages: o Better split of package names. unifi: o importing role from Bitraf. o Configring lxc host on birgitte.
Diffstat (limited to 'ansible/roles/lxc-host/tasks')
-rw-r--r--ansible/roles/lxc-host/tasks/networkd.yml65
-rw-r--r--ansible/roles/lxc-host/tasks/per-host.yml5
2 files changed, 45 insertions, 25 deletions
diff --git a/ansible/roles/lxc-host/tasks/networkd.yml b/ansible/roles/lxc-host/tasks/networkd.yml
index 526fc29..39d8a69 100644
--- a/ansible/roles/lxc-host/tasks/networkd.yml
+++ b/ansible/roles/lxc-host/tasks/networkd.yml
@@ -15,58 +15,75 @@
name: systemd-networkd
enabled: yes
state: started
+ when: lxc_host__state == "present"
- - name: "{{ file_prefix }}-1-{{ lxc_host__internal_if }}.netdev"
+ - loop:
+ - "{{ file_prefix }}-1-{{ br_if }}.netdev"
+ - "{{ file_prefix }}-2-{{ br_if }}.network"
+ - "{{ file_prefix }}-3-{{ lxc_host__internal_if }}.netdev"
+ - "{{ file_prefix }}-4-{{ lxc_host__internal_if }}.network"
+ when: lxc_host__state == "absent"
notify: systemctl restart systemd-networkd
+ file:
+ path: "{{ item }}"
+ state: absent
+
+ - name: "{{ file_prefix }}-1-{{ br_if }}.netdev"
+ notify: systemctl restart systemd-networkd
+ when: lxc_host__state == "present"
copy:
- dest: "{{ file_prefix }}-1-{{ lxc_host__internal_if }}.netdev"
+ dest: "{{ file_prefix }}-1-{{ br_if }}.netdev"
content: |
[NetDev]
- Name={{ lxc_host__internal_if }}
- Kind=dummy
+ Name={{ br_if }}
+ Kind=bridge
- - name: "{{ file_prefix }}-2-{{ lxc_host__internal_if }}.network"
+ - name: "{{ file_prefix }}-2-{{ br_if }}.network"
notify: systemctl restart systemd-networkd
+ when: lxc_host__state == "present"
copy:
- dest: "{{ file_prefix }}-2-{{ lxc_host__internal_if }}.network"
+ dest: "{{ file_prefix }}-2-{{ br_if }}.network"
content: |
[Match]
- Name={{ lxc_host__internal_if }}
+ Name={{ br_if }}
[Network]
- Bridge={{ br_if }}
+ {% if internal_if.ipv4 is defined %}
+ Address={{ internal_if.ipv4.address }}/{{ internal_if.ipv4.netmask }}
+ {% endif %}
+ {% if internal_if.ipv6 is defined %}
+ Address={{ internal_if.ipv6.address }}/{{ internal_if.ipv6.netmask }}
+ {% endif %}
- - name: "{{ file_prefix }}-3-{{ br_if }}.netdev"
+ - name: "{{ file_prefix }}-3-{{ lxc_host__internal_if }}.netdev"
notify: systemctl restart systemd-networkd
+ when: lxc_host__state == "present"
copy:
- dest: "{{ file_prefix }}-3-{{ br_if }}.netdev"
+ dest: "{{ file_prefix }}-3-{{ lxc_host__internal_if }}.netdev"
content: |
[NetDev]
- Name={{ br_if }}
- Kind=bridge
+ Name={{ lxc_host__internal_if }}
+ Kind=dummy
- - name: "{{ file_prefix }}-4-{{ br_if }}.network"
+ - name: "{{ file_prefix }}-4-{{ lxc_host__internal_if }}.network"
notify: systemctl restart systemd-networkd
+ when: lxc_host__state == "present"
copy:
- dest: "{{ file_prefix }}-4-{{ br_if }}.network"
+ dest: "{{ file_prefix }}-4-{{ lxc_host__internal_if }}.network"
content: |
[Match]
- Name={{ br_if }}
+ Name={{ lxc_host__internal_if }}
[Network]
- {% if internal_if.ipv4 is defined %}
- Address={{ internal_if.ipv4.address }}/{{ internal_if.ipv4.netmask }}
- {% endif %}
- {% if internal_if.ipv6 is defined %}
- Address={{ internal_if.ipv6.address }}/{{ internal_if.ipv6.netmask }}
- {% endif %}
+ Bridge={{ br_if }}
- meta: flush_handlers
- name: Configure sysctl, enable ipv4 and ipv6 forwarding for {{ br_if }}
- sysctl:
- name: "{{ item }}"
- value: 1
with_items:
- net.ipv4.conf.{{ br_if }}.forwarding
- net.ipv6.conf.{{ br_if }}.forwarding
+ sysctl:
+ name: "{{ item }}"
+ value: 1
+ state: "{{ lxc_host__state }}"
diff --git a/ansible/roles/lxc-host/tasks/per-host.yml b/ansible/roles/lxc-host/tasks/per-host.yml
index ca33685..0acd1b5 100644
--- a/ansible/roles/lxc-host/tasks/per-host.yml
+++ b/ansible/roles/lxc-host/tasks/per-host.yml
@@ -2,6 +2,9 @@
msg: "LXC HOST: {{ name }}"
tags: lxc-host
+- debug:
+ var: lan
+
- when: new
tags: lxc-host
become: yes
@@ -59,10 +62,10 @@
{% endif %}
{% if lan.ipv6 is defined %}
lxc.net.0.ipv6.address = {{ lan.ipv6.address }}/{{ lan.ipv6.netmask }}
- {% endif %}
{% if lan.ipv6.gateway is defined %}
lxc.net.0.ipv6.gateway = {{ lan.ipv6.gateway }}
{% endif %}
+ {% endif %}
# 0 = trace, 1 = debug, 2 = info, 3 = notice, 4 = warn, 5 = error, 6 = critical, 7 = alert, and 8 = fatal.
lxc.log.level = 1