Hello,
LXD Version: 4.5
Host on Ubuntu 20.04
I tried to create an ansible playbook to create VM Ubuntu Focal with two interfaces and user ansible configured.
This part of my playbook
- name: Creation profile vm_lanprofile LXD
lxd_profile:
name: vm_lanprofile
state: present
config:
user.network-config: |
version: 1
config:
- type: physical
name: eth0
subnets:
- type: dhcp
- type: physical
name: eth1
subnets:
- type: dhcp
user.user-data: |
#cloud-config
ssh_pwauth: yes
users:
- default
- name: ansible
gecos: ansible
groups: sudo
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
lock-passwd: false
passwd: "crypt_password"
ssh_authorized_keys:
- ssh-key xxxxxxxxx
description: VM conf for eth on lan dhcp
devices:
config:
source: cloud-init:config
type: disk
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
eth1:
name: eth1
nictype: bridged
parent: brvlan
type: nic
root:
path: /
pool: data
type: disk
- name: Demarrage de la VM
shell: "lxc launch {{ vm_os }} {{ vm_name }} --vm -c security.secureboot=false -c limits.cpu={{ cpu_limit }} -c limits.memory={{ ram_gb }}GB -p {{ vm_profile }}"
And defaults vars:
vm_user: "ansible"
vm_user_password: "blablablabla"
vm_name: "sandbox"
vm_os: "images:ubuntu/20.04/cloud"
# vm_os: "ubuntu:20.04"
ram_gb: 4
cpu_limit: 2
vm_profile: vm_lanprofile
When I use vm_os: "ubuntu:20.04"
- I have my user but I needed to first time to ssh connect with user ubuntu@sandbox, and after ansible@sanbox to works.
- But only one interface ensp5
When I use vm_os: "images:ubuntu/20.04/cloud"
- No network working at all
- I don’t know if user is work.
I try to comment when I use /cloud
image
# source: cloud-init:config
# type: disk
But no more works.
lxc network list
+-----------------+----------+---------+---------------+------+-------------+---------+
| NAME | TYPE | MANAGED | IPV4 | IPV6 | DESCRIPTION | USED BY |
+-----------------+----------+---------+---------------+------+-------------+---------+
| br-fb5620c190cf | bridge | NO | | | | 0 |
+-----------------+----------+---------+---------------+------+-------------+---------+
| brvlan | bridge | NO | | | | 11 |
+-----------------+----------+---------+---------------+------+-------------+---------+
| docker0 | bridge | NO | | | | 0 |
+-----------------+----------+---------+---------------+------+-------------+---------+
| enp0s25 | physical | NO | | | | 0 |
+-----------------+----------+---------+---------------+------+-------------+---------+
| lxdbr0 | bridge | YES | 10.69.10.1/24 | none | | 14 |
+-----------------+----------+---------+---------------+------+-------------+---------+
lxc profile show vm_lanprofile
config:
user.network-config: |
version: 1
config:
- type: physical
name: eth0
subnets:
- type: dhcp
- type: physical
name: eth1
subnets:
- type: dhcp
user.user-data: |
#cloud-config
ssh_pwauth: yes
users:
- default
- name: ansible
gecos: ansible
groups: sudo
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
lock-passwd: false
passwd: "crypt_password"
ssh_authorized_keys:
- ssh-key xxxxxx
description: VM conf for eth on lan dhcp
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
eth1:
name: eth1
nictype: bridged
parent: brvlan
type: nic
root:
path: /
pool: data
type: disk
name: vm_lanprofile
used_by:
- /1.0/instances/sandbox
I don’t know what to do now.
Thanks