-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix LXC container implementations (#231)
* Need to become to reboot * Fix rc.local insertion of script * Fix syntax Add new line to lxc.yml * Remove need to set fact * Add reset for LXC container config * Fix syntax Its always the newlines.. * remove fact setting from reset task We should mirror the deployment task * Proxmox LXC reset functions * Handle if rc.local already has data * Dont compare literal * Cleanup Erroneous newline * Handle rc.local not present on a hybrid cluster * Update roles/reset/tasks/main.yml Co-authored-by: Simon Leiner <[email protected]> * Update roles/lxc/tasks/main.yml Co-authored-by: Simon Leiner <[email protected]> --------- Co-authored-by: Techno Tim <[email protected]> Co-authored-by: Simon Leiner <[email protected]>
- Loading branch information
1 parent
030eeb4
commit 3a1a7a1
Showing
8 changed files
with
114 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
- name: reboot server | ||
become: true | ||
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 |
---|---|---|
@@ -1,7 +1,21 @@ | ||
--- | ||
- name: configure rc.local for proxmox lxc containers | ||
copy: | ||
src: "{{ playbook_dir }}/scripts/rc.local" | ||
dest: "/etc/rc.local" | ||
- name: Check for rc.local file | ||
stat: | ||
path: /etc/rc.local | ||
register: rcfile | ||
|
||
- name: Create rc.local if needed | ||
lineinfile: | ||
path: /etc/rc.local | ||
line: "#!/bin/sh -e" | ||
create: true | ||
insertbefore: BOF | ||
mode: "u=rwx,g=rx,o=rx" | ||
when: not rcfile.stat.exists | ||
|
||
- name: Write rc.local file | ||
blockinfile: | ||
path: /etc/rc.local | ||
content: "{{ lookup('template', 'templates/rc.local.j2') }}" | ||
state: present | ||
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
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,53 @@ | ||
--- | ||
- 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") }}' | ||
|
||
- name: Remove LXC apparmor profile | ||
lineinfile: | ||
dest: "{{ item }}" | ||
regexp: "^lxc.apparmor.profile" | ||
line: "lxc.apparmor.profile: unconfined" | ||
state: absent | ||
loop: "{{ proxmox_lxc_filtered_files }}" | ||
notify: reboot containers | ||
|
||
- name: Remove lxc cgroups | ||
lineinfile: | ||
dest: "{{ item }}" | ||
regexp: "^lxc.cgroup.devices.allow" | ||
line: "lxc.cgroup.devices.allow: a" | ||
state: absent | ||
loop: "{{ proxmox_lxc_filtered_files }}" | ||
notify: reboot containers | ||
|
||
- name: Remove lxc cap drop | ||
lineinfile: | ||
dest: "{{ item }}" | ||
regexp: "^lxc.cap.drop" | ||
line: "lxc.cap.drop: " | ||
state: absent | ||
loop: "{{ proxmox_lxc_filtered_files }}" | ||
notify: reboot containers | ||
|
||
- name: Remove lxc mounts | ||
lineinfile: | ||
dest: "{{ item }}" | ||
regexp: "^lxc.mount.auto" | ||
line: 'lxc.mount.auto: "proc:rw sys:rw"' | ||
state: absent | ||
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
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