Merge branch 'adaptationPlaybookExistantSolution' into solution

This commit is contained in:
2022-04-26 09:45:36 +02:00
6 changed files with 118 additions and 16 deletions

View File

@@ -1,9 +1,15 @@
---
- name: install apache via ansible playbook
hosts: cibles
hosts: all
handlers:
- name: restart apache
service:
name: "{{ apache_service_name }}"
state: restarted
tasks:
- name: import OS Specific variables
- name: import OS variables
include_vars: "{{ ansible_distribution | lower }}.yml"
- name: install apache
@@ -11,8 +17,59 @@
name: "{{ apache_package_name }}"
state: present
- name: conf httpd
template:
src: vhost.conf
dest: "{{ apache_config_dir}}/vhost.conf"
mode: 0640
owner: root
group: "{{ apache_group_name }}"
notify: restart apache
- name: activate apache
service:
name: "{{ apache_service_name }}"
enabled: yes
state: started
state: started
- name: remove default site conf
file:
path: /etc/apache2/sites-enabled/000-default.conf
state: absent
notify: restart apache
- name: setup firewall
block:
- name: install firewalld packages
yum:
name:
- python3-firewall
- firewalld
state: present
- name: enable firewalld service
service:
name: firewalld
enabled: true
state: started
- name: open firewall port
firewalld:
service: http
permanent: yes
immediate: yes
state: enabled
ignore_errors: true
when: ansible_distribution == 'CentOS'
- name: create documentroot
file:
name: /var/www/html/example.org/
state: directory
- name: copy index file
template:
src: index.txt
dest: /var/www/html/example.org/index.html
mode: 0644