Commit a9be0e38 authored by Pietro Albini's avatar Pietro Albini

lxd-container: assign static IPv4 addresses to containers

parent 25d38b13
...@@ -31,9 +31,11 @@ ...@@ -31,9 +31,11 @@
- role: lxd-container - role: lxd-container
name: spock name: spock
ip: 10.0.0.2
image: debian/jessie/amd64 image: debian/jessie/amd64
- role: lxd-container - role: lxd-container
name: bromuro name: bromuro
ip: 10.0.0.3
image: ubuntu/trusty/amd64 image: ubuntu/trusty/amd64
---
- name: "lxd-container.restart-{{ name }}"
lxd_container:
name: "{{ name }}"
state: restarted
--- ---
- include_tasks: creation.yml - include_tasks: creation.yml
- include_tasks: networking.yml
---
- name: "Assign a static IP address to the {{ name }} container"
lineinfile:
line: "dhcp-host={{ name }},{{ ip }}"
regexp: "^dhcp\\-host={{ name }}"
state: present
path: /etc/lxd_dnsmasq.conf
notify:
- lxd.restart-bridge
- "lxd-container.restart-{{ name }}"
---
- name: lxd.restart-bridge
service:
name: lxd-bridge
state: restarted
...@@ -33,6 +33,21 @@ ...@@ -33,6 +33,21 @@
src: lxd-bridge-default.j2 src: lxd-bridge-default.j2
dest: /etc/default/lxd-bridge dest: /etc/default/lxd-bridge
notify:
- lxd.restart-bridge
- name: Create the lxd dnsmasq configuration file
lineinfile:
line: ""
path: /etc/lxd_dnsmasq.conf
create: yes
state: present
notify:
- lxd.restart-bridge
- name: Initialize lxd - name: Initialize lxd
command: "lxd init --auto" command: "lxd init --auto"
......
...@@ -10,7 +10,7 @@ LXD_BRIDGE="lxdbr0" ...@@ -10,7 +10,7 @@ LXD_BRIDGE="lxdbr0"
UPDATE_PROFILE="true" UPDATE_PROFILE="true"
# Path to an extra dnsmasq configuration file # Path to an extra dnsmasq configuration file
LXD_CONFILE="" LXD_CONFILE="/etc/lxd_dnsmasq.conf"
# DNS domain for the bridge # DNS domain for the bridge
LXD_DOMAIN="lxd" LXD_DOMAIN="lxd"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment