forked from techno-tim/k3s-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for proxmox lxc containers (techno-tim#209)
Co-authored-by: Adam Doussan <[email protected]>
- Loading branch information
Showing
8 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- name: reboot server | ||
reboot: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- name: configure rc.local for proxmox lxc containers | ||
copy: | ||
src: "{{ playbook_dir }}/scripts/rc.local" | ||
dest: "/etc/rc.local" | ||
mode: "u=rwx,g=rx,o=rx" | ||
notify: reboot server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: reboot containers | ||
command: | ||
"pct reboot {{ item }}" | ||
loop: "{{ proxmox_lxc_filtered_ids }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
- name: check for container files that exist on this host | ||
stat: | ||
path: "/etc/pve/lxc/{{ item }}.conf" | ||
loop: "{{ proxmox_lxc_ct_ids }}" | ||
register: stat_results | ||
|
||
- name: filter out files that do not exist | ||
set_fact: | ||
proxmox_lxc_filtered_files: | ||
'{{ stat_results.results | rejectattr("stat.exists", "false") | map(attribute="stat.path") }}' | ||
|
||
# used for the reboot handler | ||
- name: get container ids from filtered files | ||
set_fact: | ||
proxmox_lxc_filtered_ids: | ||
'{{ proxmox_lxc_filtered_files | map("split", "/") | map("last") | map("split", ".") | map("first") }}' | ||
|
||
# https://gist.github.com/triangletodd/02f595cd4c0dc9aac5f7763ca2264185 | ||
- name: Ensure lxc config has the right apparmor profile | ||
lineinfile: | ||
dest: "{{ item }}" | ||
regexp: "^lxc.apparmor.profile" | ||
line: "lxc.apparmor.profile: unconfined" | ||
loop: "{{ proxmox_lxc_filtered_files }}" | ||
notify: reboot containers | ||
|
||
- name: Ensure lxc config has the right cgroup | ||
lineinfile: | ||
dest: "{{ item }}" | ||
regexp: "^lxc.cgroup.devices.allow" | ||
line: "lxc.cgroup.devices.allow: a" | ||
loop: "{{ proxmox_lxc_filtered_files }}" | ||
notify: reboot containers | ||
|
||
- name: Ensure lxc config has the right cap drop | ||
lineinfile: | ||
dest: "{{ item }}" | ||
regexp: "^lxc.cap.drop" | ||
line: "lxc.cap.drop: " | ||
loop: "{{ proxmox_lxc_filtered_files }}" | ||
notify: reboot containers | ||
|
||
- name: Ensure lxc config has the right mounts | ||
lineinfile: | ||
dest: "{{ item }}" | ||
regexp: "^lxc.mount.auto" | ||
line: 'lxc.mount.auto: "proc:rw sys:rw"' | ||
loop: "{{ proxmox_lxc_filtered_files }}" | ||
notify: reboot containers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh -e | ||
|
||
# Kubeadm 1.15 needs /dev/kmsg to be there, but it's not in lxc, but we can just use /dev/console instead | ||
# see: https://github.com/kubernetes-sigs/kind/issues/662 | ||
if [ ! -e /dev/kmsg ]; then | ||
ln -s /dev/console /dev/kmsg | ||
fi | ||
|
||
# https://medium.com/@kvaps/run-kubernetes-in-lxc-container-f04aa94b6c9c | ||
mount --make-rshared / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters