neuro_ansible/yaml_sub/myrepo_clean.yaml

28 lines
589 B
YAML
Raw Normal View History

2024-03-29 01:55:48 +01:00
---
- name: Find files everything except myrepo.repo
find:
paths: /etc/yum.repos.d
file_type: file
excludes: "myrepo.repo"
register: output
- name: Delete other files
file:
path: "{{ item.path }}"
state: absent
loop: "{{ output.files }}"
- name: Check for marker line
lineinfile:
path: /etc/yum.repos.d/myrepo.repo
create: true
state: present
line: "# BEGIN ANSIBLE MANAGED BLOCK"
register: marker_check
- name: Delete file if marker is absent
file:
path: /etc/yum.repos.d/myrepo.repo
state: absent
when: marker_check.changed