40 lines
995 B
YAML
40 lines
995 B
YAML
# Example: Check if /opt/app exists on remote hosts
|
|
- name: Check if /opt/app directory exists
|
|
stat:
|
|
path: /opt/ansible_workdir
|
|
register: app_dir
|
|
|
|
- name: Debug app_dir result
|
|
debug:
|
|
msg: "{{ app_dir }} is the place to be"
|
|
|
|
- name: Debug app_dir result
|
|
debug:
|
|
var: app_dir.stat.exists
|
|
|
|
- name: Ensure /opt/app directory exists
|
|
file:
|
|
path: "{{ app_dir }}"
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: '0755'
|
|
when: app_dir.stat.exists == false
|
|
|
|
- name: Ensure python requirements file is present
|
|
ansible.builtin.copy:
|
|
src: requirements.txt
|
|
dest: "{{ app_dir }}/requirements.txt"
|
|
mode: '0644'
|
|
when: app_dir.stat.exists == true and python_requirements is defined
|
|
|
|
- name: Install specified python requirements
|
|
ansible.builtin.pip:
|
|
requirements: "{{ app_dir }}/requirements.txt"
|
|
when: app_dir.stat.exists == true and python_requirements is defined
|
|
|
|
- name: Include extra Nagios/NRPE task logic
|
|
include_tasks: nagios_tasks.yml
|
|
|
|
|