Changed delete logic

This commit is contained in:
Cory Hawkless 2022-12-02 16:41:08 +10:30
parent 6acbb03400
commit 2b3fee1779
1 changed files with 30 additions and 15 deletions

View File

@ -19,24 +19,39 @@
state: absent
tags: interfaces
- name: Get directory stats
stat:
path: "/etc/netplan"
register: directory_stat
# - name: Get directory stats
# stat:
# path: "/etc/netplan"
# register: directory_stat
- name: Delete directory
# - name: Delete directory
# file:
# path: "/etc/netplan"
# state: absent
# - name: Create directory
# file:
# path: "/etc/netplan"
# state: directory
# owner: "{{ directory_stat.stat.pw_name }}"
# group: "{{ directory_stat.stat.gr_name }}"
# mode: "{{ directory_stat.stat.mode }}"
- name: 'Collect files in netplan dir'
find:
paths: "/etc/netplan/"
hidden: True
recurse: True
# file_type: any # Added in ansible 2.3
register: collected_files
tags: interfaces
- name: Remove collected files
file:
path: "/etc/netplan"
path: "{{ item.path }}"
state: absent
- name: Create directory
file:
path: "/etc/netplan"
state: directory
owner: "{{ directory_stat.stat.pw_name }}"
group: "{{ directory_stat.stat.gr_name }}"
mode: "{{ directory_stat.stat.mode }}"
with_items: "{{ collected_files.files }}"
tags: interfaces
- name: Add the bonding module
modprobe:
name: bonding