This isn’t a question as much as it is a ‘here’s what I’ve found’ post…
I’ve been testing LXD in VirtualBox, along with using ansible as much as possible to automate setup and so on. Ansible let’s you create containers on a host, once you’ve navigated this snap bug, but I’ve not been able to automatically configure a container so that I can ssh into it and carry on using ansible as-is.
I’ve now got ansible working on a container where I run playbooks on my laptop and then the host and containers are in VirtualBox. A combination of lxc exec mycontainer commands setup ssh access on the container and then the ssh config outlined here worked on my local machine.
While the above works fine, I didn’t get any joy with any of the following approaches based on my setup above…
Ansible’s LXD module seems to work best when it’s run from the container’s host and not an external machine. As a result, I never had any joy with things like this…
I also never got anywhere with ansible-sshlxd-connection or ansible-lxc-ssh. They both looked useful but I never got them to work. ansible-lxc-ssh may well not work with lxd though?
These twothreads on reddit also looked helpful but didn’t prove to be useful.
I also ran into some problems running lxc exec mycontainer commands in a bash script. I would always get lxc: command not found which was kind of baffling as the same commands ran fine at the prompt…
Aside from baking ssh and a key into an lxd image, has anyone else found a way to get ansible working on a container from an external machine in a more automated manner?
$ snap info lxd
name: lxd
summary: System container manager and API
publisher: Canonical✓
contact: https://github.com/lxc/lxd/issues
license: unset
description: |
LXD is a container manager for system containers.
It offers a REST API to remotely manage containers over the network, using
an image based workflow and with support for live migration.
Images are available for all Ubuntu releases and architectures as well as
for a wide number of other Linux distributions.
LXD containers are lightweight, secure by default and a great alternative
to virtual machines.
commands:
- lxd.benchmark
- lxd.buginfo
- lxd.check-kernel
- lxd.lxc
- lxd
- lxd.migrate
services:
lxd.activate: oneshot, enabled, inactive
lxd.daemon: simple, enabled, active
snap-id: J60k4JY0HppjwOjW8dZdYc8obXKxujRu
tracking: candidate
refresh-date: today at 11:23 EEST
channels:
stable: 3.5 (9010) 69MB -
candidate: 3.6 (9129) 69MB -
beta: ↑
edge: git-948b8f6 (9163) 69MB -
3.0/stable: 3.0.2 (8715) 65MB -
3.0/candidate: 3.0.2 (9043) 68MB -
3.0/beta: ↑
3.0/edge: git-624e200 (9167) 68MB -
2.0/stable: 2.0.11 (8023) 28MB -
2.0/candidate: 2.0.11 (8023) 28MB -
2.0/beta: ↑
2.0/edge: git-f3e2b11 (9148) 26MB -
installed: 3.6 (9129) 69MB -
This means that if you did not change the tracking, then you are tracking LXD 3.5.
If you are tracking the stable version 3.0/stable, then you are already on LXD 3.0.2.
If you are unsure, post the output of snap info lxd to verify what you are tracking.
debian@BR-LXD:~$ snap info lxd
name: lxd
summary: System container manager and API
publisher: Canonical✓
license: unset
description: |
LXD is a container manager for system containers.
It offers a REST API to remotely manage containers over the network, using an image based workflow
and with support for live migration.
Images are available for all Ubuntu releases and architectures as well as for a wide number of
other Linux distributions.
LXD containers are lightweight, secure by default and a great alternative to virtual machines.
commands:
- lxd.benchmark
- lxd.buginfo
- lxd.check-kernel
- lxd.lxc
- lxd
- lxd.migrate
services:
lxd.activate: oneshot, enabled, inactive
lxd.daemon: simple, enabled, active
snap-id: J60k4JY0HppjwOjW8dZdYc8obXKxujRu
tracking: stable
refresh-date: 3 days ago, at 16:47 SAST
channels:
stable: 3.5 (9010) 69MB -
candidate: 3.6 (9129) 69MB -
beta: ↑
edge: git-948b8f6 (9163) 69MB -
3.0/stable: 3.0.2 (8715) 65MB -
3.0/candidate: 3.0.2 (9043) 68MB -
3.0/beta: ↑
3.0/edge: git-624e200 (9167) 68MB -
2.0/stable: 2.0.11 (8023) 28MB -
2.0/candidate: 2.0.11 (8023) 28MB -
2.0/beta: ↑
2.0/edge: git-f3e2b11 (9148) 26MB -
installed: 3.5 (9010) 69MB devmode
I orginally ran sudo snap install lxd and then lxd init to attached to an existing zfs pool…
Hi @simos , lxc remote is one possible solution but I’m trying to run ansible on my laptop to run playbooks against containers running on a server. I’ve got a manual work-around going which is fine for now, but @adosztalsuggested that this bug, although I don’t know what number the bug has, is going to fix this ansible problem in version 3.0.2…
As I’m running from SNAP do you know what the differences are between 3.0.2 and 3.6?
Also, how can I see how much drive space a particular container is using?