2017-08-22 17:32:32 +02:00
|
|
|
---
|
|
|
|
- name: Install lxc tools
|
|
|
|
apt:
|
2019-10-01 17:53:08 +02:00
|
|
|
name:
|
|
|
|
- lxc
|
|
|
|
- debootstrap
|
|
|
|
- xz-utils
|
2021-05-02 01:14:06 +02:00
|
|
|
|
2021-09-30 12:10:55 +02:00
|
|
|
- name: python-lxc is installed (Debian <= 10)
|
2021-05-02 01:14:06 +02:00
|
|
|
apt:
|
|
|
|
name: python-lxc
|
|
|
|
state: present
|
2021-09-30 17:05:10 +02:00
|
|
|
when: ansible_python_version is version('3', '<')
|
2021-05-02 01:14:06 +02:00
|
|
|
|
2021-09-30 12:10:55 +02:00
|
|
|
- name: python3-lxc is installed (Debian >= 10)
|
2021-05-02 01:14:06 +02:00
|
|
|
apt:
|
|
|
|
name: python3-lxc
|
|
|
|
state: present
|
2021-09-30 17:05:10 +02:00
|
|
|
when: ansible_python_version is version('3', '>=')
|
2019-10-02 16:32:20 +02:00
|
|
|
|
2021-09-30 12:10:55 +02:00
|
|
|
- name: Install additional packages (Debian >= 10)
|
2019-10-02 16:32:20 +02:00
|
|
|
apt:
|
2020-04-17 15:57:22 +02:00
|
|
|
name:
|
|
|
|
- apparmor
|
|
|
|
- lxc-templates
|
2020-02-25 10:45:35 +01:00
|
|
|
when: ansible_distribution_major_version is version('10', '>=')
|
2017-08-22 17:32:32 +02:00
|
|
|
|
|
|
|
- name: Copy LXC default containers configuration
|
|
|
|
template:
|
|
|
|
src: default.conf
|
|
|
|
dest: /etc/lxc/
|
|
|
|
|
|
|
|
- name: Check if root has subuids
|
|
|
|
command: grep '^root:100000:10000$' /etc/subuid
|
2017-08-24 18:07:16 +02:00
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
2017-08-22 17:32:32 +02:00
|
|
|
register: root_subuids
|
2021-05-09 23:06:42 +02:00
|
|
|
when: lxc_unprivilegied_containers | bool
|
2017-08-22 17:32:32 +02:00
|
|
|
|
|
|
|
- name: Add subuid and subgid ranges to root
|
|
|
|
command: usermod -v 100000-199999 -w 100000-109999 root
|
2019-06-21 10:36:32 +02:00
|
|
|
when:
|
2021-05-09 23:06:42 +02:00
|
|
|
- lxc_unprivilegied_containers | bool
|
|
|
|
- root_subuids.rc != 0
|
2017-08-22 17:32:32 +02:00
|
|
|
|
|
|
|
- name: Create containers
|
2019-06-21 10:36:32 +02:00
|
|
|
include: create-container.yml
|
|
|
|
vars:
|
|
|
|
name: "{{ item.name }}"
|
2020-04-17 15:56:54 +02:00
|
|
|
release: "{{ item.release }}"
|
|
|
|
loop: "{{ lxc_containers }}"
|