27 lines
589 B
YAML
27 lines
589 B
YAML
---
|
|
- 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
|
|
|