Files
sib_10_premier_playbook/apache.yml
2020-09-22 15:42:05 +02:00

63 lines
1.2 KiB
YAML

---
- name: install apache via ansible playbook
hosts: centos
pre_tasks:
- name: get ressources
get_url:
url: "{{ item }}"
dest: /tmp
loop:
- https://cours.opendoor.fr/Fichiers/SIB/index.txt
- https://cours.opendoor.fr/Fichiers/SIB/vhost.conf
delegate_to: localhost
become: false
post_tasks:
- name: cleanup
file:
path: "{{ item }}"
state: absent
loop:
- /tmp/index.txt
- /tmp/vhost.conf
become: false
delegate_to: localhost
tasks:
- name: install apache
yum:
name: httpd
state: present
- name: conf httpd
template:
src: /tmp/vhost.conf
dest: /etc/httpd/conf.d/vhost.conf
mode: 0640
owner: root
group: apache
- name: activate apache
service:
name: httpd
enabled: yes
state: started
- name: open firewall port
firewalld:
service: http
permanent: yes
immediate: yes
state: enabled
- name: create documentroot
file:
name: /var/www/html/{{ ansible_hostname }}
state: directory
- name: copy index file
template:
src: /tmp/index.txt
dest: /var/www/html/{{ ansible_hostname }}/index.html
mode: 0644