Browse Source

use `vm_gateway` group vars in lxc_guest

python3
Edoardo Putti 7 years ago
parent
commit
c731f86294
2 changed files with 2 additions and 2 deletions
  1. +1
    -1
      roles/lxc_guest/tasks/main.yaml
  2. +1
    -1
      roles/lxc_guest/templates/config.j2

+ 1
- 1
roles/lxc_guest/tasks/main.yaml View File

@ -71,7 +71,7 @@
- name: update container DNS configuration - name: update container DNS configuration
shell: lxc-attach -n {{ vm_name }} --clear-env -e -- bash -c "grep -Pz1 'domain lilik.it\nnameserver {{ vm_gateway }}' /etc/resolv.conf || echo -e 'domain lilik.it\nnameserver {{ vm_gateway }}' > /etc/resolv.conf" shell: lxc-attach -n {{ vm_name }} --clear-env -e -- bash -c "grep -Pz1 'domain lilik.it\nnameserver {{ vm_gateway }}' /etc/resolv.conf || echo -e 'domain lilik.it\nnameserver {{ vm_gateway }}' > /etc/resolv.conf"
register: container_dns_configuration register: container_dns_configuration
changed_when: container_dns_configuration.stdout != "domain lilik.it\nnameserver {{ hostvars[ext_gateway].ansible_host }}\n\u0000"
changed_when: container_dns_configuration.stdout != "domain lilik.it\nnameserver {{ vm_gateway }}\n\u0000"
- name: update container network configuration - name: update container network configuration
shell: lxc-attach -n {{ vm_name }} --clear-env -e -- bash -c "grep -F 'iface eth0 inet manual' /etc/network/interfaces || sed -i 's/iface eth0 inet dhcp/iface eth0 inet manual/' /etc/network/interfaces" shell: lxc-attach -n {{ vm_name }} --clear-env -e -- bash -c "grep -F 'iface eth0 inet manual' /etc/network/interfaces || sed -i 's/iface eth0 inet dhcp/iface eth0 inet manual/' /etc/network/interfaces"


+ 1
- 1
roles/lxc_guest/templates/config.j2 View File

@ -11,5 +11,5 @@ lxc.network.flags = up
lxc.network.link = br0 lxc.network.link = br0
lxc.network.name = eth0 lxc.network.name = eth0
lxc.network.ipv4 = {{ hostvars[vm_name]['ansible_host'] }}/24 lxc.network.ipv4 = {{ hostvars[vm_name]['ansible_host'] }}/24
lxc.network.ipv4.gateway = {{ hostvars[ext_gateway]['ansible_host'] }}
lxc.network.ipv4.gateway = {{ vm_gateway }}
lxc.start.auto = {% if auto_start %}1{% else %}0{% endif %} lxc.start.auto = {% if auto_start %}1{% else %}0{% endif %}

Loading…
Cancel
Save