Giter Site home page Giter Site logo

ansible-role-lxd's Introduction

Role Name

An Ansible role to configure an LXD server

Roadmap

Requirements

Ubuntu 16.04

B4 starting remove any existing lxd 2.x stuff

apt remove --purge lxd lxd-client liblxc1 lxcfs

install 3.x

via snap - tested and fully supported by Canonical

snap install lxd

Storage network should be identical on LXD clusters?

First node

lxd init
clustering yes
joining no
password
new zfs pool, loop
not adding a remote storage pool (like ceph)
MASS no

lxc cluster commands examples:

lxc cluster list
lxc cluster show mycluster

Second node

ALL LXD DATA WILL BE WIPED FROM THE CONNECTING NODE

zfs loop

chec kcluster

lxc cluster

Third node

join 
zfs loop
lxc cluster list
lxc launch ubuntu:16.04 c1
lxc config show

Creting contianrs on the cluster

instances show up wherever (random cluster member) unless directed to a specific node like thisL

lxc launch ubuntu:16.04 d3 --target node2

overide ip address example:

lxc config override c2 eth0 ipv4.address 172.17.16.20
lxc config override c2 eth0 nic nictype=bridged parent=br0 ipv4.address 172.17.16.20 name=eth0

expanded config

lxc config show c1 --expanded

storage

lxc storage volumn list

Connecting to a remote lxd cluster

lxc remote add cluster mycluster
password
client certificate stored at server: cluster

Set the cluster as a remote the default

lxc remote set-default cluster
lxc list

To change the default back to the local lxd

lxc remote set-default local
lxc list

Note: The TLS certificate record is shared between all of your cluster nodes so you can create a DNS round robin record that is shared between all of your cluster nodes

so

ssh node1
poweroff

then

lxc cluster list

after about 30 seconds the node will be marked as not available and any containers on that node will show as OFFLINE

when the node is brought back up everything should get back to normal and the containers on the first node will be back online

Remote LXD server

  • LXD should already be setup on the remote image server:

    sudo lxd init

  • In order for Ansible to manage an LXD host remotely the following commands must be run ahead of time:

On the remote LXD host:

lxc config set core.https_address [::]:8443
lxc config set core.trust_password replace-this-with-a-secure-password

On the local LXD host:

lxc config set core.https_address [::]:8443
lxc remote add lxd4 lxd4.example.com

(replace lxd4.example.com with the hostname of your LXD host, 'lxd4' can be named whatever you want, you'll need to reference it in the inventory file)

  • Tested on an LXD host and Ansible host both using Ubuntu 16.04 LTS (may work with other distros)

Testing

Manual

Connect

molecule --debug login -s lxd

tests

zpool list
zfs list

Container creation check

lxd list
lxc launch ubuntu:18.04 c1
lxc list

Role Variables

A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.

Dependencies

A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.

Example Playbook

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:

- hosts: servers
  roles:
     - { role: cjsteel.lxd_server, x: 42 }

Inspiration

License

MIT

Author Information

An optional section for the role authors to include contact information, or a website (HTML is not allowed).

ansible-role-lxd's People

Contributors

cjsteel avatar agomerz avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.