Compare commits

..
4 Commits
Author SHA1 Message Date
kevinnlsamuel 0b364a1bd4 cleanup 2026-09-15 21:57:20 +05:30
kevinnlsamuel 92012be667 catch up with refactor 2026-09-15 21:56:38 +05:30
kevinnlsamuel a06e02c7cc refactor 2/2: ensureparentdir > ensuredir 2026-09-15 21:55:40 +05:30
kevinnlsamuel 829e8225f6 refactor 1/2 ensureparentdir > ensuredir 2026-09-15 21:53:54 +05:30
5 changed files with 22 additions and 26 deletions

No files matched your search

-3
View File
@@ -1,3 +0,0 @@
[defaults]
inventory = ./hosts.ini
vault_password_file = ./secrets-client
+10 -10
View File
@@ -1,28 +1,28 @@
- ansible.builtin.include_role:
role: ensureparentdir
apply:
vars:
path: "{{ path }}"
- ansible.builtin.import_role:
role: ensuredir
become: true
vars:
path: "{{ subvpath | dirname }}"
- name: check if btrfs subv exists
register: btrfssubvexists
become: true
failed_when: false
changed_when: false
ansible.builtin.shell: "btrfs subv list {{ path | mandatory | dirname }} | grep -qF {{ path | basename }}"
ansible.builtin.shell: "btrfs subv list {{ subvpath | mandatory | dirname }} | grep -qF {{ subvpath | basename }}"
- block:
- name: "create btrfs subv {{ path | mandatory }}"
- name: "create btrfs subv {{ subvpath | mandatory }}"
when: btrfssubvexists.rc != 0
become: true
ansible.builtin.command:
cmd: "btrfs subv create {{ path }}"
- name: "set owner:group of subv {{ path }}"
cmd: "btrfs subv create {{ subvpath }}"
- name: "set owner:group of subv {{ subvpath }}"
when: btrfssubvexists.rc != 0
become: true
ansible.builtin.file:
state: touch
path: "{{ path | mandatory }}"
path: "{{ subvpath | mandatory }}"
owner: "{{ owner | mandatory }}"
group: "{{ group | default(owner) }}"
+2 -2
View File
@@ -14,5 +14,5 @@
role: createbtrfssubv
apply:
vars:
path: "/home/{{ item.name }}/.local/share/containers"
owner: "{{ item.name }}"
subvpath: "/home/{{ item.name }}/.local/share/containers"
owner: "{{ item.name }}"
File renamed without changes.
@@ -1,29 +1,28 @@
- name: check if parent dir exists
- name: check if dir exists
register: stat_output
ansible.builtin.stat:
path: "{{ path | dirname }}"
path: "{{ path }}"
- name: create dir if not exists
when: not stat_output.stat.exists
ansible.builtin.file:
path: "{{ path | dirname }}"
path: "{{ path }}"
state: directory
- name: backup and create dir if not dir
when: stat_output.stat.exists and not stat_output.stat.isdir
block:
- name: "backup existing {{ path | dirname }}"
- name: "backup existing {{ path }}"
no_log: true
ansible.builtin.copy:
src: "{{ path | dirname }}"
dest: "{{ path | dirname }}.old"
- name: "delete existing {{ path | dirname }}"
src: "{{ path }}"
dest: "{{ path }}.old"
- name: "delete existing {{ path }}"
no_log: true
ansible.builtin.file:
path: "{{ path | dirname }}"
path: "{{ path }}"
state: absent
- name: "create {{ path | dirname }}"
no_log: true
- name: "create {{ path }}"
ansible.builtin.file:
path: "{{ path | dirname }}"
path: "{{ path }}"
state: directory