From 1d0e5df1558df5af2617668232e3e317cd62a1b3 Mon Sep 17 00:00:00 2001 From: RDF Date: Tue, 19 Jul 2022 10:22:58 -0300 Subject: [PATCH] lxd init default config --- Playbooks/01-UBUNTU-LXD.yml | 10 ++++-- Playbooks/roles/init_lxd/defaults/main.yml | 12 ++++++- .../init_lxd/templates/default_config.yml.j2 | 31 +++++++++---------- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/Playbooks/01-UBUNTU-LXD.yml b/Playbooks/01-UBUNTU-LXD.yml index b3ce3a5..132fd00 100644 --- a/Playbooks/01-UBUNTU-LXD.yml +++ b/Playbooks/01-UBUNTU-LXD.yml @@ -16,11 +16,10 @@ - "zfsutils-linux" - ansible.builtin.include_role: - name: init_lxd + name: init_lxd #vars: # - lxd_init_template_config_path="/path/to/my/custom/template" - ## Rollback - hosts: ubuntu_lxd tags: @@ -28,4 +27,11 @@ tasks: - shell: "snap remove --purge lxd" become: true + - name: Install packages + ansible.builtin.package: + name: "{{item}}" + state: absent + with_items: + - "ansible" + - "zfsutils-linux" diff --git a/Playbooks/roles/init_lxd/defaults/main.yml b/Playbooks/roles/init_lxd/defaults/main.yml index 353c223..e790483 100644 --- a/Playbooks/roles/init_lxd/defaults/main.yml +++ b/Playbooks/roles/init_lxd/defaults/main.yml @@ -1,4 +1,14 @@ --- # defaults file for roles/init_lxd + lxd_init_template_config_path: "templates/default_config.yml.j2" -lxd_init_template_processed_path: "/tmp/default_config.yml" \ No newline at end of file +lxd_init_template_processed_path: "/tmp/default_config.yml" + +## LXD Default +lxd_project_name: "default" +# - Storage +storage_pool_name: "default" +storage_pool_driver: "zfs" +storage_pool_size: "20GB" +# - Network +network_default_name: "lxdbr0" \ No newline at end of file diff --git a/Playbooks/roles/init_lxd/templates/default_config.yml.j2 b/Playbooks/roles/init_lxd/templates/default_config.yml.j2 index ecb6b6c..902e3f0 100644 --- a/Playbooks/roles/init_lxd/templates/default_config.yml.j2 +++ b/Playbooks/roles/init_lxd/templates/default_config.yml.j2 @@ -4,38 +4,36 @@ config: # -- networks: -- config: - # IPv4 +- name: {{network_default_name}} + project: {{lxd_project_name}} + type: bridge + config: + # IPv4 ipv4.nat: "true" ipv4.address: {{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }} - # IPv6 + # IPv6 ipv6.nat: "true" - name: lxdbr0 - type: bridge - project: default # -- storage_pools: -- config: - size: 20GB +- name: {{storage_pool}} + driver: {{storage_pool_driver}} + config: + size: {{storage_pool_size}} source: /var/snap/lxd/common/lxd/disks/default.img - name: default - driver: zfs # -- profiles: -- config: {} - description: Default LXD profile +- name: {{lxd_project_name}} devices: eth0: name: eth0 - network: lxdbr0 + network: {{network_default_name}} type: nic root: path: / - pool: default + pool: {{storage_pool}} type: disk - name: default # -- projects: @@ -44,5 +42,4 @@ projects: features.networks: "true" features.profiles: "true" features.storage.volumes: "true" - description: Default LXD project - name: default \ No newline at end of file + name: {{lxd_project_name}} \ No newline at end of file