Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b364a1bd4
|
||
|
|
92012be667
|
||
|
|
a06e02c7cc
|
||
|
|
829e8225f6
|
No files matched your search
@@ -1,3 +0,0 @@
|
|||||||
[defaults]
|
|
||||||
inventory = ./hosts.ini
|
|
||||||
vault_password_file = ./secrets-client
|
|
||||||
@@ -1,28 +1,28 @@
|
|||||||
- ansible.builtin.include_role:
|
- ansible.builtin.import_role:
|
||||||
role: ensureparentdir
|
role: ensuredir
|
||||||
apply:
|
become: true
|
||||||
vars:
|
vars:
|
||||||
path: "{{ path }}"
|
path: "{{ subvpath | dirname }}"
|
||||||
|
|
||||||
- name: check if btrfs subv exists
|
- name: check if btrfs subv exists
|
||||||
register: btrfssubvexists
|
register: btrfssubvexists
|
||||||
become: true
|
become: true
|
||||||
failed_when: false
|
failed_when: false
|
||||||
changed_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:
|
- block:
|
||||||
- name: "create btrfs subv {{ path | mandatory }}"
|
- name: "create btrfs subv {{ subvpath | mandatory }}"
|
||||||
when: btrfssubvexists.rc != 0
|
when: btrfssubvexists.rc != 0
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: "btrfs subv create {{ path }}"
|
cmd: "btrfs subv create {{ subvpath }}"
|
||||||
- name: "set owner:group of subv {{ path }}"
|
- name: "set owner:group of subv {{ subvpath }}"
|
||||||
when: btrfssubvexists.rc != 0
|
when: btrfssubvexists.rc != 0
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: touch
|
state: touch
|
||||||
path: "{{ path | mandatory }}"
|
path: "{{ subvpath | mandatory }}"
|
||||||
owner: "{{ owner | mandatory }}"
|
owner: "{{ owner | mandatory }}"
|
||||||
group: "{{ group | default(owner) }}"
|
group: "{{ group | default(owner) }}"
|
||||||
|
|
||||||
@@ -14,5 +14,5 @@
|
|||||||
role: createbtrfssubv
|
role: createbtrfssubv
|
||||||
apply:
|
apply:
|
||||||
vars:
|
vars:
|
||||||
path: "/home/{{ item.name }}/.local/share/containers"
|
subvpath: "/home/{{ item.name }}/.local/share/containers"
|
||||||
owner: "{{ item.name }}"
|
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
|
register: stat_output
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ path | dirname }}"
|
path: "{{ path }}"
|
||||||
|
|
||||||
- name: create dir if not exists
|
- name: create dir if not exists
|
||||||
when: not stat_output.stat.exists
|
when: not stat_output.stat.exists
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ path | dirname }}"
|
path: "{{ path }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: backup and create dir if not dir
|
- name: backup and create dir if not dir
|
||||||
when: stat_output.stat.exists and not stat_output.stat.isdir
|
when: stat_output.stat.exists and not stat_output.stat.isdir
|
||||||
block:
|
block:
|
||||||
- name: "backup existing {{ path | dirname }}"
|
- name: "backup existing {{ path }}"
|
||||||
no_log: true
|
no_log: true
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ path | dirname }}"
|
src: "{{ path }}"
|
||||||
dest: "{{ path | dirname }}.old"
|
dest: "{{ path }}.old"
|
||||||
- name: "delete existing {{ path | dirname }}"
|
- name: "delete existing {{ path }}"
|
||||||
no_log: true
|
no_log: true
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ path | dirname }}"
|
path: "{{ path }}"
|
||||||
state: absent
|
state: absent
|
||||||
- name: "create {{ path | dirname }}"
|
- name: "create {{ path }}"
|
||||||
no_log: true
|
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ path | dirname }}"
|
path: "{{ path }}"
|
||||||
state: directory
|
state: directory
|
||||||
Reference in new issue
Block a user