ansible-practice/apache-when.yml
2023-11-08 14:58:46 +00:00

24 lines
599 B
YAML

---
- name: "Apache installation"
hosts: 1-1.practice-k8s.cloud
tasks:
- name: "Apache package installation"
yum:
name: "httpd"
state: "present"
- name: "Apache configuration"
template:
src: "inventory.conf.j2"
dest: "/etc/httpd/conf.d/inventory.conf"
owner: "apache"
group: "apache"
register: apache_conf
- debug: var=apache_conf
- name: "Start apache service"
when: apache_conf.changed
tags: restart
service:
name: "httpd"
state: "started"
enabled: yes