Playbooks to a new Lilik
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.9 KiB

  1. # Role: lxc_guest
  2. This role creates a debian LXC container on an host previously with LXC
  3. and network in bridged mode, connecting the container to the interface
  4. `br0` on the host.
  5. The ip address and gateway of the container are automatically discovered
  6. from the ansible inventory. The `vm_gateway` entry IP is used as gateway
  7. while the entry associated with `vm_name` IP is used as static IP
  8. address.
  9. ## Configuration variables
  10. | Name | Description |
  11. |--------------|-----------------------------------------|
  12. | `vm_name`* | Name of the LXC container. |
  13. | `vm_size` | Size of the VM logical volume. [`'5G'`] |
  14. | `distro` | Debian release name. [`'buster'`] |
  15. | `auto_start` | Auto-start container. [`true`] |
  16. | `domain`* | The VM domain is set to dmz.$domain |
  17. | `vg_name`** | LVM volume group name on the host. |
  18. **Note: If `vg_name` is not provided it will be derived from the
  19. `ansible_lxc_host` variable in the inventory entry of the guest.
  20. If the entry pointed by `ansible_lxc_host` doesn't set has an
  21. alterntive `vg_name` set, it will default to `ansible_lxc_host`+'-vg'.
  22. ## Minimal example
  23. group_vars/all.yaml:
  24. ---
  25. domain: 'example.com'
  26. hosts:
  27. vm_gateway ansible_host=10.0.2.1 ansible_user=root
  28. physical1 ansible_host=10.0.1.1 ansible_user=root vm_name=test-vg
  29. vm1 ansible_host=10.0.2.10 ansible_user=root ansible_lxc_host=physical1
  30. vm1.yaml:
  31. ---
  32. - hosts: vm1
  33. gather_facts: false # host may not exist yet
  34. tasks:
  35. - import_role: name='lxc_guest'
  36. vars:
  37. vm_name: '{{ inventory_hostname }}'
  38. vm_size: '1G'
  39. delegate_to: '{{ ansible_lxc_host }}'
  40. Command line:
  41. ansible-playbook -i hosts vm1.yaml
  42. ## Requirements
  43. On Ansible controller:
  44. - connection_plugins/ssh_lxc.py
  45. On LXC host:
  46. - python3-lxc module.
  47. ## See also
  48. The playbook `prepare_host.yaml` provides a working configuration for
  49. the physical machine running LXC.