У меня есть руководство, в котором я проверяю, могу ли я установить агент, что я хотел бы сделать, и следующее, когда в моем есть игнорируемый, где, например, где я проверяю, есть ли /opt/Agent/
каталог, в противном случае я хотел бы создать этот каталог, как это сделать?
---
- hosts: all
tasks:
- name: 'Ensure that free space on /opt/Agent/ is grater than 1.5GB'
assert:
that: item.size_available >= 1500000000
msg: 'disk space has reached 1.5GB threshold'
when: item.mount == mountname
with_items: '{{ ansible_mounts }}'
- name: Ansible check agent is present.
stat:
path: /etc/init.d/agent
register: file_details
- debug:
msg: "Agent is present"
when: file_details.stat.exists
- name: Ansible check directory Agent exists.
stat:
path: /opt/Agent/
register: files_to_delete
- debug:
msg: "Directory Agent exists"
when: files_to_delete.stat.exists and files_to_delete.stat.isdir
vars:
mountname: '/opt/Agent/'