--- - name: install apache via ansible playbook hosts: cibles vars: apache_site_name: "orsys.fr" apache_documentroot: "/srv/www/{{ apache_site_name }}" handlers: - name: restart apache service: name: httpd state: restarted tasks: - name: install apache yum: name: httpd state: latest - name: conf httpd template: src: vhost.conf dest: /etc/httpd/conf.d/vhost.conf mode: 0640 owner: root group: apache notify: restart apache - name: activate apache service: name: httpd enabled: yes state: started - name: open firewall port firewalld: service: http permanent: yes immediate: yes state: enabled ignore_errors: yes - name: create documentroot file: name: "{{ apache_documentroot }}" state: directory - name: create index file copy: src: index.txt dest: "{{ apache_documentroot }}/index.html" mode: 0644