Skip to content

Commit e11d045

Browse files
authored
adding in fixes from mreeve quality of life fixes branch (#555)
* adding in fixes from mreeve quality of life fixes branch * Fix issue with no directory created * Fix issue with improper executable for shell being used
1 parent 688e7a6 commit e11d045

File tree

4 files changed

+290
-35
lines changed

4 files changed

+290
-35
lines changed

ansible/install_lme_local.yml

Lines changed: 103 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
vars:
77
clone_directory: "{{ clone_dir | default('~/LME') }}"
88
install_user: "root"
9+
tags: ['base', 'all']
910

1011
tasks:
1112
- name: Expand clone_directory path
@@ -94,9 +95,12 @@
9495
#directories
9596
user_config_dir: "/root/.config/containers"
9697
user_secrets_conf: "/root/.config/containers/containers.conf" # Update with actual path
98+
user_storage_conf: "/root/.config/containers/storage.conf" # Update with actual path
99+
global_storage_conf: "/etc/containers/storage.conf" # Update with actual path
97100
config_dir: "/etc/lme"
98101
user_vault_dir: "/etc/lme/vault" # Update with actual path
99102
password_file: "/etc/lme/pass.sh"
103+
tags: ['base', 'all']
100104

101105
tasks:
102106
- name: Create Vault password
@@ -196,16 +200,49 @@
196200
store = "cat > {{ user_vault_dir }}/$SECRET_ID && chmod 700 {{ user_vault_dir }}/$SECRET_ID && ansible-vault encrypt {{ user_vault_dir }}/$SECRET_ID"
197201
delete = "rm {{ user_vault_dir }}/$SECRET_ID"
198202
mode: '0600'
203+
- name: setup root overlay-fs usage
204+
copy:
205+
dest: "{{ user_storage_conf }}"
206+
content: |
207+
[storage]
208+
driver = "overlay"
209+
210+
[storage.options.overlay]
211+
mount_program = "/usr/bin/fuse-overlayfs"
212+
213+
mode: '0600'
214+
215+
- name: Create /etc/containers
216+
file:
217+
path: /etc/containers/
218+
state: directory
219+
owner: "root"
220+
group: "root"
221+
mode: '0744'
222+
223+
- name: setup global overlay-fs usage
224+
copy:
225+
dest: "{{ global_storage_conf }}"
226+
content: |
227+
[storage]
228+
driver = "overlay"
229+
runroot = "/run/containers/storage"
230+
graphroot = "/var/lib/containers/storage"
231+
232+
[storage.options.overlay]
233+
mount_program = "/usr/bin/fuse-overlayfs"
234+
235+
mode: '0600'
199236

200237
- name: Setup Nix
201238
hosts: localhost
202239
connection: local
203-
become: no # Default to no privilege escalation
240+
become: no
204241
vars:
205242
clone_directory: "{{ clone_dir | default('~/LME') }}"
206243
install_user: "{{ ansible_user_id }}"
244+
tags: ['base', 'all']
207245
tasks:
208-
209246
- name: Update apt cache
210247
apt:
211248
update_cache: yes
@@ -219,6 +256,7 @@
219256
- nix-bin
220257
- nix-setup-systemd
221258
- python3-pexpect
259+
- fuse-overlayfs
222260
state: present
223261
become: yes
224262

@@ -237,10 +275,6 @@
237275
append: yes
238276
become: yes
239277

240-
- name: Restart Nix daemon
241-
command: systemctl restart nix-daemon
242-
become: yes
243-
244278
- name: Update PATH for Ansible execution
245279
set_fact:
246280
ansible_env: "{{ ansible_env | combine({'PATH': ansible_env.PATH ~ ':/nix/var/nix/profiles/default/bin'}) }}"
@@ -258,11 +292,59 @@
258292
create: yes
259293
become: yes
260294

295+
- name: Update PATH in user's bashrc
296+
lineinfile:
297+
path: "~/.bashrc"
298+
line: 'export PATH=$PATH:/nix/var/nix/profiles/default/bin'
299+
create: yes
300+
301+
- name: Update PATH in root's bashrc
302+
lineinfile:
303+
path: "/root/.bashrc"
304+
line: 'export PATH=$PATH:/nix/var/nix/profiles/default/bin'
305+
create: yes
306+
become: yes
307+
308+
- name: Setup Podman
309+
hosts: localhost
310+
connection: local
311+
become: no
312+
vars:
313+
clone_directory: "{{ clone_dir | default('~/LME') }}"
314+
install_user: "{{ ansible_user_id }}"
315+
tags: ['system', 'all']
316+
317+
handlers:
318+
- name: restart nix-daemon
319+
systemd:
320+
name: nix-daemon
321+
state: restarted
322+
daemon_reload: yes
323+
become: yes
324+
325+
tasks:
326+
- name: Ensure Nix daemon is running
327+
systemd:
328+
name: nix-daemon
329+
state: started
330+
enabled: yes
331+
become: yes
332+
notify: restart nix-daemon
333+
334+
- name: Wait for Nix daemon to be ready
335+
wait_for:
336+
timeout: 10
337+
when: ansible_play_hosts_all.index(inventory_hostname) == 0
338+
261339
- name: Install Podman using Nix
262340
command: nix-env -iA nixpkgs.podman
263341
become: yes
264342
environment:
265343
PATH: "{{ ansible_env.PATH }}"
344+
register: podman_install
345+
retries: 3
346+
delay: 5
347+
until: podman_install is not failed
266348

267349
- name: Set sysctl limits
268350
command: "{{ clone_directory }}/scripts/set_sysctl_limits.sh"
@@ -280,6 +362,7 @@
280362
become: no # Default to no privilege escalation
281363
vars:
282364
clone_directory: "{{ clone_dir | default('~/LME') }}"
365+
tags: ['system', 'all']
283366
tasks:
284367
#maybe check for each in the shell script below?
285368
- name: Register a variable, ignore errors and continue
@@ -318,6 +401,7 @@
318401
vars:
319402
clone_directory: "{{ clone_dir | default('~/LME') }}"
320403
install_user: "{{ ansible_user_id }}"
404+
tags: ['system', 'all']
321405
tasks:
322406
- name: Enable linger for user
323407
command: "loginctl enable-linger {{ install_user }}"
@@ -367,11 +451,11 @@
367451
- name: Setup Containers for root
368452
hosts: localhost
369453
connection: local
370-
become: no # Default to no privilege escalation
454+
become: no
371455
vars:
372456
clone_directory: "{{ clone_dir | default('~/LME') }}"
457+
tags: ['system', 'all']
373458
tasks:
374-
375459
- name: Add Container Image policy file
376460
copy:
377461
content: |
@@ -386,23 +470,28 @@
386470
become: yes
387471

388472
- name: Pull containers
389-
command: "podman pull {{ item }}"
473+
shell: |
474+
export PATH=$PATH:/nix/var/nix/profiles/default/bin
475+
podman pull {{ item }}
476+
args:
477+
executable: /bin/bash
390478
loop: "{{ lookup('file', clone_directory + '/config/containers.txt').splitlines() }}"
391-
environment:
392-
PATH: "{{ ansible_env.PATH }}"
393479
become: yes
394480

395481
- name: Tag containers
396-
command: "podman image tag {{ item }} {{ item.split('/')[-1].split(':')[0] }}:LME_LATEST"
482+
shell: |
483+
export PATH=$PATH:/nix/var/nix/profiles/default/bin
484+
podman image tag {{ item }} {{ item.split('/')[-1].split(':')[0] }}:LME_LATEST
485+
args:
486+
executable: /bin/bash
397487
loop: "{{ lookup('file', clone_directory + '/config/containers.txt').splitlines() }}"
398-
environment:
399-
PATH: "{{ ansible_env.PATH }}"
400488
become: yes
401489

402490
- name: Start lme.service
403491
hosts: localhost
404492
connection: local
405493
become: yes # Default to no privilege escalation
494+
tags: ['system', 'all']
406495
tasks:
407496
- name: Reload systemd daemon
408497
systemd:

0 commit comments

Comments
 (0)